pkgsrc-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
pkg/49759: pth call incorrect syscall when netbsd-6 or lator
>Number: 49759
>Category: pkg
>Synopsis: pth call incorrect syscall when netbsd-6 or lator
>Confidential: no
>Severity: critical
>Priority: medium
>Responsible: pkg-manager
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Mar 19 14:35:01 +0000 2015
>Originator: Yasushi Oshima
>Release: pkgsrc-current at Mar 19 2015
>Organization:
>Environment:
NetBSD n6i836 6.1.5 NetBSD 6.1.5 (GENERIC)
>Description:
When run gpg-agent --daemon --enable-ssh-support and run gpg2 --card-status, the /usr/pkg/libexec/scdaemon uses 100% CPU load.
It will occur on all 32bit NetBSD platform after NetBSD-6.0.
This cause is in devel/pth.
The syscall interface of pth, it calls symbol name such as "select" from libc.so by dlsym().
But the 'select' syscall was changed from NetBSD-6.
It is 'compat_50_select' for NetBSD 5 or before compatible with 32bit time_t interface.
In native build on NetBSD-6 or later, it should use a new syscall '__syscall50'.
By the same reason 'nanosleep' should be '__nanosleep50' and 'wait4' should be '__wait450'.
>How-To-Repeat:
In NetBSD/i386 6.x or 7.0_BETA,
- build pkgsrc/security/gnupg2
- run
/usr/pkg/libexec/scdaemon --daemon
>Fix:
The patch-ad for pth_syscall.c will below:
--- pth_syscall.c.orig 2006-06-08 17:54:03.000000000 +0000
+++ pth_syscall.c
@@ -57,6 +57,7 @@
#define sendto __pth_sys_sendto
#define pread __pth_sys_pread
#define pwrite __pth_sys_pwrite
+#define wait4 __pth_sys_wait4
/* include the private header and this way system headers */
#include "pth_p.h"
@@ -108,6 +109,7 @@ int pth_syscall_hard = PTH_SYSCALL_HARD;
#undef sendto
#undef pread
#undef pwrite
+#undef wait4
/* internal data structures */
#if cpp
@@ -157,15 +159,28 @@ intern pth_syscall_fct_tab_t pth_syscall
#define PTH_SCF_sendto 19
#define PTH_SCF_pread 20
#define PTH_SCF_pwrite 21
+#define PTH_SCF_wait4 22
{ "fork", NULL },
{ "waitpid", NULL },
{ "system", NULL },
+#if defined(__NetBSD__) && defined(SYS___nanosleep50)
+ { "__nanosleep50", NULL },
+#else
{ "nanosleep", NULL },
+#endif
{ "usleep", NULL },
{ "sleep", NULL },
+#if defined(__NetBSD__)
+ { "__sigprocmask14", NULL },
+#else
{ "sigprocmask", NULL },
+#endif
{ "sigwait", NULL },
+#if defined(__NetBSD__) && defined(SYS___select50)
+ { "__select50", NULL },
+#else
{ "select", NULL },
+#endif
{ "poll", NULL },
{ "connect", NULL },
{ "accept", NULL },
@@ -179,6 +194,11 @@ intern pth_syscall_fct_tab_t pth_syscall
{ "sendto", NULL },
{ "pread", NULL },
{ "pwrite", NULL },
+#if defined(__NetBSD__) && defined(SYS___wait450)
+ { "__wait450", NULL },
+#else
+ { "wait4", NULL },
+#endif
{ NULL, NULL }
};
#endif
@@ -405,6 +425,10 @@ intern pid_t pth_sc_waitpid(pid_t wpid,
(wpid, status, options);
#if defined(HAVE_SYSCALL) && defined(SYS_waitpid)
else return (pid_t)syscall(SYS_waitpid, wpid, status, options);
+#elif defined(HAVE_SYSCALL) && defined(SYS_wait4)
+ else return (pid_t)syscall(SYS_wait4, wpid, status, options, (struct rusage *) NULL);
+#elif defined(HAVE_SYSCALL) && defined(SYS___wait450)
+ else return (pid_t)syscall(SYS___wait450, wpid, status, options, (struct rusage *) NULL);
#else
else PTH_SYSCALL_ERROR(-1, ENOSYS, "waitpid");
#endif
@@ -491,6 +515,8 @@ intern int pth_sc_select(int nfds, fd_se
else return (int)syscall(SYS__newselect, nfds, readfds, writefds, exceptfds, timeout);
#elif defined(HAVE_SYSCALL) && defined(SYS_select)
else return (int)syscall(SYS_select, nfds, readfds, writefds, exceptfds, timeout);
+#elif defined(HAVE_SYSCALL) && defined(SYS___select50)
+ else return (int)syscall(SYS___select50, nfds, readfds, writefds, exceptfds, timeout);
#else
else PTH_SYSCALL_ERROR(-1, ENOSYS, "accept");
#endif
@@ -721,5 +747,29 @@ intern ssize_t pth_sc_sendto(int fd, con
#endif
}
+/* ==== Pth hard syscall wrapper for wait4(2) ==== */
+pid_t wait4(pid_t, int *, int, struct rusage *);
+pid_t wait4(pid_t wpid, int *status, int options, struct rusage *rusage)
+{
+ /* external entry point for application */
+ pth_implicit_init();
+ return pth_wait4(wpid, status, options, rusage);
+}
+intern pid_t pth_sc_wait4(pid_t wpid, int *status, int options, struct rusage *rusage)
+{
+ /* internal exit point for Pth */
+ if (pth_syscall_fct_tab[PTH_SCF_wait4].addr != NULL)
+ return ((pid_t (*)(pid_t, int *, int, struct rusage *))
+ pth_syscall_fct_tab[PTH_SCF_wait4].addr)
+ (wpid, status, options, rusage);
+#if defined(HAVE_SYSCALL) && defined(SYS_wait4)
+ else return (pid_t)syscall(SYS_wait4, wpid, status, options, rusage);
+#elif defined(HAVE_SYSCALL) && defined(SYS___wait450)
+ else return (pid_t)syscall(SYS___wait450, wpid, status, options, rusage);
+#else
+ else PTH_SYSCALL_ERROR(-1, ENOSYS, "wait4");
+#endif
+}
+
#endif /* PTH_SYSCALL_HARD */
Home |
Main Index |
Thread Index |
Old Index