CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: thorpej Date: Fri Dec 4 00:26:16 UTC 2020 Modified Files: src/sys/compat/linux/common: linux_misc_notalpha.c Log Message: Rewrite linux_sys_alarm() to use dogetitimer() / dosetitimer(), rather than fiddling with process timers directly. To generate a diff of this commit: cvs rdiff -u -r1.110 -r1.111 \ src/sys/compat/linux/common/linux_misc_notalpha.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_misc_notalpha.c diff -u src/sys/compat/linux/common/linux_misc_notalpha.c:1.110 src/sys/compat/linux/common/linux_misc_notalpha.c:1.111 --- src/sys/compat/linux/common/linux_misc_notalpha.c:1.110 Thu Nov 29 17:40:12 2018 +++ src/sys/compat/linux/common/linux_misc_notalpha.c Fri Dec 4 00:26:16 2020 @@ -1,7 +1,7 @@ -/* $NetBSD: linux_misc_notalpha.c,v 1.110 2018/11/29 17:40:12 maxv Exp $ */ +/* $NetBSD: linux_misc_notalpha.c,v 1.111 2020/12/04 00:26:16 thorpej Exp $ */ /*- - * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. + * Copyright (c) 1995, 1998, 2008, 2020 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_misc_notalpha.c,v 1.110 2018/11/29 17:40:12 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_misc_notalpha.c,v 1.111 2020/12/04 00:26:16 thorpej Exp $"); /* * Note that we must NOT include "opt_compat_linux32.h" here, @@ -88,9 +88,7 @@ __KERNEL_RCSID(0, "$NetBSD: linux_misc_n /* * Alarm. This is a libc call which uses setitimer(2) in NetBSD. - * Fiddle with the timers to make it work. - * - * XXX This shouldn't be dicking about with the ptimer stuff directly. + * Do the same here. */ int linux_sys_alarm(struct lwp *l, const struct linux_sys_alarm_args *uap, register_t *retval) @@ -99,98 +97,28 @@ linux_sys_alarm(struct lwp *l, const str syscallarg(unsigned int) secs; } */ struct proc *p = l->l_proc; - struct timespec now; - struct itimerspec *itp, it; - struct ptimer *ptp, *spare; - extern kmutex_t timer_lock; - struct ptimers *pts; - - if ((pts = p->p_timers) == NULL) - pts = timers_alloc(p); - spare = NULL; - - retry: - mutex_spin_enter(_lock); - if (pts && pts->pts_timers[ITIMER_REAL]) - itp = >pts_timers[ITIMER_REAL]->pt_time; - else - itp = NULL; - /* - * Clear any pending timer alarms. - */ - if (itp) { - callout_stop(>pts_timers[ITIMER_REAL]->pt_ch); - timespecclear(>it_interval); - getnanotime(); - if (timespecisset(>it_value) && - timespeccmp(>it_value, , >)) - timespecsub(>it_value, , >it_value); - /* - * Return how many seconds were left (rounded up) - */ - retval[0] = itp->it_value.tv_sec; - if (itp->it_value.tv_nsec) - retval[0]++; - } else { - retval[0] = 0; - } + struct itimerval itv, oitv; + int error; - /* - * alarm(0) just resets the timer. - */ - if (SCARG(uap, secs) == 0) { - if (itp) - timespecclear(>it_value); - mutex_spin_exit(_lock); - return 0; + timerclear(_interval); + itv.it_value.tv_sec = SCARG(uap, secs); + itv.it_value.tv_usec = 0; + if (itv.it_value.tv_sec < 0) { + return EINVAL; } - /* - * Check the new alarm time for sanity, and set it. - */ - timespecclear(_interval); - it.it_value.tv_sec = SCARG(uap, secs); - it.it_value.tv_nsec = 0; - if (itimespecfix(_value) || itimespecfix(_interval)) { - mutex_spin_exit(_lock); - return (EINVAL); + if ((error = dogetitimer(p, ITIMER_REAL, )) != 0) { + return error; } - - ptp = pts->pts_timers[ITIMER_REAL]; - if (ptp == NULL) { - if (spare == NULL) { - mutex_spin_exit(_lock); - spare = pool_get(_pool, PR_WAITOK); - memset(spare, 0, sizeof(*spare)); - goto retry; - } - ptp = spare; - spare = NULL; - ptp->pt_ev.sigev_notify = SIGEV_SIGNAL; - ptp->pt_ev.sigev_signo = SIGALRM; - ptp->pt_overruns = 0; - ptp->pt_proc = p; - ptp->pt_type = CLOCK_REALTIME; - ptp->pt_entry = CLOCK_REALTIME; - ptp->pt_active = 0; - ptp->pt_queued = 0; - callout_init(>pt_ch, CALLOUT_MPSAFE); - pts->pts_timers[ITIMER_REAL] = ptp; + if (oitv.it_value.tv_usec) { + oitv.it_value.tv_sec++; } - if (timespecisset(_value)) { - /* - * Don't need to check tvhzto() return value, here. - * callout_reset() does it for us. - */ - getnanotime(); - timespecadd(_value, , _value); - callout_reset(>pt_ch, tshzto(_value), - realtimerexpire, ptp); + if ((error = dosetitimer(p, ITIMER_REAL, )) != 0) { + return error; } - ptp->pt_time = it; - mutex_spin_exit(_lock); + *retval = oitv.it_value.tv_sec; return 0; } #endif /* !COMPAT_LINUX32 */
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: christos Date: Tue Nov 3 22:08:44 UTC 2020 Modified Files: src/sys/compat/linux/common: linux_socket.c Log Message: PR/55780: Bernd Sieker: setsockopt in Linux emulation misses some options To generate a diff of this commit: cvs rdiff -u -r1.151 -r1.152 src/sys/compat/linux/common/linux_socket.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_socket.c diff -u src/sys/compat/linux/common/linux_socket.c:1.151 src/sys/compat/linux/common/linux_socket.c:1.152 --- src/sys/compat/linux/common/linux_socket.c:1.151 Sat Oct 24 05:01:56 2020 +++ src/sys/compat/linux/common/linux_socket.c Tue Nov 3 17:08:44 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_socket.c,v 1.151 2020/10/24 09:01:56 mgorny Exp $ */ +/* $NetBSD: linux_socket.c,v 1.152 2020/11/03 22:08:44 christos Exp $ */ /*- * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.151 2020/10/24 09:01:56 mgorny Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.152 2020/11/03 22:08:44 christos Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -861,11 +861,11 @@ linux_to_bsd_so_sockopt(int lopt) return SO_DEBUG; case LINUX_SO_REUSEADDR: /* - * Linux does not implement SO_REUSEPORT, but allows reuse of a - * host:port pair through SO_REUSEADDR even if the address is not a - * multicast-address. Effectively, this means that we should use - * SO_REUSEPORT to allow Linux applications to not exit with - * EADDRINUSE + * Linux does not implement SO_REUSEPORT, but allows reuse of + * a host:port pair through SO_REUSEADDR even if the address + * is not a multicast-address. Effectively, this means that we + * should use SO_REUSEPORT to allow Linux applications to not + * exit with EADDRINUSE */ return SO_REUSEPORT; case LINUX_SO_TYPE: @@ -880,20 +880,51 @@ linux_to_bsd_so_sockopt(int lopt) return SO_SNDBUF; case LINUX_SO_RCVBUF: return SO_RCVBUF; - case LINUX_SO_SNDLOWAT: - return SO_SNDLOWAT; - case LINUX_SO_RCVLOWAT: - return SO_RCVLOWAT; case LINUX_SO_KEEPALIVE: return SO_KEEPALIVE; case LINUX_SO_OOBINLINE: return SO_OOBINLINE; + case LINUX_SO_NO_CHECK: + case LINUX_SO_PRIORITY: + return -1; case LINUX_SO_LINGER: return SO_LINGER; + case LINUX_SO_BSDCOMPAT: + case LINUX_SO_PASSCRED: + case LINUX_SO_PEERCRED: + return -1; + case LINUX_SO_RCVLOWAT: + return SO_RCVLOWAT; + case LINUX_SO_SNDLOWAT: + return SO_SNDLOWAT; + case LINUX_SO_RCVTIMEO: + return SO_RCVTIMEO; + case LINUX_SO_SNDTIMEO: + return SO_SNDTIMEO; + case LINUX_SO_SECURITY_AUTHENTICATION: + case LINUX_SO_SECURITY_ENCRYPTION_TRANSPORT: + case LINUX_SO_SECURITY_ENCRYPTION_NETWORK: + case LINUX_SO_BINDTODEVICE: + case LINUX_SO_ATTACH_FILTER: + case LINUX_SO_DETACH_FILTER: + case LINUX_SO_PEERNAME: + return -1; + case LINUX_SO_TIMESTAMP: + return SO_TIMESTAMP; case LINUX_SO_ACCEPTCONN: - return SO_ACCEPTCONN; - case LINUX_SO_PRIORITY: - case LINUX_SO_NO_CHECK: + case LINUX_SO_PEERSEC: + case LINUX_SO_SNDBUFFORCE: + case LINUX_SO_RCVBUFFORCE: + case LINUX_SO_PASSSEC: + case LINUX_SO_TIMESTAMPNS: + case LINUX_SO_MARK: + case LINUX_SO_TIMESTAMPING: + case LINUX_SO_PROTOCOL: + case LINUX_SO_DOMAIN: + case LINUX_SO_RXQ_OVFL: + case LINUX_SO_WIFI_STATUS: + case LINUX_SO_PEEK_OFF: + case LINUX_SO_NOFCS: default: return -1; }
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: mgorny Date: Sat Oct 24 09:01:56 UTC 2020 Modified Files: src/sys/compat/linux/common: linux_socket.c Log Message: Fix compat with Linux programs that use longer namelen for sockets Linux is less strict than NetBSD and permits namelen to be larger than valid struct sockaddr_in*. If this is the case, truncate the value to the correct size, so that NetBSD networking does not return an error. Reviewed by kamil To generate a diff of this commit: cvs rdiff -u -r1.150 -r1.151 src/sys/compat/linux/common/linux_socket.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_socket.c diff -u src/sys/compat/linux/common/linux_socket.c:1.150 src/sys/compat/linux/common/linux_socket.c:1.151 --- src/sys/compat/linux/common/linux_socket.c:1.150 Thu Jul 16 15:02:08 2020 +++ src/sys/compat/linux/common/linux_socket.c Sat Oct 24 09:01:56 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_socket.c,v 1.150 2020/07/16 15:02:08 msaitoh Exp $ */ +/* $NetBSD: linux_socket.c,v 1.151 2020/10/24 09:01:56 mgorny Exp $ */ /*- * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.150 2020/07/16 15:02:08 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.151 2020/10/24 09:01:56 mgorny Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -1612,6 +1612,21 @@ linux_get_sa(struct lwp *l, int s, struc sin6->sin6_scope_id = 0; } + /* + * Linux is less strict than NetBSD and permits namelen to be larger + * than valid struct sockaddr_in*. If this is the case, truncate + * the value to the correct size, so that NetBSD networking does not + * return an error. + */ + switch (bdom) { + case AF_INET: + namelen = MIN(namelen, sizeof(struct sockaddr_in)); + break; + case AF_INET6: + namelen = MIN(namelen, sizeof(struct sockaddr_in6)); + break; + } + sb->sb_family = bdom; sb->sb_len = namelen; ktrkuser("mbsoname", sb, namelen);
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: rin Date: Thu May 14 08:26:29 UTC 2020 Modified Files: src/sys/compat/linux/common: linux_sched.c Log Message: Fix previous; specify lwpid for curlpw in the case of pid == 0. For linux_sys_sched_setaffinity, pid == 0 means the current thread. On the other hand, for our native sys_sched_setaffinity, lid == 0 means all lwp's that belong to the process. To generate a diff of this commit: cvs rdiff -u -r1.76 -r1.77 src/sys/compat/linux/common/linux_sched.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_sched.c diff -u src/sys/compat/linux/common/linux_sched.c:1.76 src/sys/compat/linux/common/linux_sched.c:1.77 --- src/sys/compat/linux/common/linux_sched.c:1.76 Wed Apr 29 01:55:18 2020 +++ src/sys/compat/linux/common/linux_sched.c Thu May 14 08:26:29 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_sched.c,v 1.76 2020/04/29 01:55:18 thorpej Exp $ */ +/* $NetBSD: linux_sched.c,v 1.77 2020/05/14 08:26:29 rin Exp $ */ /*- * Copyright (c) 1999, 2019 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_sched.c,v 1.76 2020/04/29 01:55:18 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_sched.c,v 1.77 2020/05/14 08:26:29 rin Exp $"); #include #include @@ -671,12 +671,14 @@ linux_sys_sched_setaffinity(struct lwp * struct sys__sched_setaffinity_args ssa; size_t size; pid_t pid; + lwpid_t lid; size = LINUX_CPU_MASK_SIZE; if (SCARG(uap, len) < size) return EINVAL; - if (SCARG(uap, pid) != 0) { + lid = SCARG(uap, pid); + if (lid != 0) { /* Get the canonical PID for the process. */ mutex_enter(proc_lock); struct proc *p = proc_find_lwpid(SCARG(uap, pid)); @@ -687,11 +689,12 @@ linux_sys_sched_setaffinity(struct lwp * pid = p->p_pid; mutex_exit(proc_lock); } else { - pid = 0; + pid = curproc->p_pid; + lid = curlwp->l_lid; } SCARG(, pid) = pid; - SCARG(, lid) = SCARG(uap, pid); + SCARG(, lid) = lid; SCARG(, size) = size; SCARG(, cpuset) = (cpuset_t *)SCARG(uap, mask);
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: thorpej Date: Wed Apr 29 01:55:18 UTC 2020 Modified Files: src/sys/compat/linux/common: linux_sched.c Log Message: Fix proc / lwp lookup processing in linux_sys_sched_getaffinity() and linux_sys_sched_setaffinity(). They were incorrect even before the LWP ID changes, but those changes exposed the latent bugs. To generate a diff of this commit: cvs rdiff -u -r1.75 -r1.76 src/sys/compat/linux/common/linux_sched.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_sched.c diff -u src/sys/compat/linux/common/linux_sched.c:1.75 src/sys/compat/linux/common/linux_sched.c:1.76 --- src/sys/compat/linux/common/linux_sched.c:1.75 Fri Apr 24 03:22:06 2020 +++ src/sys/compat/linux/common/linux_sched.c Wed Apr 29 01:55:18 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_sched.c,v 1.75 2020/04/24 03:22:06 thorpej Exp $ */ +/* $NetBSD: linux_sched.c,v 1.76 2020/04/29 01:55:18 thorpej Exp $ */ /*- * Copyright (c) 1999, 2019 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_sched.c,v 1.75 2020/04/24 03:22:06 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_sched.c,v 1.76 2020/04/29 01:55:18 thorpej Exp $"); #include #include @@ -608,6 +608,7 @@ linux_sys_sched_getaffinity(struct lwp * syscallarg(unsigned int) len; syscallarg(unsigned long *) mask; } */ + struct proc *p; struct lwp *t; kcpuset_t *kcset; size_t size; @@ -618,15 +619,23 @@ linux_sys_sched_getaffinity(struct lwp * if (SCARG(uap, len) < size) return EINVAL; - /* Lock the LWP */ - t = lwp_find2(SCARG(uap, pid), l->l_lid); - if (t == NULL) - return ESRCH; + if (SCARG(uap, pid) == 0) { + p = curproc; + mutex_enter(p->p_lock); + t = curlwp; + } else { + t = lwp_find2(-1, SCARG(uap, pid)); + if (__predict_false(t == NULL)) { + return ESRCH; + } + p = t->l_proc; + KASSERT(mutex_owned(p->p_lock)); + } /* Check the permission */ if (kauth_authorize_process(l->l_cred, - KAUTH_PROCESS_SCHEDULER_GETAFFINITY, t->l_proc, NULL, NULL, NULL)) { - mutex_exit(t->l_proc->p_lock); + KAUTH_PROCESS_SCHEDULER_GETAFFINITY, p, NULL, NULL, NULL)) { + mutex_exit(p->p_lock); return EPERM; } @@ -644,7 +653,7 @@ linux_sys_sched_getaffinity(struct lwp * kcpuset_set(kcset, i); } lwp_unlock(t); - mutex_exit(t->l_proc->p_lock); + mutex_exit(p->p_lock); error = kcpuset_copyout(kcset, (cpuset_t *)SCARG(uap, mask), size); kcpuset_unuse(kcset, NULL); *retval = size; @@ -661,13 +670,28 @@ linux_sys_sched_setaffinity(struct lwp * } */ struct sys__sched_setaffinity_args ssa; size_t size; + pid_t pid; size = LINUX_CPU_MASK_SIZE; if (SCARG(uap, len) < size) return EINVAL; - SCARG(, pid) = SCARG(uap, pid); - SCARG(, lid) = l->l_lid; + if (SCARG(uap, pid) != 0) { + /* Get the canonical PID for the process. */ + mutex_enter(proc_lock); + struct proc *p = proc_find_lwpid(SCARG(uap, pid)); + if (p == NULL) { + mutex_exit(proc_lock); + return ESRCH; + } + pid = p->p_pid; + mutex_exit(proc_lock); + } else { + pid = 0; + } + + SCARG(, pid) = pid; + SCARG(, lid) = SCARG(uap, pid); SCARG(, size) = size; SCARG(, cpuset) = (cpuset_t *)SCARG(uap, mask);
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: thorpej Date: Wed Apr 29 01:55:52 UTC 2020 Modified Files: src/sys/compat/linux/common: linux_signal.c Log Message: Fix proc lookup by distinguishing between the "tgid" and "tid" cases. To generate a diff of this commit: cvs rdiff -u -r1.81 -r1.82 src/sys/compat/linux/common/linux_signal.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_signal.c diff -u src/sys/compat/linux/common/linux_signal.c:1.81 src/sys/compat/linux/common/linux_signal.c:1.82 --- src/sys/compat/linux/common/linux_signal.c:1.81 Fri Aug 23 08:31:11 2019 +++ src/sys/compat/linux/common/linux_signal.c Wed Apr 29 01:55:52 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_signal.c,v 1.81 2019/08/23 08:31:11 maxv Exp $ */ +/* $NetBSD: linux_signal.c,v 1.82 2020/04/29 01:55:52 thorpej Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_signal.c,v 1.81 2019/08/23 08:31:11 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_signal.c,v 1.82 2020/04/29 01:55:52 thorpej Exp $"); #define COMPAT_LINUX 1 @@ -749,10 +749,6 @@ linux_do_tkill(struct lwp *l, int tgid, return EINVAL; signum = linux_to_native_signo[signum]; - if (tgid == -1) { - tgid = tid; - } - KSI_INIT(); ksi.ksi_signo = signum; ksi.ksi_code = SI_LWP; @@ -761,7 +757,10 @@ linux_do_tkill(struct lwp *l, int tgid, ksi.ksi_lid = tid; mutex_enter(proc_lock); - p = proc_find(tgid); + if (tgid != -1) + p = proc_find(tgid); + else + p = proc_find_lwpid(tid); if (p == NULL) { mutex_exit(proc_lock); return ESRCH;
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: christos Date: Sun Jul 15 21:31:00 UTC 2018 Modified Files: src/sys/compat/linux/common: linux_exec_elf32.c Log Message: - fix constants and explain limit - use machine32 instead of hard-coded x86 stuff To generate a diff of this commit: cvs rdiff -u -r1.96 -r1.97 src/sys/compat/linux/common/linux_exec_elf32.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_exec_elf32.c diff -u src/sys/compat/linux/common/linux_exec_elf32.c:1.96 src/sys/compat/linux/common/linux_exec_elf32.c:1.97 --- src/sys/compat/linux/common/linux_exec_elf32.c:1.96 Mon Jul 9 01:43:35 2018 +++ src/sys/compat/linux/common/linux_exec_elf32.c Sun Jul 15 17:31:00 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_exec_elf32.c,v 1.96 2018/07/09 05:43:35 msaitoh Exp $ */ +/* $NetBSD: linux_exec_elf32.c,v 1.97 2018/07/15 21:31:00 christos Exp $ */ /*- * Copyright (c) 1995, 1998, 2000, 2001 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_exec_elf32.c,v 1.96 2018/07/09 05:43:35 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_exec_elf32.c,v 1.97 2018/07/15 21:31:00 christos Exp $"); #ifndef ELFSIZE /* XXX should die */ @@ -323,8 +323,9 @@ ELFNAME2(linux,go_rt0_signature)(struct goto out; } - if (sh[i].sh_size > 1024 * 1014) - sh[i].sh_size = 1014 * 1014; + // Don't scan more than 1MB + if (sh[i].sh_size > 1024 * 1024) + sh[i].sh_size = 1024 * 1024; tmp = malloc(sh[i].sh_size, M_TEMP, M_WAITOK); error = exec_read_from(l, epp->ep_vp, sh[i].sh_offset, tmp, @@ -333,8 +334,9 @@ ELFNAME2(linux,go_rt0_signature)(struct goto out; #if (ELFSIZE == 32) - if (strcmp(machine, "amd64") == 0) - m = "i386"; + extern const char machine32[] __weak; + if (machine32 != NULL) + m = machine32; else m = machine; #else
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: msaitoh Date: Mon Jul 9 05:43:35 UTC 2018 Modified Files: src/sys/compat/linux/common: linux_exec_elf32.c Log Message: Fix compile error. To generate a diff of this commit: cvs rdiff -u -r1.95 -r1.96 src/sys/compat/linux/common/linux_exec_elf32.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_exec_elf32.c diff -u src/sys/compat/linux/common/linux_exec_elf32.c:1.95 src/sys/compat/linux/common/linux_exec_elf32.c:1.96 --- src/sys/compat/linux/common/linux_exec_elf32.c:1.95 Sun Jul 8 17:58:39 2018 +++ src/sys/compat/linux/common/linux_exec_elf32.c Mon Jul 9 05:43:35 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_exec_elf32.c,v 1.95 2018/07/08 17:58:39 christos Exp $ */ +/* $NetBSD: linux_exec_elf32.c,v 1.96 2018/07/09 05:43:35 msaitoh Exp $ */ /*- * Copyright (c) 1995, 1998, 2000, 2001 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_exec_elf32.c,v 1.95 2018/07/08 17:58:39 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_exec_elf32.c,v 1.96 2018/07/09 05:43:35 msaitoh Exp $"); #ifndef ELFSIZE /* XXX should die */ @@ -78,7 +78,7 @@ __KERNEL_RCSID(0, "$NetBSD: linux_exec_e #ifdef DEBUG_LINUX #define DPRINTF(a) uprintf a #else -#define DPRINTF(a) +#define DPRINTF(a) do {} while (0) #endif #ifdef LINUX_ATEXIT_SIGNATURE @@ -313,7 +313,7 @@ ELFNAME2(linux,go_rt0_signature)(struct if (error) goto out; if (!memcmp(tbuf, signature, sigsz)) { - DPRINTF(("linux_goplcntab_sig=%s\n", tbuf); + DPRINTF(("linux_goplcntab_sig=%s\n", tbuf)); break; } }
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: christos Date: Sun Jul 8 17:58:39 UTC 2018 Modified Files: src/sys/compat/linux/common: linux_exec_elf32.c Log Message: Enable executing linux go binaries by using a special probe function for them. To generate a diff of this commit: cvs rdiff -u -r1.94 -r1.95 src/sys/compat/linux/common/linux_exec_elf32.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_exec_elf32.c diff -u src/sys/compat/linux/common/linux_exec_elf32.c:1.94 src/sys/compat/linux/common/linux_exec_elf32.c:1.95 --- src/sys/compat/linux/common/linux_exec_elf32.c:1.94 Mon Feb 6 18:45:49 2017 +++ src/sys/compat/linux/common/linux_exec_elf32.c Sun Jul 8 13:58:39 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_exec_elf32.c,v 1.94 2017/02/06 23:45:49 uwe Exp $ */ +/* $NetBSD: linux_exec_elf32.c,v 1.95 2018/07/08 17:58:39 christos Exp $ */ /*- * Copyright (c) 1995, 1998, 2000, 2001 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_exec_elf32.c,v 1.94 2017/02/06 23:45:49 uwe Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_exec_elf32.c,v 1.95 2018/07/08 17:58:39 christos Exp $"); #ifndef ELFSIZE /* XXX should die */ @@ -73,6 +73,8 @@ __KERNEL_RCSID(0, "$NetBSD: linux_exec_e #include #include +#define LINUX_GO_RT0_SIGNATURE + #ifdef DEBUG_LINUX #define DPRINTF(a) uprintf a #else @@ -264,6 +266,93 @@ out: } #endif +#ifdef LINUX_GO_RT0_SIGNATURE +/* + * Look for a .gopclntab, specific to go binaries + * in it look for a symbol called _rt0__linux + */ +static int +ELFNAME2(linux,go_rt0_signature)(struct lwp *l, struct exec_package *epp, Elf_Ehdr *eh) +{ + Elf_Shdr *sh; + size_t shsize; + u_int shstrndx; + size_t i; + static const char signature[] = ".gopclntab"; + const size_t sigsz = sizeof(signature); + char tbuf[sizeof(signature)], *tmp = NULL; + char mbuf[64]; + const char *m; + int mlen; + int error; + + /* Load the section header table. */ + shsize = eh->e_shnum * sizeof(Elf_Shdr); + sh = malloc(shsize, M_TEMP, M_WAITOK); + error = exec_read_from(l, epp->ep_vp, eh->e_shoff, sh, shsize); + if (error) + goto out; + + /* Now let's find the string table. If it does not exist, give up. */ + shstrndx = eh->e_shstrndx; + if (shstrndx == SHN_UNDEF || shstrndx >= eh->e_shnum) { + error = ENOEXEC; + goto out; + } + + /* Check if any section has the name we're looking for. */ + const off_t stroff = sh[shstrndx].sh_offset; + for (i = 0; i < eh->e_shnum; i++) { + Elf_Shdr *s = [i]; + + if (s->sh_name + sigsz > sh[shstrndx].sh_size) + continue; + + error = exec_read_from(l, epp->ep_vp, stroff + s->sh_name, tbuf, + sigsz); + if (error) + goto out; + if (!memcmp(tbuf, signature, sigsz)) { + DPRINTF(("linux_goplcntab_sig=%s\n", tbuf); + break; + } + } + + if (i == eh->e_shnum) { + error = ENOEXEC; + goto out; + } + + if (sh[i].sh_size > 1024 * 1014) + sh[i].sh_size = 1014 * 1014; + + tmp = malloc(sh[i].sh_size, M_TEMP, M_WAITOK); + error = exec_read_from(l, epp->ep_vp, sh[i].sh_offset, tmp, + sh[i].sh_size); + if (error) + goto out; + +#if (ELFSIZE == 32) + if (strcmp(machine, "amd64") == 0) + m = "i386"; + else + m = machine; +#else + m = machine; +#endif + mlen = snprintf(mbuf, sizeof(mbuf), "_rt0_%s_linux", m); + if (memmem(tmp, sh[i].sh_size, mbuf, mlen) == NULL) + error = ENOEXEC; + else + DPRINTF(("linux_rt0_sig=%s\n", mbuf)); +out: + if (tmp) + free(tmp, M_TEMP); + free(sh, M_TEMP); + return error; +} +#endif + int ELFNAME2(linux,signature)(struct lwp *l, struct exec_package *epp, Elf_Ehdr *eh, char *itp) { @@ -356,6 +445,9 @@ ELFNAME2(linux,probe)(struct lwp *l, str #ifdef LINUX_DEBUGLINK_SIGNATURE ((error = ELFNAME2(linux,debuglink_signature)(l, epp, eh)) != 0) && #endif +#ifdef LINUX_GO_RT0_SIGNATURE + ((error = ELFNAME2(linux,go_rt0_signature)(l, epp, eh)) != 0) && +#endif 1) { DPRINTF(("linux_probe: returning %d\n", error)); return error;
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: kamil Date: Sun Apr 15 03:25:25 UTC 2018 Modified Files: src/sys/compat/linux/common: linux_sched.c Log Message: Remove unused variable p from linux_sys_clone() After refactoring by in 2010 (r. 1.63) the p variable is no longer used. As noted by its usage is also unsafe and might cause use-after-free scenarios. No functional change intended. Reference: http://mail-index.netbsd.org/tech-kern/2017/09/08/msg022267.html Sponsored by To generate a diff of this commit: cvs rdiff -u -r1.69 -r1.70 src/sys/compat/linux/common/linux_sched.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_sched.c diff -u src/sys/compat/linux/common/linux_sched.c:1.69 src/sys/compat/linux/common/linux_sched.c:1.70 --- src/sys/compat/linux/common/linux_sched.c:1.69 Fri Apr 21 15:10:34 2017 +++ src/sys/compat/linux/common/linux_sched.c Sun Apr 15 03:25:25 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_sched.c,v 1.69 2017/04/21 15:10:34 christos Exp $ */ +/* $NetBSD: linux_sched.c,v 1.70 2018/04/15 03:25:25 kamil Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_sched.c,v 1.69 2017/04/21 15:10:34 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_sched.c,v 1.70 2018/04/15 03:25:25 kamil Exp $"); #include #include @@ -103,7 +103,6 @@ linux_sys_clone(struct lwp *l, const str syscallarg(void *) tls; syscallarg(void *) child_tidptr; } */ - struct proc *p; struct linux_emuldata *led; int flags, sig, error; @@ -159,7 +158,7 @@ linux_sys_clone(struct lwp *l, const str * that makes this adjustment is a noop. */ if ((error = fork1(l, flags, sig, SCARG(uap, stack), 0, - linux_child_return, NULL, retval, )) != 0) { + linux_child_return, NULL, retval, NULL)) != 0) { DPRINTF(("%s: fork1: error %d\n", __func__, error)); return error; }
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: christos Date: Sun Jan 7 21:14:38 UTC 2018 Modified Files: src/sys/compat/linux/common: linux_sigaction.c linux_signal.c Log Message: Ignore signal 64 for now (go uses it) XXX: pullup-8 To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/sys/compat/linux/common/linux_sigaction.c cvs rdiff -u -r1.79 -r1.80 src/sys/compat/linux/common/linux_signal.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_sigaction.c diff -u src/sys/compat/linux/common/linux_sigaction.c:1.34 src/sys/compat/linux/common/linux_sigaction.c:1.35 --- src/sys/compat/linux/common/linux_sigaction.c:1.34 Fri Oct 17 16:21:34 2008 +++ src/sys/compat/linux/common/linux_sigaction.c Sun Jan 7 16:14:38 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_sigaction.c,v 1.34 2008/10/17 20:21:34 njoly Exp $ */ +/* $NetBSD: linux_sigaction.c,v 1.35 2018/01/07 21:14:38 christos Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_sigaction.c,v 1.34 2008/10/17 20:21:34 njoly Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_sigaction.c,v 1.35 2018/01/07 21:14:38 christos Exp $"); #include #include @@ -84,6 +84,15 @@ linux_sys_sigaction(struct lwp *l, const linux_old_to_native_sigaction(, ); } sig = SCARG(uap, signum); + /* + * XXX: Linux has 33 realtime signals, the go binary wants to + * reset all of them; nothing else uses the last RT signal, so for + * now ignore it. + */ + if (sig == LINUX__NSIG) { + uprintf("%s: setting signal %d ignored\n", __func__, sig); + sig--; /* back to 63 which is ignored */ + } if (sig < 0 || sig >= LINUX__NSIG) return (EINVAL); if (sig > 0 && !linux_to_native_signo[sig]) { Index: src/sys/compat/linux/common/linux_signal.c diff -u src/sys/compat/linux/common/linux_signal.c:1.79 src/sys/compat/linux/common/linux_signal.c:1.80 --- src/sys/compat/linux/common/linux_signal.c:1.79 Mon Feb 20 11:30:41 2017 +++ src/sys/compat/linux/common/linux_signal.c Sun Jan 7 16:14:38 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_signal.c,v 1.79 2017/02/20 16:30:41 rin Exp $ */ +/* $NetBSD: linux_signal.c,v 1.80 2018/01/07 21:14:38 christos Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_signal.c,v 1.79 2017/02/20 16:30:41 rin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_signal.c,v 1.80 2018/01/07 21:14:38 christos Exp $"); #define COMPAT_LINUX 1 @@ -346,6 +346,15 @@ linux_sys_rt_sigaction(struct lwp *l, co } sig = SCARG(uap, signum); + /* + * XXX: Linux has 33 realtime signals, the go binary wants to + * reset all of them; nothing else uses the last RT signal, so for + * now ignore it. + */ + if (sig == LINUX__NSIG) { + uprintf("%s: setting signal %d ignored\n", __func__, sig); + sig--; /* back to 63 which is ignored */ + } if (sig < 0 || sig >= LINUX__NSIG) return EINVAL; if (sig > 0 && !linux_to_native_signo[sig]) {
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: maxv Date: Tue Nov 21 10:45:12 UTC 2017 Modified Files: src/sys/compat/linux/common: linux_sg.c Log Message: This should be "linux_sg_version", not "version". To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/compat/linux/common/linux_sg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_sg.c diff -u src/sys/compat/linux/common/linux_sg.c:1.13 src/sys/compat/linux/common/linux_sg.c:1.14 --- src/sys/compat/linux/common/linux_sg.c:1.13 Fri Mar 21 21:54:58 2008 +++ src/sys/compat/linux/common/linux_sg.c Tue Nov 21 10:45:12 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_sg.c,v 1.13 2008/03/21 21:54:58 ad Exp $ */ +/* $NetBSD: linux_sg.c,v 1.14 2017/11/21 10:45:12 maxv Exp $ */ /* * Copyright (c) 2004 Soren S. Jorvang. All rights reserved. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_sg.c,v 1.13 2008/03/21 21:54:58 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_sg.c,v 1.14 2017/11/21 10:45:12 maxv Exp $"); #include #include @@ -88,7 +88,7 @@ linux_ioctl_sg(struct lwp *l, const stru DPRINTF(("Command = %lx\n", com)); switch (com) { case LINUX_SG_GET_VERSION_NUM: { - error = copyout(, SCARG(uap, data), + error = copyout(_sg_version, SCARG(uap, data), sizeof(linux_sg_version)); break; }
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: riastradh Date: Sat Jul 29 02:31:22 UTC 2017 Modified Files: src/sys/compat/linux/common: linux_time.c Log Message: Put suser check in the right function: settimeofday, not gettimeofday. While here, remove wrong comment. Noted by kre@. To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/sys/compat/linux/common/linux_time.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_time.c diff -u src/sys/compat/linux/common/linux_time.c:1.38 src/sys/compat/linux/common/linux_time.c:1.39 --- src/sys/compat/linux/common/linux_time.c:1.38 Sat Jul 29 01:14:59 2017 +++ src/sys/compat/linux/common/linux_time.c Sat Jul 29 02:31:22 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_time.c,v 1.38 2017/07/29 01:14:59 riastradh Exp $ */ +/* $NetBSD: linux_time.c,v 1.39 2017/07/29 02:31:22 riastradh Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_time.c,v 1.38 2017/07/29 01:14:59 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_time.c,v 1.39 2017/07/29 02:31:22 riastradh Exp $"); #include #include @@ -79,9 +79,6 @@ linux_sys_gettimeofday(struct lwp *l, co } if (SCARG(uap, tzp)) { - if (kauth_authorize_generic(kauth_cred_get(), - KAUTH_GENERIC_ISSUSER, NULL) != 0) - return (EPERM); error = copyout(_sys_tz, SCARG(uap, tzp), sizeof(linux_sys_tz)); if (error) return (error); @@ -105,11 +102,10 @@ linux_sys_settimeofday(struct lwp *l, co return (error); } - /* - * If user is not the superuser, we returned - * after the sys_settimeofday() call. - */ if (SCARG(uap, tzp)) { + if (kauth_authorize_generic(kauth_cred_get(), + KAUTH_GENERIC_ISSUSER, NULL) != 0) + return (EPERM); error = copyin(SCARG(uap, tzp), _sys_tz, sizeof(linux_sys_tz)); if (error) return (error);
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: riastradh Date: Sat Jul 29 01:14:59 UTC 2017 Modified Files: src/sys/compat/linux/common: linux_time.c Log Message: Only let the superuser set the compat_linux timezone. Not really keen to invent a new kauth cookie for this useless purpose. >From Ilja Van Sprundel. To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 src/sys/compat/linux/common/linux_time.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_time.c diff -u src/sys/compat/linux/common/linux_time.c:1.37 src/sys/compat/linux/common/linux_time.c:1.38 --- src/sys/compat/linux/common/linux_time.c:1.37 Mon Jan 13 10:33:03 2014 +++ src/sys/compat/linux/common/linux_time.c Sat Jul 29 01:14:59 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_time.c,v 1.37 2014/01/13 10:33:03 njoly Exp $ */ +/* $NetBSD: linux_time.c,v 1.38 2017/07/29 01:14:59 riastradh Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_time.c,v 1.37 2014/01/13 10:33:03 njoly Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_time.c,v 1.38 2017/07/29 01:14:59 riastradh Exp $"); #include #include @@ -79,6 +79,9 @@ linux_sys_gettimeofday(struct lwp *l, co } if (SCARG(uap, tzp)) { + if (kauth_authorize_generic(kauth_cred_get(), + KAUTH_GENERIC_ISSUSER, NULL) != 0) + return (EPERM); error = copyout(_sys_tz, SCARG(uap, tzp), sizeof(linux_sys_tz)); if (error) return (error);
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: dholland Date: Sun Apr 9 00:02:30 UTC 2017 Modified Files: src/sys/compat/linux/common: linux_futex.c Log Message: speed limit 80 To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/sys/compat/linux/common/linux_futex.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_futex.c diff -u src/sys/compat/linux/common/linux_futex.c:1.35 src/sys/compat/linux/common/linux_futex.c:1.36 --- src/sys/compat/linux/common/linux_futex.c:1.35 Mon Aug 15 09:20:11 2016 +++ src/sys/compat/linux/common/linux_futex.c Sun Apr 9 00:02:30 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_futex.c,v 1.35 2016/08/15 09:20:11 maxv Exp $ */ +/* $NetBSD: linux_futex.c,v 1.36 2017/04/09 00:02:30 dholland Exp $ */ /*- * Copyright (c) 2005 Emmanuel Dreyfus, all rights reserved. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(1, "$NetBSD: linux_futex.c,v 1.35 2016/08/15 09:20:11 maxv Exp $"); +__KERNEL_RCSID(1, "$NetBSD: linux_futex.c,v 1.36 2017/04/09 00:02:30 dholland Exp $"); #include #include @@ -112,7 +112,8 @@ static int futex_wake(struct futex *, in static int futex_atomic_op(lwp_t *, int, void *); int -linux_sys_futex(struct lwp *l, const struct linux_sys_futex_args *uap, register_t *retval) +linux_sys_futex(struct lwp *l, const struct linux_sys_futex_args *uap, + register_t *retval) { /* { syscallarg(int *) uaddr; @@ -138,7 +139,8 @@ linux_sys_futex(struct lwp *l, const str } int -linux_do_futex(struct lwp *l, const struct linux_sys_futex_args *uap, register_t *retval, struct timespec *ts) +linux_do_futex(struct lwp *l, const struct linux_sys_futex_args *uap, + register_t *retval, struct timespec *ts) { /* { syscallarg(int *) uaddr; @@ -196,12 +198,13 @@ linux_do_futex(struct lwp *l, const stru if (error != ETIMEDOUT) return error; /* - * If the user process requests a non null timeout, - * make sure we do not turn it into an infinite - * timeout because tout is 0. + * If the user process requests a non null + * timeout, make sure we do not turn it into + * an infinite timeout because tout is 0. * - * We use a minimal timeout of 1/hz. Maybe it would make - * sense to just return ETIMEDOUT without sleeping. + * We use a minimal timeout of 1/hz. Maybe it + * would make sense to just return ETIMEDOUT + * without sleeping. */ if (SCARG(uap, timeout) != NULL) tout = 1;
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: rin Date: Mon Feb 20 16:30:41 UTC 2017 Modified Files: src/sys/compat/linux/common: linux_signal.c Log Message: KNF; no binary changes To generate a diff of this commit: cvs rdiff -u -r1.78 -r1.79 src/sys/compat/linux/common/linux_signal.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_signal.c diff -u src/sys/compat/linux/common/linux_signal.c:1.78 src/sys/compat/linux/common/linux_signal.c:1.79 --- src/sys/compat/linux/common/linux_signal.c:1.78 Mon Feb 20 16:26:30 2017 +++ src/sys/compat/linux/common/linux_signal.c Mon Feb 20 16:30:41 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_signal.c,v 1.78 2017/02/20 16:26:30 rin Exp $ */ +/* $NetBSD: linux_signal.c,v 1.79 2017/02/20 16:30:41 rin Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_signal.c,v 1.78 2017/02/20 16:26:30 rin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_signal.c,v 1.79 2017/02/20 16:30:41 rin Exp $"); #define COMPAT_LINUX 1 @@ -336,18 +336,18 @@ linux_sys_rt_sigaction(struct lwp *l, co #endif if (SCARG(uap, sigsetsize) != sizeof(linux_sigset_t)) - return (EINVAL); + return EINVAL; if (SCARG(uap, nsa)) { error = copyin(SCARG(uap, nsa), , sizeof(nlsa)); if (error) - return (error); + return error; linux_to_native_sigaction(, ); } sig = SCARG(uap, signum); if (sig < 0 || sig >= LINUX__NSIG) - return (EINVAL); + return EINVAL; if (sig > 0 && !linux_to_native_signo[sig]) { /* Pretend that we did something useful for unknown signals. */ obsa.sa_handler = SIG_IGN; @@ -358,7 +358,7 @@ linux_sys_rt_sigaction(struct lwp *l, co if (SCARG(uap, nsa) && (nlsa.linux_sa_flags & LINUX_SA_RESTORER) && (tramp = nlsa.linux_sa_restorer) != NULL) -vers = 2; + vers = 2; #endif error = sigaction1(l, linux_to_native_signo[sig], @@ -366,7 +366,7 @@ linux_sys_rt_sigaction(struct lwp *l, co SCARG(uap, osa) ? : NULL, tramp, vers); if (error) - return (error); + return error; } if (SCARG(uap, osa)) { native_to_linux_sigaction(, ); @@ -380,9 +380,9 @@ linux_sys_rt_sigaction(struct lwp *l, co error = copyout(, SCARG(uap, osa), sizeof(olsa)); if (error) - return (error); + return error; } - return (0); + return 0; } int @@ -404,13 +404,13 @@ linux_sigprocmask1(struct lwp *l, int ho how = SIG_SETMASK; break; default: - return (EINVAL); + return EINVAL; } if (set) { error = copyin(set, , sizeof(nlss)); if (error) - return (error); + return error; linux_old_to_native_sigset(, ); } mutex_enter(p->p_lock); @@ -418,14 +418,14 @@ linux_sigprocmask1(struct lwp *l, int ho set ? : NULL, oset ? : NULL); mutex_exit(p->p_lock); if (error) - return (error); + return error; if (oset) { native_to_linux_old_sigset(, ); error = copyout(, oset, sizeof(olss)); if (error) - return (error); + return error; } - return (error); + return error; } int @@ -444,7 +444,7 @@ linux_sys_rt_sigprocmask(struct lwp *l, int error, how; if (SCARG(uap, sigsetsize) != sizeof(linux_sigset_t)) - return (EINVAL); + return EINVAL; switch (SCARG(uap, how)) { case LINUX_SIG_BLOCK: @@ -457,7 +457,7 @@ linux_sys_rt_sigprocmask(struct lwp *l, how = SIG_SETMASK; break; default: - return (EINVAL); + return EINVAL; } set = SCARG(uap, set); @@ -466,7 +466,7 @@ linux_sys_rt_sigprocmask(struct lwp *l, if (set) { error = copyin(set, , sizeof(nlss)); if (error) - return (error); + return error; linux_to_native_sigset(, ); } mutex_enter(p->p_lock); @@ -477,7 +477,7 @@ linux_sys_rt_sigprocmask(struct lwp *l, native_to_linux_sigset(, ); error = copyout(, oset, sizeof(olss)); } - return (error); + return error; } int @@ -491,7 +491,7 @@ linux_sys_rt_sigpending(struct lwp *l, c linux_sigset_t lss; if (SCARG(uap, sigsetsize) != sizeof(linux_sigset_t)) - return (EINVAL); + return EINVAL; sigpending1(l, ); native_to_linux_sigset(, ); @@ -526,7 +526,7 @@ linux_sys_sigsuspend(struct lwp *l, cons lss = SCARG(uap, mask); linux_old_to_native_sigset(, ); - return (sigsuspend1(l, )); + return sigsuspend1(l, ); } #endif /* __amd64__ */ @@ -542,15 +542,15 @@ linux_sys_rt_sigsuspend(struct lwp *l, c int error; if (SCARG(uap, sigsetsize) != sizeof(linux_sigset_t)) - return (EINVAL); + return EINVAL; error = copyin(SCARG(uap, unewset), , sizeof(linux_sigset_t)); if (error) - return (error); + return error; linux_to_native_sigset(, ); - return (sigsuspend1(l, )); + return sigsuspend1(l, ); } static int @@ -632,7 +632,7 @@ linux_sys_rt_queueinfo(struct lwp *l, co /* XXX To really implement this we need to */ /* XXX keep a list of queued signals somewhere. */ - return
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: rin Date: Mon Feb 20 16:26:30 UTC 2017 Modified Files: src/sys/compat/linux/common: linux_signal.c Log Message: CID 980928: fix NULL pointer dereferece To generate a diff of this commit: cvs rdiff -u -r1.77 -r1.78 src/sys/compat/linux/common/linux_signal.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_signal.c diff -u src/sys/compat/linux/common/linux_signal.c:1.77 src/sys/compat/linux/common/linux_signal.c:1.78 --- src/sys/compat/linux/common/linux_signal.c:1.77 Sat Nov 14 13:29:35 2015 +++ src/sys/compat/linux/common/linux_signal.c Mon Feb 20 16:26:30 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_signal.c,v 1.77 2015/11/14 13:29:35 christos Exp $ */ +/* $NetBSD: linux_signal.c,v 1.78 2017/02/20 16:26:30 rin Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_signal.c,v 1.77 2015/11/14 13:29:35 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_signal.c,v 1.78 2017/02/20 16:26:30 rin Exp $"); #define COMPAT_LINUX 1 @@ -355,7 +355,8 @@ linux_sys_rt_sigaction(struct lwp *l, co obsa.sa_flags = 0; } else { #ifdef LINUX_SA_RESTORER - if ((nlsa.linux_sa_flags & LINUX_SA_RESTORER) && + if (SCARG(uap, nsa) && + (nlsa.linux_sa_flags & LINUX_SA_RESTORER) && (tramp = nlsa.linux_sa_restorer) != NULL) vers = 2; #endif
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: christos Date: Thu Feb 9 22:01:48 UTC 2017 Modified Files: src/sys/compat/linux/common: linux_socketcall.c linux_socketcall.h Log Message: use proper arg functions, remove bogus ones. To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/sys/compat/linux/common/linux_socketcall.c cvs rdiff -u -r1.20 -r1.21 src/sys/compat/linux/common/linux_socketcall.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_socketcall.c diff -u src/sys/compat/linux/common/linux_socketcall.c:1.47 src/sys/compat/linux/common/linux_socketcall.c:1.48 --- src/sys/compat/linux/common/linux_socketcall.c:1.47 Fri Feb 3 11:57:39 2017 +++ src/sys/compat/linux/common/linux_socketcall.c Thu Feb 9 17:01:48 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_socketcall.c,v 1.47 2017/02/03 16:57:39 christos Exp $ */ +/* $NetBSD: linux_socketcall.c,v 1.48 2017/02/09 22:01:48 christos Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_socketcall.c,v 1.47 2017/02/03 16:57:39 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_socketcall.c,v 1.48 2017/02/09 22:01:48 christos Exp $"); #include #include @@ -93,7 +93,7 @@ static const struct { {L("socket"), sizeof(struct linux_sys_socket_args)}, /* 1 */ {L("bind"), sizeof(struct linux_sys_bind_args)}, /* 2 */ {L("connect"), sizeof(struct linux_sys_connect_args)}, /* 3 */ - {L("listen"), sizeof(struct linux_sys_listen_args)}, /* 4 */ + {L("listen"), sizeof(struct sys_listen_args)}, /* 4 */ {L("accept"), sizeof(struct linux_sys_accept_args)}, /* 5 */ {L("getsockname"),sizeof(struct linux_sys_getsockname_args)}, /* 6 */ {L("getpeername"),sizeof(struct linux_sys_getpeername_args)}, /* 7 */ @@ -102,7 +102,7 @@ static const struct { {L("recv"), sizeof(struct linux_sys_recv_args)}, /* 10 */ {L("sendto"), sizeof(struct linux_sys_sendto_args)}, /* 11 */ {L("recvfrom"), sizeof(struct linux_sys_recvfrom_args)}, /* 12 */ - {L("shutdown"), sizeof(struct linux_sys_shutdown_args)}, /* 13 */ + {L("shutdown"), sizeof(struct sys_shutdown_args)}, /* 13 */ {L("setsockopt"),sizeof(struct linux_sys_setsockopt_args)}, /* 14 */ {L("getsockopt"),sizeof(struct linux_sys_getsockopt_args)}, /* 15 */ {L("sendmsg"), sizeof(struct linux_sys_sendmsg_args)}, /* 16 */ Index: src/sys/compat/linux/common/linux_socketcall.h diff -u src/sys/compat/linux/common/linux_socketcall.h:1.20 src/sys/compat/linux/common/linux_socketcall.h:1.21 --- src/sys/compat/linux/common/linux_socketcall.h:1.20 Fri Feb 3 17:29:51 2017 +++ src/sys/compat/linux/common/linux_socketcall.h Thu Feb 9 17:01:48 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_socketcall.h,v 1.20 2017/02/03 22:29:51 christos Exp $ */ +/* $NetBSD: linux_socketcall.h,v 1.21 2017/02/09 22:01:48 christos Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -244,22 +244,6 @@ struct linux_sys_recv_args { }; #endif -/* These are only used for their size: */ - -#ifndef LINUX_SYS_listen -struct linux_sys_listen_args { - syscallarg(int) s; - syscallarg(int) backlog; -}; -#endif - -#ifndef LINUX_SYS_shutdown -struct linux_sys_shutdown_args { - syscallarg(int) s; - syscallarg(int) how; -}; -#endif - #ifndef LINUX_SYS_accept4 struct linux_sys_accept4_args { syscallarg(int) s;
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: uwe Date: Mon Feb 6 23:45:49 UTC 2017 Modified Files: src/sys/compat/linux/common: linux_exec_elf32.c Log Message: Use ELFOSABI_LINUX instead of a magic number. To generate a diff of this commit: cvs rdiff -u -r1.93 -r1.94 src/sys/compat/linux/common/linux_exec_elf32.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_exec_elf32.c diff -u src/sys/compat/linux/common/linux_exec_elf32.c:1.93 src/sys/compat/linux/common/linux_exec_elf32.c:1.94 --- src/sys/compat/linux/common/linux_exec_elf32.c:1.93 Thu Jun 11 02:54:00 2015 +++ src/sys/compat/linux/common/linux_exec_elf32.c Mon Feb 6 23:45:49 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_exec_elf32.c,v 1.93 2015/06/11 02:54:00 matt Exp $ */ +/* $NetBSD: linux_exec_elf32.c,v 1.94 2017/02/06 23:45:49 uwe Exp $ */ /*- * Copyright (c) 1995, 1998, 2000, 2001 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_exec_elf32.c,v 1.93 2015/06/11 02:54:00 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_exec_elf32.c,v 1.94 2017/02/06 23:45:49 uwe Exp $"); #ifndef ELFSIZE /* XXX should die */ @@ -273,7 +273,7 @@ ELFNAME2(linux,signature)(struct lwp *l, int error; static const char linux[] = "Linux"; - if (eh->e_ident[EI_OSABI] == 3 || + if (eh->e_ident[EI_OSABI] == ELFOSABI_LINUX || memcmp(>e_ident[EI_ABIVERSION], linux, sizeof(linux)) == 0) return 0;
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: christos Date: Fri Feb 3 22:29:51 UTC 2017 Modified Files: src/sys/compat/linux/common: linux_socketcall.h Log Message: New versions of linux on arm and others have both socketcall and separate syscalls... To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/compat/linux/common/linux_socketcall.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_socketcall.h diff -u src/sys/compat/linux/common/linux_socketcall.h:1.19 src/sys/compat/linux/common/linux_socketcall.h:1.20 --- src/sys/compat/linux/common/linux_socketcall.h:1.19 Fri Feb 3 11:57:39 2017 +++ src/sys/compat/linux/common/linux_socketcall.h Fri Feb 3 17:29:51 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_socketcall.h,v 1.19 2017/02/03 16:57:39 christos Exp $ */ +/* $NetBSD: linux_socketcall.h,v 1.20 2017/02/03 22:29:51 christos Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -68,6 +68,8 @@ /* Used on: arm, i386, m68k, mips, ppc, sparc, sparc64 */ /* Used for COMPAT_LINUX32 on amd64 */ /* Not used on: alpha */ +#include +#include /* * Values passed to the Linux socketcall() syscall, determining the actual @@ -109,19 +111,24 @@ struct linux_socketcall_dummy_args { void *dummy_ptrs[3]; /* Max 3 pointers */ }; +#ifndef LINUX_SYS_socket struct linux_sys_socket_args { syscallarg(int) domain; syscallarg(int) type; syscallarg(int) protocol; }; +#endif +#ifndef LINUX_SYS_socketpair struct linux_sys_socketpair_args { syscallarg(int) domain; syscallarg(int) type; syscallarg(int) protocol; syscallarg(int *) rsv; }; +#endif +#ifndef LINUX_SYS_sendto struct linux_sys_sendto_args { syscallarg(int) s; syscallarg(void *) msg; @@ -130,7 +137,9 @@ struct linux_sys_sendto_args { syscallarg(struct osockaddr *) to; syscallarg(int) tolen; }; +#endif +#ifndef LINUX_SYS_recvfrom struct linux_sys_recvfrom_args { syscallarg(int) s; syscallarg(void *) buf; @@ -139,7 +148,9 @@ struct linux_sys_recvfrom_args { syscallarg(struct osockaddr *) from; syscallarg(int *) fromlenaddr; }; +#endif +#ifndef LINUX_SYS_setsockopt struct linux_sys_setsockopt_args { syscallarg(int) s; syscallarg(int) level; @@ -147,7 +158,9 @@ struct linux_sys_setsockopt_args { syscallarg(void *) optval; syscallarg(int) optlen; }; +#endif +#ifndef LINUX_SYS_getsockopt struct linux_sys_getsockopt_args { syscallarg(int) s; syscallarg(int) level; @@ -155,82 +168,108 @@ struct linux_sys_getsockopt_args { syscallarg(void *) optval; syscallarg(int *) optlen; }; +#endif +#ifndef LINUX_SYS_bind struct linux_sys_bind_args { syscallarg(int) s; syscallarg(struct osockaddr *) name; syscallarg(int) namelen; }; +#endif +#ifndef LINUX_SYS_connect struct linux_sys_connect_args { syscallarg(int) s; syscallarg(struct osockaddr *) name; syscallarg(int) namelen; }; +#endif +#ifndef LINUX_SYS_accept struct linux_sys_accept_args { syscallarg(int) s; syscallarg(struct osockaddr *) name; syscallarg(int *) anamelen; }; +#endif +#ifndef LINUX_SYS_getsockname struct linux_sys_getsockname_args { syscallarg(int) fdes; syscallarg(struct osockaddr *) asa; syscallarg(int *) alen; }; +#endif +#ifndef LINUX_SYS_getpeername struct linux_sys_getpeername_args { syscallarg(int) fdes; syscallarg(struct osockaddr *) asa; syscallarg(int *) alen; }; +#endif +#ifndef LINUX_SYS_sendmsg struct linux_sys_sendmsg_args { syscallarg(int) s; syscallarg(struct linux_msghdr *) msg; syscallarg(u_int) flags; }; +#endif +#ifndef LINUX_SYS_recvmsg struct linux_sys_recvmsg_args { syscallarg(int) s; syscallarg(struct linux_msghdr *) msg; syscallarg(u_int) flags; }; +#endif +#ifndef LINUX_SYS_send struct linux_sys_send_args { syscallarg(int) s; syscallarg(void *) buf; syscallarg(int) len; syscallarg(int) flags; }; +#endif +#ifndef LINUX_SYS_recv struct linux_sys_recv_args { syscallarg(int) s; syscallarg(void *) buf; syscallarg(int) len; syscallarg(int) flags; }; +#endif /* These are only used for their size: */ +#ifndef LINUX_SYS_listen struct linux_sys_listen_args { syscallarg(int) s; syscallarg(int) backlog; }; +#endif +#ifndef LINUX_SYS_shutdown struct linux_sys_shutdown_args { syscallarg(int) s; syscallarg(int) how; }; +#endif +#ifndef LINUX_SYS_accept4 struct linux_sys_accept4_args { syscallarg(int) s; syscallarg(struct osockaddr *) name; syscallarg(int *) anamelen; syscallarg(int) flags; }; +#endif +#ifndef LINUX_SYS_recvmmsg struct linux_sys_recvmmsg_args { syscallarg(int) s; syscallarg(struct linux_mmsghdr *) msgvec; @@ -238,13 +277,16 @@ struct linux_sys_recvmmsg_args { syscallarg(unsigned int) flags; syscallarg(struct linux_timespec *) timeout; }; +#endif +#ifndef LINUX_SYS_sendmmsg struct linux_sys_sendmmsg_args {
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: christos Date: Fri Feb 3 16:57:39 UTC 2017 Modified Files: src/sys/compat/linux/common: linux_socket.c linux_socket.h linux_socketcall.c linux_socketcall.h Log Message: add sendmmsg and recvmmsg To generate a diff of this commit: cvs rdiff -u -r1.136 -r1.137 src/sys/compat/linux/common/linux_socket.c cvs rdiff -u -r1.22 -r1.23 src/sys/compat/linux/common/linux_socket.h cvs rdiff -u -r1.46 -r1.47 src/sys/compat/linux/common/linux_socketcall.c cvs rdiff -u -r1.18 -r1.19 src/sys/compat/linux/common/linux_socketcall.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_socket.c diff -u src/sys/compat/linux/common/linux_socket.c:1.136 src/sys/compat/linux/common/linux_socket.c:1.137 --- src/sys/compat/linux/common/linux_socket.c:1.136 Fri Feb 3 08:08:08 2017 +++ src/sys/compat/linux/common/linux_socket.c Fri Feb 3 11:57:39 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_socket.c,v 1.136 2017/02/03 13:08:08 christos Exp $ */ +/* $NetBSD: linux_socket.c,v 1.137 2017/02/03 16:57:39 christos Exp $ */ /*- * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.136 2017/02/03 13:08:08 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.137 2017/02/03 16:57:39 christos Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -82,6 +82,7 @@ __KERNEL_RCSID(0, "$NetBSD: linux_socket #include #include #include +#include #include #include #if !defined(__alpha__) && !defined(__amd64__) @@ -124,8 +125,8 @@ static int linux_get_sa(struct lwp *, in static int linux_sa_put(struct osockaddr *osa); static int linux_to_bsd_msg_flags(int); static int bsd_to_linux_msg_flags(int); -static void linux_to_bsd_msghdr(struct linux_msghdr *, struct msghdr *); -static void bsd_to_linux_msghdr(struct msghdr *, struct linux_msghdr *); +static void linux_to_bsd_msghdr(const struct linux_msghdr *, struct msghdr *); +static void bsd_to_linux_msghdr(const struct msghdr *, struct linux_msghdr *); static const int linux_to_bsd_domain_[LINUX_AF_MAX] = { AF_UNSPEC, @@ -433,7 +434,7 @@ linux_sys_sendto(struct lwp *l, const st } static void -linux_to_bsd_msghdr(struct linux_msghdr *lmsg, struct msghdr *bmsg) +linux_to_bsd_msghdr(const struct linux_msghdr *lmsg, struct msghdr *bmsg) { bmsg->msg_name = lmsg->msg_name; bmsg->msg_namelen = lmsg->msg_namelen; @@ -445,7 +446,7 @@ linux_to_bsd_msghdr(struct linux_msghdr } static void -bsd_to_linux_msghdr(struct msghdr *bmsg, struct linux_msghdr *lmsg) +bsd_to_linux_msghdr(const struct msghdr *bmsg, struct linux_msghdr *lmsg) { lmsg->msg_name = bmsg->msg_name; lmsg->msg_namelen = bmsg->msg_namelen; @@ -1742,3 +1743,190 @@ linux_sys_accept4(struct lwp *l, const s return 0; } + +int +linux_sys_sendmmsg(struct lwp *l, const struct linux_sys_sendmmsg_args *uap, +register_t *retval) +{ + /* { + syscallarg(int) s; + syscallarg(struct linux_mmsghdr *) msgvec; + syscallarg(unsigned int) vlen; + syscallarg(unsigned int) flags; + } */ + struct linux_mmsghdr lmsg; + struct mmsghdr bmsg; + struct socket *so; + file_t *fp; + struct msghdr *msg = _hdr; + int error, s; + unsigned int vlen, flags, dg; + + if ((flags = linux_to_bsd_msg_flags(SCARG(uap, flags))) == -1) + return EINVAL; + + flags = (flags & MSG_USERFLAGS) | MSG_IOVUSRSPACE; + + s = SCARG(uap, s); + if ((error = fd_getsock1(s, , )) != 0) + return error; + + vlen = SCARG(uap, vlen); + if (vlen > 1024) + vlen = 1024; + + for (dg = 0; dg < vlen;) { + error = copyin(SCARG(uap, msgvec) + dg, , sizeof(lmsg)); + if (error) + break; + linux_to_bsd_msghdr(_hdr, _hdr); + + msg->msg_flags = flags; + + error = do_sys_sendmsg_so(l, s, so, fp, msg, flags, + , sizeof(msg), retval); + if (error) + break; + + ktrkuser("msghdr", msg, sizeof *msg); + lmsg.msg_len = *retval; + error = copyout(, SCARG(uap, msgvec) + dg, sizeof(lmsg)); + if (error) + break; + dg++; + + } + + *retval = dg; + if (error) + so->so_error = error; + + fd_putfile(s); + + /* + * If we succeeded at least once, return 0, hopefully so->so_error + * will catch it next time. + */ + if (dg) + return 0; + return error; +} + +int +linux_sys_recvmmsg(struct lwp *l, const struct linux_sys_recvmmsg_args *uap, +register_t *retval) +{ + /* { + syscallarg(int) s; + syscallarg(struct linux_mmsghdr *) msgvec; + syscallarg(unsigned int) vlen; + syscallarg(unsigned int) flags; + syscallarg(struct linux_timespec *) timeout; + } */ + struct linux_mmsghdr lmsg; + struct mmsghdr bmsg; + struct socket *so; + struct msghdr *msg = _hdr; + int error, s; + struct mbuf *from, *control; + struct timespec ts, now; + struct linux_timespec lts; + unsigned int vlen, flags, dg; + + if (SCARG(uap, timeout)) { + error = copyin(SCARG(uap, timeout), ,
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: christos Date: Fri Feb 3 13:08:08 UTC 2017 Modified Files: src/sys/compat/linux/common: linux_socket.c linux_socketcall.c linux_socketcall.h Log Message: handle accept4 for i386 To generate a diff of this commit: cvs rdiff -u -r1.135 -r1.136 src/sys/compat/linux/common/linux_socket.c cvs rdiff -u -r1.45 -r1.46 src/sys/compat/linux/common/linux_socketcall.c cvs rdiff -u -r1.17 -r1.18 src/sys/compat/linux/common/linux_socketcall.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_socket.c diff -u src/sys/compat/linux/common/linux_socket.c:1.135 src/sys/compat/linux/common/linux_socket.c:1.136 --- src/sys/compat/linux/common/linux_socket.c:1.135 Fri Feb 3 03:43:02 2017 +++ src/sys/compat/linux/common/linux_socket.c Fri Feb 3 08:08:08 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_socket.c,v 1.135 2017/02/03 08:43:02 martin Exp $ */ +/* $NetBSD: linux_socket.c,v 1.136 2017/02/03 13:08:08 christos Exp $ */ /*- * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.135 2017/02/03 08:43:02 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.136 2017/02/03 13:08:08 christos Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -1708,7 +1708,6 @@ linux_sys_accept(struct lwp *l, const st return (0); } -#ifndef __i386__ /* Linux/i386 does not have this syscall */ int linux_sys_accept4(struct lwp *l, const struct linux_sys_accept4_args *uap, register_t *retval) { @@ -1743,5 +1742,3 @@ linux_sys_accept4(struct lwp *l, const s return 0; } -#endif - Index: src/sys/compat/linux/common/linux_socketcall.c diff -u src/sys/compat/linux/common/linux_socketcall.c:1.45 src/sys/compat/linux/common/linux_socketcall.c:1.46 --- src/sys/compat/linux/common/linux_socketcall.c:1.45 Sun Nov 9 12:48:08 2014 +++ src/sys/compat/linux/common/linux_socketcall.c Fri Feb 3 08:08:08 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_socketcall.c,v 1.45 2014/11/09 17:48:08 maxv Exp $ */ +/* $NetBSD: linux_socketcall.c,v 1.46 2017/02/03 13:08:08 christos Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_socketcall.c,v 1.45 2014/11/09 17:48:08 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_socketcall.c,v 1.46 2017/02/03 13:08:08 christos Exp $"); #include #include @@ -107,6 +107,7 @@ static const struct { {L("getsockopt"),sizeof(struct linux_sys_getsockopt_args)}, /* 15 */ {L("sendmsg"), sizeof(struct linux_sys_sendmsg_args)}, /* 16 */ {L("recvmsg"), sizeof(struct linux_sys_recvmsg_args)}, /* 17 */ + {L("accept4"), sizeof(struct linux_sys_accept4_args)}, /* 18 */ #undef L }; @@ -215,6 +216,9 @@ linux_sys_socketcall(struct lwp *l, cons case LINUX_SYS_RECVMSG: error = linux_sys_recvmsg(l, (void *), retval); break; + case LINUX_SYS_ACCEPT4: + error = linux_sys_accept4(l, (void *), retval); + break; default: error = ENOSYS; break; Index: src/sys/compat/linux/common/linux_socketcall.h diff -u src/sys/compat/linux/common/linux_socketcall.h:1.17 src/sys/compat/linux/common/linux_socketcall.h:1.18 --- src/sys/compat/linux/common/linux_socketcall.h:1.17 Fri Dec 27 10:10:53 2013 +++ src/sys/compat/linux/common/linux_socketcall.h Fri Feb 3 08:08:08 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_socketcall.h,v 1.17 2013/12/27 15:10:53 njoly Exp $ */ +/* $NetBSD: linux_socketcall.h,v 1.18 2017/02/03 13:08:08 christos Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -91,8 +91,11 @@ #define LINUX_SYS_GETSOCKOPT 15 #define LINUX_SYS_SENDMSG 16 #define LINUX_SYS_RECVMSG 17 +#define LINUX_SYS_ACCEPT4 18 +#define LINUX_SYS_RECVMMSG 19 +#define LINUX_SYS_SENDMMSG 20 -#define LINUX_MAX_SOCKETCALL 17 +#define LINUX_MAX_SOCKETCALL 18 /* no send/recv mmsg yet */ /* @@ -221,6 +224,13 @@ struct linux_sys_shutdown_args { syscallarg(int) how; }; +struct linux_sys_accept4_args { + syscallarg(int) s; + syscallarg(struct osockaddr *) name; + syscallarg(int *) anamelen; + syscallarg(int) flags; +}; + # ifdef _KERNEL __BEGIN_DECLS #define SYS_DEF(foo) int foo(struct lwp *, const struct foo##_args *, register_t *); @@ -239,6 +249,7 @@ SYS_DEF(linux_sys_recvmsg) SYS_DEF(linux_sys_recv) SYS_DEF(linux_sys_send) SYS_DEF(linux_sys_accept) +SYS_DEF(linux_sys_accept4) #undef SYS_DEF __END_DECLS # endif /* !_KERNEL */
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: martin Date: Fri Feb 3 08:43:02 UTC 2017 Modified Files: src/sys/compat/linux/common: linux_socket.c Log Message: Do not compile accept4 on i386, there is no such syscall in Linux. To generate a diff of this commit: cvs rdiff -u -r1.134 -r1.135 src/sys/compat/linux/common/linux_socket.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_socket.c diff -u src/sys/compat/linux/common/linux_socket.c:1.134 src/sys/compat/linux/common/linux_socket.c:1.135 --- src/sys/compat/linux/common/linux_socket.c:1.134 Thu Feb 2 15:36:55 2017 +++ src/sys/compat/linux/common/linux_socket.c Fri Feb 3 08:43:02 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_socket.c,v 1.134 2017/02/02 15:36:55 christos Exp $ */ +/* $NetBSD: linux_socket.c,v 1.135 2017/02/03 08:43:02 martin Exp $ */ /*- * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.134 2017/02/02 15:36:55 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.135 2017/02/03 08:43:02 martin Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -1708,6 +1708,7 @@ linux_sys_accept(struct lwp *l, const st return (0); } +#ifndef __i386__ /* Linux/i386 does not have this syscall */ int linux_sys_accept4(struct lwp *l, const struct linux_sys_accept4_args *uap, register_t *retval) { @@ -1742,3 +1743,5 @@ linux_sys_accept4(struct lwp *l, const s return 0; } +#endif +
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: christos Date: Thu Feb 2 15:36:55 UTC 2017 Modified Files: src/sys/compat/linux/common: linux_socket.c Log Message: implement accept4 To generate a diff of this commit: cvs rdiff -u -r1.133 -r1.134 src/sys/compat/linux/common/linux_socket.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_socket.c diff -u src/sys/compat/linux/common/linux_socket.c:1.133 src/sys/compat/linux/common/linux_socket.c:1.134 --- src/sys/compat/linux/common/linux_socket.c:1.133 Tue Sep 13 03:01:07 2016 +++ src/sys/compat/linux/common/linux_socket.c Thu Feb 2 10:36:55 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_socket.c,v 1.133 2016/09/13 07:01:07 martin Exp $ */ +/* $NetBSD: linux_socket.c,v 1.134 2017/02/02 15:36:55 christos Exp $ */ /*- * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.133 2016/09/13 07:01:07 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.134 2017/02/02 15:36:55 christos Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -1707,3 +1707,38 @@ linux_sys_accept(struct lwp *l, const st return (0); } + +int +linux_sys_accept4(struct lwp *l, const struct linux_sys_accept4_args *uap, register_t *retval) +{ + /* { + syscallarg(int) s; + syscallarg(struct osockaddr *) name; + syscallarg(int *) anamelen; + syscallarg(int) flags; + } */ + int error, flags; + struct sockaddr_big name; + + if ((flags = linux_to_bsd_type(SCARG(uap, flags))) == -1) + return EINVAL; + + name.sb_len = UCHAR_MAX; + error = do_sys_accept(l, SCARG(uap, s), (struct sockaddr *), + retval, NULL, flags, 0); + if (error != 0) + return error; + + error = copyout_sockname_sb((struct sockaddr *)SCARG(uap, name), + SCARG(uap, anamelen), MSG_LENUSRSPACE, ); + if (error != 0) { + int fd = (int)*retval; + if (fd_getfile(fd) != NULL) + (void)fd_close(fd); + return error; + } + if (SCARG(uap, name) && (error = linux_sa_put(SCARG(uap, name + return error; + + return 0; +}
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: christos Date: Sat Jan 28 15:01:01 UTC 2017 Modified Files: src/sys/compat/linux/common: linux_file64.c linux_misc.c Log Message: copy the terminating NUL (njoly) To generate a diff of this commit: cvs rdiff -u -r1.57 -r1.58 src/sys/compat/linux/common/linux_file64.c cvs rdiff -u -r1.236 -r1.237 src/sys/compat/linux/common/linux_misc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_file64.c diff -u src/sys/compat/linux/common/linux_file64.c:1.57 src/sys/compat/linux/common/linux_file64.c:1.58 --- src/sys/compat/linux/common/linux_file64.c:1.57 Fri Jan 13 17:46:43 2017 +++ src/sys/compat/linux/common/linux_file64.c Sat Jan 28 10:01:01 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_file64.c,v 1.57 2017/01/13 22:46:43 christos Exp $ */ +/* $NetBSD: linux_file64.c,v 1.58 2017/01/28 15:01:01 christos Exp $ */ /*- * Copyright (c) 1995, 1998, 2000, 2008 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_file64.c,v 1.57 2017/01/13 22:46:43 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_file64.c,v 1.58 2017/01/28 15:01:01 christos Exp $"); #include #include @@ -355,7 +355,7 @@ again: idb.d_off = off; idb.d_reclen = (u_short)linux_reclen; memcpy(idb.d_name, bdp->d_name, MIN(sizeof(idb.d_name), - bdp->d_namlen)); + bdp->d_namlen + 1)); if ((error = copyout((void *), outp, linux_reclen))) goto out; /* advance past this real entry */ Index: src/sys/compat/linux/common/linux_misc.c diff -u src/sys/compat/linux/common/linux_misc.c:1.236 src/sys/compat/linux/common/linux_misc.c:1.237 --- src/sys/compat/linux/common/linux_misc.c:1.236 Fri Jan 13 17:45:15 2017 +++ src/sys/compat/linux/common/linux_misc.c Sat Jan 28 10:01:01 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_misc.c,v 1.236 2017/01/13 22:45:15 christos Exp $ */ +/* $NetBSD: linux_misc.c,v 1.237 2017/01/28 15:01:01 christos Exp $ */ /*- * Copyright (c) 1995, 1998, 1999, 2008 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.236 2017/01/13 22:45:15 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.237 2017/01/28 15:01:01 christos Exp $"); #include #include @@ -788,7 +788,7 @@ again: *((char *) + idb.d_reclen - 1) = bdp->d_type; } memcpy(idb.d_name, bdp->d_name, - MIN(sizeof(idb.d_name), bdp->d_namlen)); + MIN(sizeof(idb.d_name), bdp->d_namlen + 1)); if ((error = copyout((void *), outp, linux_reclen))) goto out; /* advance past this real entry */
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: christos Date: Fri Jan 13 22:46:44 UTC 2017 Modified Files: src/sys/compat/linux/common: linux_file64.c Log Message: fix typo To generate a diff of this commit: cvs rdiff -u -r1.56 -r1.57 src/sys/compat/linux/common/linux_file64.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_file64.c diff -u src/sys/compat/linux/common/linux_file64.c:1.56 src/sys/compat/linux/common/linux_file64.c:1.57 --- src/sys/compat/linux/common/linux_file64.c:1.56 Fri Jan 13 16:02:05 2017 +++ src/sys/compat/linux/common/linux_file64.c Fri Jan 13 17:46:43 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_file64.c,v 1.56 2017/01/13 21:02:05 christos Exp $ */ +/* $NetBSD: linux_file64.c,v 1.57 2017/01/13 22:46:43 christos Exp $ */ /*- * Copyright (c) 1995, 1998, 2000, 2008 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_file64.c,v 1.56 2017/01/13 21:02:05 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_file64.c,v 1.57 2017/01/13 22:46:43 christos Exp $"); #include #include @@ -355,7 +355,7 @@ again: idb.d_off = off; idb.d_reclen = (u_short)linux_reclen; memcpy(idb.d_name, bdp->d_name, MIN(sizeof(idb.d_name), - bdp.d_namlen); + bdp->d_namlen)); if ((error = copyout((void *), outp, linux_reclen))) goto out; /* advance past this real entry */
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: christos Date: Fri Jan 13 22:45:15 UTC 2017 Modified Files: src/sys/compat/linux/common: linux_misc.c Log Message: no namlen on linux To generate a diff of this commit: cvs rdiff -u -r1.235 -r1.236 src/sys/compat/linux/common/linux_misc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_misc.c diff -u src/sys/compat/linux/common/linux_misc.c:1.235 src/sys/compat/linux/common/linux_misc.c:1.236 --- src/sys/compat/linux/common/linux_misc.c:1.235 Fri Jan 13 15:24:37 2017 +++ src/sys/compat/linux/common/linux_misc.c Fri Jan 13 17:45:15 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_misc.c,v 1.235 2017/01/13 20:24:37 christos Exp $ */ +/* $NetBSD: linux_misc.c,v 1.236 2017/01/13 22:45:15 christos Exp $ */ /*- * Copyright (c) 1995, 1998, 1999, 2008 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.235 2017/01/13 20:24:37 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.236 2017/01/13 22:45:15 christos Exp $"); #include #include @@ -788,7 +788,7 @@ again: *((char *) + idb.d_reclen - 1) = bdp->d_type; } memcpy(idb.d_name, bdp->d_name, - MIN(sizeof(idb.d_name), idb.d_namlen)); + MIN(sizeof(idb.d_name), bdp->d_namlen)); if ((error = copyout((void *), outp, linux_reclen))) goto out; /* advance past this real entry */
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: christos Date: Fri Jan 13 20:24:37 UTC 2017 Modified Files: src/sys/compat/linux/common: linux_misc.c Log Message: convert strcpy to a bounded copy to avoid compiler warnings, although the reclen test prevents overflow. To generate a diff of this commit: cvs rdiff -u -r1.234 -r1.235 src/sys/compat/linux/common/linux_misc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_misc.c diff -u src/sys/compat/linux/common/linux_misc.c:1.234 src/sys/compat/linux/common/linux_misc.c:1.235 --- src/sys/compat/linux/common/linux_misc.c:1.234 Mon Jan 2 11:32:10 2017 +++ src/sys/compat/linux/common/linux_misc.c Fri Jan 13 15:24:37 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_misc.c,v 1.234 2017/01/02 16:32:10 manu Exp $ */ +/* $NetBSD: linux_misc.c,v 1.235 2017/01/13 20:24:37 christos Exp $ */ /*- * Copyright (c) 1995, 1998, 1999, 2008 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.234 2017/01/02 16:32:10 manu Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.235 2017/01/13 20:24:37 christos Exp $"); #include #include @@ -787,7 +787,8 @@ again: /* Linux puts d_type at the end of each record */ *((char *) + idb.d_reclen - 1) = bdp->d_type; } - strcpy(idb.d_name, bdp->d_name); + memcpy(idb.d_name, bdp->d_name, + MIN(sizeof(idb.d_name), idb.d_namlen)); if ((error = copyout((void *), outp, linux_reclen))) goto out; /* advance past this real entry */
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: martin Date: Mon Jan 2 20:10:44 UTC 2017 Modified Files: src/sys/compat/linux/common: linux_signal.h Log Message: Provide a dummy linux_sigset_t for all architectures that do not have any machdep one. This make kdump compile again. To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/sys/compat/linux/common/linux_signal.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_signal.h diff -u src/sys/compat/linux/common/linux_signal.h:1.31 src/sys/compat/linux/common/linux_signal.h:1.32 --- src/sys/compat/linux/common/linux_signal.h:1.31 Mon Jan 2 16:32:10 2017 +++ src/sys/compat/linux/common/linux_signal.h Mon Jan 2 20:10:44 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_signal.h,v 1.31 2017/01/02 16:32:10 manu Exp $ */ +/* $NetBSD: linux_signal.h,v 1.32 2017/01/02 20:10:44 martin Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -46,6 +46,8 @@ #include #elif defined(__amd64__) #include +#else +typedef void linux_sigset_t; #endif typedef struct {
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: njoly Date: Wed Aug 31 08:12:44 UTC 2016 Modified Files: src/sys/compat/linux/common: linux_misc.c linux_misc.h Log Message: Teach wait4 about WCONTINUED. To generate a diff of this commit: cvs rdiff -u -r1.231 -r1.232 src/sys/compat/linux/common/linux_misc.c cvs rdiff -u -r1.24 -r1.25 src/sys/compat/linux/common/linux_misc.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_misc.c diff -u src/sys/compat/linux/common/linux_misc.c:1.231 src/sys/compat/linux/common/linux_misc.c:1.232 --- src/sys/compat/linux/common/linux_misc.c:1.231 Sat Mar 14 08:32:08 2015 +++ src/sys/compat/linux/common/linux_misc.c Wed Aug 31 08:12:44 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_misc.c,v 1.231 2015/03/14 08:32:08 njoly Exp $ */ +/* $NetBSD: linux_misc.c,v 1.232 2016/08/31 08:12:44 njoly Exp $ */ /*- * Copyright (c) 1995, 1998, 1999, 2008 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.231 2015/03/14 08:32:08 njoly Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.232 2016/08/31 08:12:44 njoly Exp $"); #include #include @@ -231,6 +231,8 @@ linux_sys_wait4(struct lwp *l, const str options |= WNOHANG; if (linux_options & LINUX_WAIT4_WUNTRACED) options |= WUNTRACED; + if (linux_options & LINUX_WAIT4_WCONTINUED) + options |= WCONTINUED; if (linux_options & LINUX_WAIT4_WALL) options |= WALLSIG; if (linux_options & LINUX_WAIT4_WCLONE) Index: src/sys/compat/linux/common/linux_misc.h diff -u src/sys/compat/linux/common/linux_misc.h:1.24 src/sys/compat/linux/common/linux_misc.h:1.25 --- src/sys/compat/linux/common/linux_misc.h:1.24 Mon Nov 18 01:32:52 2013 +++ src/sys/compat/linux/common/linux_misc.h Wed Aug 31 08:12:44 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_misc.h,v 1.24 2013/11/18 01:32:52 chs Exp $ */ +/* $NetBSD: linux_misc.h,v 1.25 2016/08/31 08:12:44 njoly Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -35,14 +35,16 @@ /* * Options passed to the Linux wait4() system call. */ -#define LINUX_WAIT4_WNOHANG 0x0001 -#define LINUX_WAIT4_WUNTRACED 0x0002 -#define LINUX_WAIT4_WNOTHREAD 0x2000 -#define LINUX_WAIT4_WALL 0x4000 -#define LINUX_WAIT4_WCLONE0x8000 +#define LINUX_WAIT4_WNOHANG 0x0001 +#define LINUX_WAIT4_WUNTRACED 0x0002 +#define LINUX_WAIT4_WCONTINUED 0x0008 +#define LINUX_WAIT4_WNOTHREAD 0x2000 +#define LINUX_WAIT4_WALL 0x4000 +#define LINUX_WAIT4_WCLONE 0x8000 #define LINUX_WAIT4_KNOWNFLAGS (LINUX_WAIT4_WNOHANG | \ LINUX_WAIT4_WUNTRACED | \ +LINUX_WAIT4_WCONTINUED | \ LINUX_WAIT4_WNOTHREAD | \ LINUX_WAIT4_WALL | \ LINUX_WAIT4_WCLONE)
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: maxv Date: Mon Aug 15 09:20:11 UTC 2016 Modified Files: src/sys/compat/linux/common: linux_futex.c Log Message: Uninitialized var, found by brainy; not tested, but obvious enough To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/sys/compat/linux/common/linux_futex.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_futex.c diff -u src/sys/compat/linux/common/linux_futex.c:1.34 src/sys/compat/linux/common/linux_futex.c:1.35 --- src/sys/compat/linux/common/linux_futex.c:1.34 Fri May 20 13:54:34 2016 +++ src/sys/compat/linux/common/linux_futex.c Mon Aug 15 09:20:11 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_futex.c,v 1.34 2016/05/20 13:54:34 chs Exp $ */ +/* $NetBSD: linux_futex.c,v 1.35 2016/08/15 09:20:11 maxv Exp $ */ /*- * Copyright (c) 2005 Emmanuel Dreyfus, all rights reserved. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(1, "$NetBSD: linux_futex.c,v 1.34 2016/05/20 13:54:34 chs Exp $"); +__KERNEL_RCSID(1, "$NetBSD: linux_futex.c,v 1.35 2016/08/15 09:20:11 maxv Exp $"); #include #include @@ -769,6 +769,7 @@ release_futexes(struct lwp *l) return; head.futex_offset = (unsigned long)u32; + futex_offset = head.futex_offset; } else #endif if (copyin(_offset, _offset, sizeof(unsigned long)))
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: ozaki-r Date: Tue Jul 5 07:55:08 UTC 2016 Modified Files: src/sys/compat/linux/common: linux_socket.c Log Message: Fix psref isn't released in a case of IFADDR_EMPTY To generate a diff of this commit: cvs rdiff -u -r1.129 -r1.130 src/sys/compat/linux/common/linux_socket.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_socket.c diff -u src/sys/compat/linux/common/linux_socket.c:1.129 src/sys/compat/linux/common/linux_socket.c:1.130 --- src/sys/compat/linux/common/linux_socket.c:1.129 Thu Jun 16 02:38:40 2016 +++ src/sys/compat/linux/common/linux_socket.c Tue Jul 5 07:55:08 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_socket.c,v 1.129 2016/06/16 02:38:40 ozaki-r Exp $ */ +/* $NetBSD: linux_socket.c,v 1.130 2016/07/05 07:55:08 ozaki-r Exp $ */ /*- * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.129 2016/06/16 02:38:40 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.130 2016/07/05 07:55:08 ozaki-r Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -1149,8 +1149,7 @@ linux_getifconf(struct lwp *l, register_ error = ENAMETOOLONG; goto release_exit; } - if (IFADDR_EMPTY(ifp)) - continue; + IFADDR_FOREACH(ifa, ifp) { sa = ifa->ifa_addr; if (sa->sa_family != AF_INET ||
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: chs Date: Fri May 20 13:54:34 UTC 2016 Modified Files: src/sys/compat/linux/common: linux_futex.c Log Message: simplify and fix futex requeuing: don't wake up all the threads being requeued to have them move themselves from one list to another (thus defeating the purpose), just change the lists directly in futex_wake(). To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/sys/compat/linux/common/linux_futex.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_futex.c diff -u src/sys/compat/linux/common/linux_futex.c:1.33 src/sys/compat/linux/common/linux_futex.c:1.34 --- src/sys/compat/linux/common/linux_futex.c:1.33 Tue Feb 11 16:00:13 2014 +++ src/sys/compat/linux/common/linux_futex.c Fri May 20 13:54:34 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_futex.c,v 1.33 2014/02/11 16:00:13 maxv Exp $ */ +/* $NetBSD: linux_futex.c,v 1.34 2016/05/20 13:54:34 chs Exp $ */ /*- * Copyright (c) 2005 Emmanuel Dreyfus, all rights reserved. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(1, "$NetBSD: linux_futex.c,v 1.33 2014/02/11 16:00:13 maxv Exp $"); +__KERNEL_RCSID(1, "$NetBSD: linux_futex.c,v 1.34 2016/05/20 13:54:34 chs Exp $"); #include #include @@ -58,11 +58,10 @@ __KERNEL_RCSID(1, "$NetBSD: linux_futex. struct futex; struct waiting_proc { - lwp_t *wp_l; - struct futex *wp_new_futex; + struct futex *wp_futex; kcondvar_t wp_futex_cv; TAILQ_ENTRY(waiting_proc) wp_list; - TAILQ_ENTRY(waiting_proc) wp_rqlist; + bool wp_onlist; }; struct futex { void *f_uaddr; @@ -70,7 +69,6 @@ struct futex { uint32_t f_bitset; LIST_ENTRY(futex) f_list; TAILQ_HEAD(, waiting_proc) f_waiting_proc; - TAILQ_HEAD(, waiting_proc) f_requeue_proc; }; static LIST_HEAD(futex_list, futex) futex_list; @@ -432,7 +430,6 @@ futex_get(void *uaddr, uint32_t bitset) f->f_bitset = bitset; f->f_refcount = 1; TAILQ_INIT(>f_waiting_proc); - TAILQ_INIT(>f_requeue_proc); LIST_INSERT_HEAD(_list, f, f_list); return f; @@ -456,7 +453,6 @@ futex_put(struct futex *f) f->f_refcount--; if (f->f_refcount == 0) { KASSERT(TAILQ_EMPTY(>f_waiting_proc)); - KASSERT(TAILQ_EMPTY(>f_requeue_proc)); LIST_REMOVE(f, f_list); kmem_free(f, sizeof(*f)); } @@ -465,107 +461,78 @@ futex_put(struct futex *f) static int futex_sleep(struct futex **fp, lwp_t *l, int timeout, struct waiting_proc *wp) { - struct futex *f, *newf; + struct futex *f; int ret; FUTEX_LOCKASSERT; f = *fp; - wp->wp_l = l; - wp->wp_new_futex = NULL; - -requeue: + wp->wp_futex = f; TAILQ_INSERT_TAIL(>f_waiting_proc, wp, wp_list); + wp->wp_onlist = true; ret = cv_timedwait_sig(>wp_futex_cv, _lock, timeout); - TAILQ_REMOVE(>f_waiting_proc, wp, wp_list); - /* if futex_wake() tells us to requeue ... */ - newf = wp->wp_new_futex; - if (ret == 0 && newf != NULL) { - /* ... requeue ourselves on the new futex */ - futex_put(f); - wp->wp_new_futex = NULL; - TAILQ_REMOVE(>f_requeue_proc, wp, wp_rqlist); - *fp = f = newf; - goto requeue; + /* + * we may have been requeued to a different futex before we were + * woken up, so let the caller know which futex to put. if we were + * woken by futex_wake() then it took us off the waiting list, + * but if our sleep was interrupted or timed out then we might + * need to take ourselves off the waiting list. + */ + + f = wp->wp_futex; + if (wp->wp_onlist) { + TAILQ_REMOVE(>f_waiting_proc, wp, wp_list); } + *fp = f; return ret; } static int futex_wake(struct futex *f, int n, struct futex *newf, int n2) { - struct waiting_proc *wp, *wpnext; - int count; + struct waiting_proc *wp; + int count = 0; FUTEX_LOCKASSERT; - count = newf ? 0 : 1; - /* - * first, wake up any threads sleeping on this futex. - * note that sleeping threads are not in the process of requeueing. + * wake up up to n threads waiting on this futex. */ - TAILQ_FOREACH(wp, >f_waiting_proc, wp_list) { - KASSERT(wp->wp_new_futex == NULL); - - FUTEXPRINTF(("%s: signal f %p l %p ref %d\n", __func__, - f, wp->wp_l, f->f_refcount)); + while (n--) { + wp = TAILQ_FIRST(>f_waiting_proc); + if (wp == NULL) + return count; + + KASSERT(f == wp->wp_futex); + TAILQ_REMOVE(>f_waiting_proc, wp, wp_list); + wp->wp_onlist = false; cv_signal(>wp_futex_cv); - if (count <= n) { - count++; - } else { - if (newf == NULL) -break; - - /* matching futex_put() is called by the other thread. */ - futex_ref(newf); - wp->wp_new_futex = newf; - TAILQ_INSERT_TAIL(>f_requeue_proc, wp, wp_rqlist); - FUTEXPRINTF(("%s: requeue newf %p l %p ref %d\n", - __func__, newf, wp->wp_l, newf->f_refcount)); - if (count - n >= n2) -goto out; - } + count++; } + if (newf == NULL) + return count; /* - * next, deal with threads that are requeuing to this futex. - * we don't need to signal these threads,
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: pgoyette Date: Sat Oct 10 04:28:04 UTC 2015 Modified Files: src/sys/compat/linux/common: linux_mod.c Log Message: Add an additional dependency on compat_sysv To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/compat/linux/common/linux_mod.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_mod.c diff -u src/sys/compat/linux/common/linux_mod.c:1.4 src/sys/compat/linux/common/linux_mod.c:1.5 --- src/sys/compat/linux/common/linux_mod.c:1.4 Fri Mar 7 01:33:43 2014 +++ src/sys/compat/linux/common/linux_mod.c Sat Oct 10 04:28:04 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_mod.c,v 1.4 2014/03/07 01:33:43 christos Exp $ */ +/* $NetBSD: linux_mod.c,v 1.5 2015/10/10 04:28:04 pgoyette Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux_mod.c,v 1.4 2014/03/07 01:33:43 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux_mod.c,v 1.5 2015/10/10 04:28:04 pgoyette Exp $"); #ifdef _KERNEL_OPT #include "opt_execfmt.h" @@ -65,7 +65,8 @@ __KERNEL_RCSID(0, "$NetBSD: linux_mod.c, # define MD3 "" #endif -MODULE(MODULE_CLASS_EXEC, compat_linux, "compat,compat_ossaudio" MD1 MD2 MD3); +MODULE(MODULE_CLASS_EXEC, compat_linux, "compat,compat_ossaudio,compat_sysv" + MD1 MD2 MD3); static struct execsw linux_execsw[] = { #if defined(EXEC_ELF32) && ELFSIZE == 32
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: christos Date: Fri Jul 3 02:24:28 UTC 2015 Modified Files: src/sys/compat/linux/common: linux_sched.c Log Message: PR/50021: Rin Okuyama: Fix linux affinity syscalls XXX: pullup-7 To generate a diff of this commit: cvs rdiff -u -r1.67 -r1.68 src/sys/compat/linux/common/linux_sched.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_sched.c diff -u src/sys/compat/linux/common/linux_sched.c:1.67 src/sys/compat/linux/common/linux_sched.c:1.68 --- src/sys/compat/linux/common/linux_sched.c:1.67 Sun Nov 9 12:48:08 2014 +++ src/sys/compat/linux/common/linux_sched.c Thu Jul 2 22:24:28 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_sched.c,v 1.67 2014/11/09 17:48:08 maxv Exp $ */ +/* $NetBSD: linux_sched.c,v 1.68 2015/07/03 02:24:28 christos Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_sched.c,v 1.67 2014/11/09 17:48:08 maxv Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_sched.c,v 1.68 2015/07/03 02:24:28 christos Exp $); #include sys/param.h #include sys/mount.h @@ -65,6 +65,9 @@ __KERNEL_RCSID(0, $NetBSD: linux_sched. static int linux_clone_nptl(struct lwp *, const struct linux_sys_clone_args *, register_t *); +/* Unlike Linux, dynamically calculate CPU mask size */ +#define LINUX_CPU_MASK_SIZE (sizeof(long) * ((ncpu + LONG_BIT - 1) / LONG_BIT)) + #if DEBUG_LINUX #define DPRINTF(x) uprintf x #else @@ -627,6 +630,10 @@ linux_sys_gettid(struct lwp *l, const vo return 0; } +/* + * The affinity syscalls assume that the layout of our cpu kcpuset is + * the same as linux's: a linear bitmask. + */ int linux_sys_sched_getaffinity(struct lwp *l, const struct linux_sys_sched_getaffinity_args *uap, register_t *retval) { @@ -635,39 +642,45 @@ linux_sys_sched_getaffinity(struct lwp * syscallarg(unsigned int) len; syscallarg(unsigned long *) mask; } */ - proc_t *p; - unsigned long *lp, *data; - int error, size, nb = ncpu; + struct lwp *t; + kcpuset_t *kcset; + size_t size; + cpuid_t i; + int error; - /* Unlike Linux, dynamically calculate cpu mask size */ - size = sizeof(long) * ((ncpu + LONG_BIT - 1) / LONG_BIT); + size = LINUX_CPU_MASK_SIZE; if (SCARG(uap, len) size) return EINVAL; - /* XXX: Pointless check. TODO: Actually implement this. */ - mutex_enter(proc_lock); - p = proc_find(SCARG(uap, pid)); - mutex_exit(proc_lock); - if (p == NULL) { + /* Lock the LWP */ + t = lwp_find2(SCARG(uap, pid), l-l_lid); + if (t == NULL) return ESRCH; - } - - /* - * return the actual number of CPU, tag all of them as available - * The result is a mask, the first CPU being in the least significant - * bit. - */ - data = kmem_zalloc(size, KM_SLEEP); - lp = data; - while (nb LONG_BIT) { - *lp++ = ~0UL; - nb -= LONG_BIT; - } - if (nb) - *lp = (1 ncpu) - 1; - error = copyout(data, SCARG(uap, mask), size); - kmem_free(data, size); + /* Check the permission */ + if (kauth_authorize_process(l-l_cred, + KAUTH_PROCESS_SCHEDULER_GETAFFINITY, t-l_proc, NULL, NULL, NULL)) { + mutex_exit(t-l_proc-p_lock); + return EPERM; + } + + kcpuset_create(kcset, true); + lwp_lock(t); + if (t-l_affinity != NULL) + kcpuset_copy(kcset, t-l_affinity); + else { + /* + * All available CPUs should be masked when affinity has not + * been set. + */ + kcpuset_zero(kcset); + for (i = 0; i ncpu; i++) + kcpuset_set(kcset, i); + } + lwp_unlock(t); + mutex_exit(t-l_proc-p_lock); + error = kcpuset_copyout(kcset, (cpuset_t *)SCARG(uap, mask), size); + kcpuset_unuse(kcset, NULL); *retval = size; return error; } @@ -680,17 +693,17 @@ linux_sys_sched_setaffinity(struct lwp * syscallarg(unsigned int) len; syscallarg(unsigned long *) mask; } */ - proc_t *p; + struct sys__sched_setaffinity_args ssa; + size_t size; - /* XXX: Pointless check. TODO: Actually implement this. */ - mutex_enter(proc_lock); - p = proc_find(SCARG(uap, pid)); - mutex_exit(proc_lock); - if (p == NULL) { - return ESRCH; - } + size = LINUX_CPU_MASK_SIZE; + if (SCARG(uap, len) size) + return EINVAL; - /* Let's ignore it */ - DPRINTF((%s\n, __func__)); - return 0; + SCARG(ssa, pid) = SCARG(uap, pid); + SCARG(ssa, lid) = l-l_lid; + SCARG(ssa, size) = size; + SCARG(ssa, cpuset) = (cpuset_t *)SCARG(uap, mask); + + return sys__sched_setaffinity(l, ssa, retval); }
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: matt Date: Thu Jun 11 02:54:00 UTC 2015 Modified Files: src/sys/compat/linux/common: linux_exec_elf32.c Log Message: Force *stackp to (uintptr_t) before possibly moving to a smaller pointer size. To generate a diff of this commit: cvs rdiff -u -r1.92 -r1.93 src/sys/compat/linux/common/linux_exec_elf32.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_exec_elf32.c diff -u src/sys/compat/linux/common/linux_exec_elf32.c:1.92 src/sys/compat/linux/common/linux_exec_elf32.c:1.93 --- src/sys/compat/linux/common/linux_exec_elf32.c:1.92 Fri Mar 20 20:36:27 2015 +++ src/sys/compat/linux/common/linux_exec_elf32.c Thu Jun 11 02:54:00 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_exec_elf32.c,v 1.92 2015/03/20 20:36:27 maxv Exp $ */ +/* $NetBSD: linux_exec_elf32.c,v 1.93 2015/06/11 02:54:00 matt Exp $ */ /*- * Copyright (c) 1995, 1998, 2000, 2001 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_exec_elf32.c,v 1.92 2015/03/20 20:36:27 maxv Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_exec_elf32.c,v 1.93 2015/06/11 02:54:00 matt Exp $); #ifndef ELFSIZE /* XXX should die */ @@ -460,7 +460,7 @@ ELFNAME2(linux,copyargs)(struct lwp *l, a++; a-a_type = LINUX_AT_RANDOM; - a-a_v = (Elf_Addr)*stackp; + a-a_v = (Elf_Addr)(uintptr_t)*stackp; a++; a-a_type = AT_NULL;
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: rtr Date: Sun May 24 17:07:27 UTC 2015 Modified Files: src/sys/compat/linux/common: linux_socket.c Log Message: convert remaining linux_get_sa() users to use linux_get_sa_sb() and pass the pointer to the sockaddr in msghdr.msg_name, while removing the MSG_NAMEMBUF flag. now that the original linux_get_sa() is unused remove it and to make function names consistent again rename linux_get_sa_sb() to linux_get_sa(). To generate a diff of this commit: cvs rdiff -u -r1.124 -r1.125 src/sys/compat/linux/common/linux_socket.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_socket.c diff -u src/sys/compat/linux/common/linux_socket.c:1.124 src/sys/compat/linux/common/linux_socket.c:1.125 --- src/sys/compat/linux/common/linux_socket.c:1.124 Sat May 2 17:18:03 2015 +++ src/sys/compat/linux/common/linux_socket.c Sun May 24 17:07:26 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_socket.c,v 1.124 2015/05/02 17:18:03 rtr Exp $ */ +/* $NetBSD: linux_socket.c,v 1.125 2015/05/24 17:07:26 rtr Exp $ */ /*- * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_socket.c,v 1.124 2015/05/02 17:18:03 rtr Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_socket.c,v 1.125 2015/05/24 17:07:26 rtr Exp $); #if defined(_KERNEL_OPT) #include opt_inet.h @@ -119,9 +119,7 @@ int linux_to_bsd_udp_sockopt(int); int linux_getifname(struct lwp *, register_t *, void *); int linux_getifconf(struct lwp *, register_t *, void *); int linux_getifhwaddr(struct lwp *, register_t *, u_int, void *); -static int linux_get_sa(struct lwp *, int, struct mbuf **, - const struct osockaddr *, unsigned int); -static int linux_get_sa_sb(struct lwp *, int, struct sockaddr_big *, +static int linux_get_sa(struct lwp *, int, struct sockaddr_big *, const struct osockaddr *, socklen_t); static int linux_sa_put(struct osockaddr *osa); static int linux_to_bsd_msg_flags(int); @@ -401,7 +399,7 @@ linux_sys_sendto(struct lwp *l, const st } */ struct msghdr msg; struct iovecaiov; - struct mbuf *nam; + struct sockaddr_big nam; int bflags; int error; @@ -421,8 +419,7 @@ linux_sys_sendto(struct lwp *l, const st SCARG(uap, tolen)); if (error) return (error); - msg.msg_flags |= MSG_NAMEMBUF; - msg.msg_name = nam; + msg.msg_name = nam; msg.msg_namelen = SCARG(uap, tolen); } @@ -470,7 +467,7 @@ linux_sys_sendmsg(struct lwp *l, const s struct linux_msghdr lmsg; int error; int bflags; - struct mbuf *nam; + struct sockaddr_big nam; u_int8_t *control; struct mbuf *ctl_mbuf = NULL; @@ -495,8 +492,7 @@ linux_sys_sendmsg(struct lwp *l, const s msg.msg_namelen); if (error) return (error); - msg.msg_flags |= MSG_NAMEMBUF; - msg.msg_name = nam; + msg.msg_name = nam; } /* @@ -1404,7 +1400,7 @@ linux_sys_connect(struct lwp *l, const s int error; struct sockaddr_big sb; - error = linux_get_sa_sb(l, SCARG(uap, s), sb, SCARG(uap, name), + error = linux_get_sa(l, SCARG(uap, s), sb, SCARG(uap, name), SCARG(uap, namelen)); if (error) return (error); @@ -1449,7 +1445,7 @@ linux_sys_bind(struct lwp *l, const stru int error; struct sockaddr_big sb; - error = linux_get_sa_sb(l, SCARG(uap, s), sb, SCARG(uap, name), + error = linux_get_sa(l, SCARG(uap, s), sb, SCARG(uap, name), SCARG(uap, namelen)); if (error) return (error); @@ -1495,8 +1491,12 @@ linux_sys_getpeername(struct lwp *l, con return (0); } +/* + * Copy the osockaddr structure pointed to by name to sb, adjust + * family and convert to sockaddr. + */ static int -linux_get_sa_sb(struct lwp *l, int s, struct sockaddr_big *sb, +linux_get_sa(struct lwp *l, int s, struct sockaddr_big *sb, const struct osockaddr *name, socklen_t namelen) { int error, bdom; @@ -1566,122 +1566,6 @@ linux_get_sa_sb(struct lwp *l, int s, st return 0; } -/* - * Copy the osockaddr structure pointed to by osa to mbuf, adjust - * family and convert to sockaddr. - */ -static int -linux_get_sa(struct lwp *l, int s, struct mbuf **mp, -const struct osockaddr *osa, unsigned int salen) -{ - int error, bdom; - struct sockaddr *sa; - struct osockaddr *kosa; - struct mbuf *m; - - if (salen == 1 || salen UCHAR_MAX) { - DPRINTF((bad osa=%p salen=%d\n, osa, salen)); - return EINVAL; - } - - /* We'll need the address in an mbuf later, so copy into one here */ - m = m_get(M_WAIT, MT_SONAME); - if (salen MLEN) - MEXTMALLOC(m, salen, M_WAITOK); - - m-m_len = salen; - - if (salen == 0) { - *mp = m; - return 0; - } - - kosa = mtod(m, void *); - if ((error = copyin(osa, kosa, salen))) { - DPRINTF((error %d copying osa %p len %d\n, -error, osa, salen)); - goto bad; - } - - ktrkuser(linux/sockaddr, kosa, salen); - - bdom = linux_to_bsd_domain(kosa-sa_family); - if (bdom
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: njoly Date: Sun Mar 1 13:19:39 UTC 2015 Modified Files: src/sys/compat/linux/common: linux_fcntl.h linux_file.c Log Message: Add Linux specific fcntl(2) commands. Support F_DUPFD_CLOEXEC. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/compat/linux/common/linux_fcntl.h cvs rdiff -u -r1.114 -r1.115 src/sys/compat/linux/common/linux_file.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_fcntl.h diff -u src/sys/compat/linux/common/linux_fcntl.h:1.16 src/sys/compat/linux/common/linux_fcntl.h:1.17 --- src/sys/compat/linux/common/linux_fcntl.h:1.16 Sun Jun 1 13:42:12 2014 +++ src/sys/compat/linux/common/linux_fcntl.h Sun Mar 1 13:19:39 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_fcntl.h,v 1.16 2014/06/01 13:42:12 njoly Exp $ */ +/* $NetBSD: linux_fcntl.h,v 1.17 2015/03/01 13:19:39 njoly Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -87,6 +87,16 @@ struct linux_flock64 { #error Undefined linux_fcntl.h machine type. #endif +/* Linux specific fcntl(2) commands */ +#define LINUX_F_SPECIFIC_BASE 1024 +#define LINUX_F_SETLEASE (LINUX_F_SPECIFIC_BASE + 0) +#define LINUX_F_GETLEASE (LINUX_F_SPECIFIC_BASE + 1) +#define LINUX_F_NOTIFY (LINUX_F_SPECIFIC_BASE + 2) +#define LINUX_F_CANCELLK (LINUX_F_SPECIFIC_BASE + 5) +#define LINUX_F_DUPFD_CLOEXEC (LINUX_F_SPECIFIC_BASE + 6) +#define LINUX_F_SETPIPE_SZ (LINUX_F_SPECIFIC_BASE + 7) +#define LINUX_F_GETPIPE_SZ (LINUX_F_SPECIFIC_BASE + 8) + /* * We have to have 4 copies of the code that converts linux fcntl() file * locking to native form because there are 4 layouts for the structures. Index: src/sys/compat/linux/common/linux_file.c diff -u src/sys/compat/linux/common/linux_file.c:1.114 src/sys/compat/linux/common/linux_file.c:1.115 --- src/sys/compat/linux/common/linux_file.c:1.114 Sun Nov 9 17:48:08 2014 +++ src/sys/compat/linux/common/linux_file.c Sun Mar 1 13:19:39 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_file.c,v 1.114 2014/11/09 17:48:08 maxv Exp $ */ +/* $NetBSD: linux_file.c,v 1.115 2015/03/01 13:19:39 njoly Exp $ */ /*- * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_file.c,v 1.114 2014/11/09 17:48:08 maxv Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_file.c,v 1.115 2015/03/01 13:19:39 njoly Exp $); #include sys/param.h #include sys/systm.h @@ -417,6 +417,10 @@ linux_sys_fcntl(struct lwp *l, const str mutex_exit(proc_lock); return 0; + case LINUX_F_DUPFD_CLOEXEC: + cmd = F_DUPFD_CLOEXEC; + break; + default: return EOPNOTSUPP; }
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: njoly Date: Sat Feb 28 13:08:00 UTC 2015 Modified Files: src/sys/compat/linux/common: linux_limit.h Log Message: When converting limits from linux32 (int32_t) to native (uint64_t), cast it to unsigned first to avoid bad side effect for negative values. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/compat/linux/common/linux_limit.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_limit.h diff -u src/sys/compat/linux/common/linux_limit.h:1.6 src/sys/compat/linux/common/linux_limit.h:1.7 --- src/sys/compat/linux/common/linux_limit.h:1.6 Sat Sep 22 22:34:02 2012 +++ src/sys/compat/linux/common/linux_limit.h Sat Feb 28 13:08:00 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_limit.h,v 1.6 2012/09/22 22:34:02 joerg Exp $ */ +/* $NetBSD: linux_limit.h,v 1.7 2015/02/28 13:08:00 njoly Exp $ */ /*- * Copyright (c) 1995, 1998, 1999 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ static int linux_to_bsd_limit(int); linux_to_bsd_rlimit1(b, l, rlim_max) #define linux32_to_bsd_rlimit1(b, l, f) \ -(b)-f = (l)-f == LINUX32_RLIM_INFINITY ? RLIM_INFINITY : (l)-f +(b)-f = (l)-f == LINUX32_RLIM_INFINITY ? RLIM_INFINITY : (uint32_t)(l)-f #define linux32_to_bsd_rlimit(b, l) \ linux32_to_bsd_rlimit1(b, l, rlim_cur); \ linux32_to_bsd_rlimit1(b, l, rlim_max)
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: njoly Date: Sat Nov 22 15:47:42 UTC 2014 Modified Files: src/sys/compat/linux/common: linux_errno.h Log Message: Do not define LINUX_EDEADLK more than once. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/compat/linux/common/linux_errno.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_errno.h diff -u src/sys/compat/linux/common/linux_errno.h:1.14 src/sys/compat/linux/common/linux_errno.h:1.15 --- src/sys/compat/linux/common/linux_errno.h:1.14 Tue Dec 17 22:14:24 2013 +++ src/sys/compat/linux/common/linux_errno.h Sat Nov 22 15:47:42 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_errno.h,v 1.14 2013/12/17 22:14:24 njoly Exp $ */ +/* $NetBSD: linux_errno.h,v 1.15 2014/11/22 15:47:42 njoly Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -66,7 +66,6 @@ #define LINUX_EPIPE 32 #define LINUX_EDOM 33 #define LINUX_ERANGE 34 -#define LINUX_EDEADLK 35 /* Error numbers after here vary wildly*/
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: ozaki-r Date: Fri Nov 21 06:03:04 UTC 2014 Modified Files: src/sys/compat/linux/common: linux_socket.c Log Message: Tweak linux_getifhwaddr No functional change. To generate a diff of this commit: cvs rdiff -u -r1.120 -r1.121 src/sys/compat/linux/common/linux_socket.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_socket.c diff -u src/sys/compat/linux/common/linux_socket.c:1.120 src/sys/compat/linux/common/linux_socket.c:1.121 --- src/sys/compat/linux/common/linux_socket.c:1.120 Sun Nov 9 17:48:08 2014 +++ src/sys/compat/linux/common/linux_socket.c Fri Nov 21 06:03:04 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_socket.c,v 1.120 2014/11/09 17:48:08 maxv Exp $ */ +/* $NetBSD: linux_socket.c,v 1.121 2014/11/21 06:03:04 ozaki-r Exp $ */ /*- * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_socket.c,v 1.120 2014/11/09 17:48:08 maxv Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_socket.c,v 1.121 2014/11/21 06:03:04 ozaki-r Exp $); #if defined(_KERNEL_OPT) #include opt_inet.h @@ -1234,45 +1234,46 @@ linux_getifhwaddr(struct lwp *l, registe } } - if (strncmp(lreq.ifr_name, eth, 3) == 0) { - for (ifnum = 0, index = 3; - index LINUX_IFNAMSIZ lreq.ifr_name[index] != '\0'; - index++) { - ifnum *= 10; - ifnum += lreq.ifr_name[index] - '0'; - } - - error = EINVAL; /* in case we don't find one */ - found = 0; - IFNET_FOREACH(ifp) { - if (found) -break; - memcpy(lreq.ifr_name, ifp-if_xname, - MIN(LINUX_IFNAMSIZ, IFNAMSIZ)); - IFADDR_FOREACH(ifa, ifp) { -sadl = satosdl(ifa-ifa_addr); -/* only return ethernet addresses */ -/* XXX what about FDDI, etc. ? */ -if (sadl-sdl_family != AF_LINK || -sadl-sdl_type != IFT_ETHER) - continue; -if (ifnum--) - /* not the reqested iface */ - continue; -memcpy(lreq.ifr_hwaddr.sa_data, - CLLADDR(sadl), - MIN(sadl-sdl_alen, - sizeof(lreq.ifr_hwaddr.sa_data))); -lreq.ifr_hwaddr.sa_family = - sadl-sdl_family; -error = copyout(lreq, data, sizeof(lreq)); -found = 1; -break; - } - } - } else { + if (strncmp(lreq.ifr_name, eth, 3) != 0) { /* unknown interface, not even an eth* name */ error = ENODEV; + goto out; + } + + for (ifnum = 0, index = 3; + index LINUX_IFNAMSIZ lreq.ifr_name[index] != '\0'; + index++) { + ifnum *= 10; + ifnum += lreq.ifr_name[index] - '0'; + } + + error = EINVAL; /* in case we don't find one */ + found = 0; + IFNET_FOREACH(ifp) { + if (found) + break; + memcpy(lreq.ifr_name, ifp-if_xname, + MIN(LINUX_IFNAMSIZ, IFNAMSIZ)); + IFADDR_FOREACH(ifa, ifp) { + sadl = satosdl(ifa-ifa_addr); + /* only return ethernet addresses */ + /* XXX what about FDDI, etc. ? */ + if (sadl-sdl_family != AF_LINK || + sadl-sdl_type != IFT_ETHER) +continue; + if (ifnum--) +/* not the reqested iface */ +continue; + memcpy(lreq.ifr_hwaddr.sa_data, + CLLADDR(sadl), + MIN(sadl-sdl_alen, + sizeof(lreq.ifr_hwaddr.sa_data))); + lreq.ifr_hwaddr.sa_family = +sadl-sdl_family; + error = copyout(lreq, data, sizeof(lreq)); + found = 1; + break; + } } out:
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: maxv Date: Thu Oct 30 16:45:28 UTC 2014 Modified Files: src/sys/compat/linux/common: linux_uselib.c Log Message: Reject non-regular files. Patch from njoly@. To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/sys/compat/linux/common/linux_uselib.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_uselib.c diff -u src/sys/compat/linux/common/linux_uselib.c:1.31 src/sys/compat/linux/common/linux_uselib.c:1.32 --- src/sys/compat/linux/common/linux_uselib.c:1.31 Sun Oct 19 17:33:58 2014 +++ src/sys/compat/linux/common/linux_uselib.c Thu Oct 30 16:45:28 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_uselib.c,v 1.31 2014/10/19 17:33:58 maxv Exp $ */ +/* $NetBSD: linux_uselib.c,v 1.32 2014/10/30 16:45:28 maxv Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_uselib.c,v 1.31 2014/10/19 17:33:58 maxv Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_uselib.c,v 1.32 2014/10/30 16:45:28 maxv Exp $); #include sys/param.h #include sys/systm.h @@ -100,6 +100,11 @@ linux_sys_uselib(struct lwp *l, const st if (error != 0) return error; + if (vp-v_type != VREG) { + error = EINVAL; + goto out; + } + if ((error = vn_rdwr(UIO_READ, vp, (void *) hdr, LINUX_AOUT_HDR_SIZE, 0, UIO_SYSSPACE, IO_NODELOCKED, l-l_cred, rem, NULL))) {
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: maxv Date: Sun Oct 19 17:33:59 UTC 2014 Modified Files: src/sys/compat/linux/common: linux_uselib.c Log Message: Resource leak. Found by my code scanner. Tested by njoly@; ok njoly@ rmind@ on tech-kern@. To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/sys/compat/linux/common/linux_uselib.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_uselib.c diff -u src/sys/compat/linux/common/linux_uselib.c:1.30 src/sys/compat/linux/common/linux_uselib.c:1.31 --- src/sys/compat/linux/common/linux_uselib.c:1.30 Fri Aug 28 01:39:03 2009 +++ src/sys/compat/linux/common/linux_uselib.c Sun Oct 19 17:33:58 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_uselib.c,v 1.30 2009/08/28 01:39:03 dholland Exp $ */ +/* $NetBSD: linux_uselib.c,v 1.31 2014/10/19 17:33:58 maxv Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_uselib.c,v 1.30 2009/08/28 01:39:03 dholland Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_uselib.c,v 1.31 2014/10/19 17:33:58 maxv Exp $); #include sys/param.h #include sys/systm.h @@ -103,17 +103,18 @@ linux_sys_uselib(struct lwp *l, const st if ((error = vn_rdwr(UIO_READ, vp, (void *) hdr, LINUX_AOUT_HDR_SIZE, 0, UIO_SYSSPACE, IO_NODELOCKED, l-l_cred, rem, NULL))) { - vrele(vp); - return error; + goto out; } if (rem != 0) { - vrele(vp); - return ENOEXEC; + error = ENOEXEC; + goto out; } - if (LINUX_N_MACHTYPE(hdr) != LINUX_MID_MACHINE) - return ENOEXEC; + if (LINUX_N_MACHTYPE(hdr) != LINUX_MID_MACHINE) { + error = ENOEXEC; + goto out; + } magic = LINUX_N_MAGIC(hdr); taddr = hdr.a_entry (~(PAGE_SIZE - 1)); @@ -123,7 +124,7 @@ linux_sys_uselib(struct lwp *l, const st error = vn_marktext(vp); if (error) - return (error); + goto out; vcset.evs_cnt = 0; vcset.evs_used = 0; @@ -150,7 +151,7 @@ linux_sys_uselib(struct lwp *l, const st kill_vmcmds(vcset); +out: vrele(vp); - return error; }
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: njoly Date: Wed Jun 25 16:38:53 UTC 2014 Modified Files: src/sys/compat/linux/common: linux_file.c Log Message: Add support for more open flags that have a native equivalent (O_NONBLOCK, O_DIRECT and O_NOFOLLOW). Translate native EFTYPE error (missing on Linux) to expected ELOOP; when opening symlinks with flag O_NOFOLLOW. To generate a diff of this commit: cvs rdiff -u -r1.112 -r1.113 src/sys/compat/linux/common/linux_file.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_file.c diff -u src/sys/compat/linux/common/linux_file.c:1.112 src/sys/compat/linux/common/linux_file.c:1.113 --- src/sys/compat/linux/common/linux_file.c:1.112 Sun Jun 1 13:42:12 2014 +++ src/sys/compat/linux/common/linux_file.c Wed Jun 25 16:38:53 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_file.c,v 1.112 2014/06/01 13:42:12 njoly Exp $ */ +/* $NetBSD: linux_file.c,v 1.113 2014/06/25 16:38:53 njoly Exp $ */ /*- * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_file.c,v 1.112 2014/06/01 13:42:12 njoly Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_file.c,v 1.113 2014/06/25 16:38:53 njoly Exp $); #include sys/param.h #include sys/systm.h @@ -93,15 +93,19 @@ linux_to_bsd_ioflags(int lflags) res |= cvtto_bsd_mask(lflags, LINUX_O_WRONLY, O_WRONLY); res |= cvtto_bsd_mask(lflags, LINUX_O_RDONLY, O_RDONLY); res |= cvtto_bsd_mask(lflags, LINUX_O_RDWR, O_RDWR); + res |= cvtto_bsd_mask(lflags, LINUX_O_CREAT, O_CREAT); res |= cvtto_bsd_mask(lflags, LINUX_O_EXCL, O_EXCL); res |= cvtto_bsd_mask(lflags, LINUX_O_NOCTTY, O_NOCTTY); res |= cvtto_bsd_mask(lflags, LINUX_O_TRUNC, O_TRUNC); + res |= cvtto_bsd_mask(lflags, LINUX_O_APPEND, O_APPEND); + res |= cvtto_bsd_mask(lflags, LINUX_O_NONBLOCK, O_NONBLOCK); res |= cvtto_bsd_mask(lflags, LINUX_O_NDELAY, O_NDELAY); res |= cvtto_bsd_mask(lflags, LINUX_O_SYNC, O_FSYNC); res |= cvtto_bsd_mask(lflags, LINUX_FASYNC, O_ASYNC); - res |= cvtto_bsd_mask(lflags, LINUX_O_APPEND, O_APPEND); + res |= cvtto_bsd_mask(lflags, LINUX_O_DIRECT, O_DIRECT); res |= cvtto_bsd_mask(lflags, LINUX_O_DIRECTORY, O_DIRECTORY); + res |= cvtto_bsd_mask(lflags, LINUX_O_NOFOLLOW, O_NOFOLLOW); res |= cvtto_bsd_mask(lflags, LINUX_O_CLOEXEC, O_CLOEXEC); return res; @@ -115,15 +119,19 @@ bsd_to_linux_ioflags(int bflags) res |= cvtto_linux_mask(bflags, O_WRONLY, LINUX_O_WRONLY); res |= cvtto_linux_mask(bflags, O_RDONLY, LINUX_O_RDONLY); res |= cvtto_linux_mask(bflags, O_RDWR, LINUX_O_RDWR); + res |= cvtto_linux_mask(bflags, O_CREAT, LINUX_O_CREAT); res |= cvtto_linux_mask(bflags, O_EXCL, LINUX_O_EXCL); res |= cvtto_linux_mask(bflags, O_NOCTTY, LINUX_O_NOCTTY); res |= cvtto_linux_mask(bflags, O_TRUNC, LINUX_O_TRUNC); + res |= cvtto_linux_mask(bflags, O_APPEND, LINUX_O_APPEND); + res |= cvtto_linux_mask(bflags, O_NONBLOCK, LINUX_O_NONBLOCK); res |= cvtto_linux_mask(bflags, O_NDELAY, LINUX_O_NDELAY); res |= cvtto_linux_mask(bflags, O_FSYNC, LINUX_O_SYNC); res |= cvtto_linux_mask(bflags, O_ASYNC, LINUX_FASYNC); - res |= cvtto_linux_mask(bflags, O_APPEND, LINUX_O_APPEND); + res |= cvtto_linux_mask(bflags, O_DIRECT, LINUX_O_DIRECT); res |= cvtto_linux_mask(bflags, O_DIRECTORY, LINUX_O_DIRECTORY); + res |= cvtto_linux_mask(bflags, O_NOFOLLOW, LINUX_O_NOFOLLOW); res |= cvtto_linux_mask(bflags, O_CLOEXEC, LINUX_O_CLOEXEC); return res; @@ -204,7 +212,7 @@ linux_sys_open(struct lwp *l, const stru SCARG(boa, mode) = SCARG(uap, mode); if ((error = sys_open(l, boa, retval))) - return error; + return (error == EFTYPE) ? ELOOP : error; linux_open_ctty(l, fl, *retval); return 0; @@ -230,7 +238,7 @@ linux_sys_openat(struct lwp *l, const st SCARG(boa, mode) = SCARG(uap, mode); if ((error = sys_openat(l, boa, retval))) - return error; + return (error == EFTYPE) ? ELOOP : error; linux_open_ctty(l, fl, *retval); return 0;
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: njoly Date: Fri May 23 12:28:51 UTC 2014 Modified Files: src/sys/compat/linux/common: linux_socket.c Log Message: Add a funtion that translate socket type value from Linux to NetBSD. Use it for socket and socketpair syscalls. To generate a diff of this commit: cvs rdiff -u -r1.118 -r1.119 src/sys/compat/linux/common/linux_socket.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_socket.c diff -u src/sys/compat/linux/common/linux_socket.c:1.118 src/sys/compat/linux/common/linux_socket.c:1.119 --- src/sys/compat/linux/common/linux_socket.c:1.118 Sat May 17 21:26:20 2014 +++ src/sys/compat/linux/common/linux_socket.c Fri May 23 12:28:51 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_socket.c,v 1.118 2014/05/17 21:26:20 rmind Exp $ */ +/* $NetBSD: linux_socket.c,v 1.119 2014/05/23 12:28:51 njoly Exp $ */ /*- * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_socket.c,v 1.118 2014/05/17 21:26:20 rmind Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_socket.c,v 1.119 2014/05/23 12:28:51 njoly Exp $); #if defined(_KERNEL_OPT) #include opt_inet.h @@ -70,7 +70,6 @@ __KERNEL_RCSID(0, $NetBSD: linux_socket #include sys/kauth.h #include sys/syscallargs.h #include sys/ktrace.h -#include sys/fcntl.h #include lib/libkern/libkern.h @@ -111,6 +110,7 @@ __KERNEL_RCSID(0, $NetBSD: linux_socket static int linux_to_bsd_domain(int); static int bsd_to_linux_domain(int); +static int linux_to_bsd_type(int); int linux_to_bsd_sopt_level(int); int linux_to_bsd_so_sockopt(int); int linux_to_bsd_ip_sockopt(int); @@ -238,6 +238,27 @@ bsd_to_linux_domain(int bdom) } static int +linux_to_bsd_type(int ltype) +{ + int type, flags; + + /* Real types are identical between Linux and NetBSD */ + type = ltype LINUX_SOCK_TYPE_MASK; + + /* But flags are not .. */ + flags = ltype ~LINUX_SOCK_TYPE_MASK; + if (flags ~(LINUX_SOCK_CLOEXEC|LINUX_SOCK_NONBLOCK)) + return -1; + + if (flags LINUX_SOCK_CLOEXEC) + type |= SOCK_CLOEXEC; + if (flags LINUX_SOCK_NONBLOCK) + type |= SOCK_NONBLOCK; + + return type; +} + +static int linux_to_bsd_msg_flags(int lflag) { int i, lfl, bfl; @@ -300,16 +321,16 @@ linux_sys_socket(struct lwp *l, const st syscallarg(int) protocol; } */ struct sys___socket30_args bsa; - struct sys_fcntl_args fsa; - register_t fretval[2]; - int error, flags; + int error; SCARG(bsa, protocol) = SCARG(uap, protocol); - SCARG(bsa, type) = SCARG(uap, type) LINUX_SOCK_TYPE_MASK; SCARG(bsa, domain) = linux_to_bsd_domain(SCARG(uap, domain)); if (SCARG(bsa, domain) == -1) return EINVAL; + SCARG(bsa, type) = linux_to_bsd_type(SCARG(uap, type)); + if (SCARG(bsa, type) == -1) + return EINVAL; /* * Apparently linux uses this to talk to ISDN sockets. If we fail * now programs seems to handle it, but if we don't we are going @@ -317,36 +338,8 @@ linux_sys_socket(struct lwp *l, const st */ if (SCARG(bsa, domain) == AF_ROUTE SCARG(bsa, type) == SOCK_RAW) return ENOTSUP; - flags = SCARG(uap, type) ~LINUX_SOCK_TYPE_MASK; - if (flags ~(LINUX_SOCK_CLOEXEC | LINUX_SOCK_NONBLOCK)) - return EINVAL; error = sys___socket30(l, bsa, retval); - /* - * Linux overloads the type parameter to include some - * fcntl flags to be set on the file descriptor. - * Process those if creating the socket succeeded. - */ - - if (!error flags LINUX_SOCK_CLOEXEC) { - SCARG(fsa, fd) = *retval; - SCARG(fsa, cmd) = F_SETFD; - SCARG(fsa, arg) = (void *)(uintptr_t)FD_CLOEXEC; - (void) sys_fcntl(l, fsa, fretval); - } - if (!error flags LINUX_SOCK_NONBLOCK) { - SCARG(fsa, fd) = *retval; - SCARG(fsa, cmd) = F_SETFL; - SCARG(fsa, arg) = (void *)(uintptr_t)O_NONBLOCK; - error = sys_fcntl(l, fsa, fretval); - if (error) { - struct sys_close_args csa; - - SCARG(csa, fd) = *retval; - (void) sys_close(l, csa, fretval); - } - } - #ifdef INET6 /* * Linux AF_INET6 socket has IPV6_V6ONLY setsockopt set to 0 by @@ -385,7 +378,9 @@ linux_sys_socketpair(struct lwp *l, cons SCARG(bsa, domain) = linux_to_bsd_domain(SCARG(uap, domain)); if (SCARG(bsa, domain) == -1) return EINVAL; - SCARG(bsa, type) = SCARG(uap, type); + SCARG(bsa, type) = linux_to_bsd_type(SCARG(uap, type)); + if (SCARG(bsa, type) == -1) + return EINVAL; SCARG(bsa, protocol) = SCARG(uap, protocol); SCARG(bsa, rsv) = SCARG(uap, rsv);
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: njoly Date: Tue May 20 17:31:18 UTC 2014 Modified Files: src/sys/compat/linux/common: linux_uid16.c Log Message: Fix signed vs. unsigned comparison in getgroups16() syscall. Negative gisetsize values now fail with EINVAL as expected. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/compat/linux/common/linux_uid16.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_uid16.c diff -u src/sys/compat/linux/common/linux_uid16.c:1.3 src/sys/compat/linux/common/linux_uid16.c:1.4 --- src/sys/compat/linux/common/linux_uid16.c:1.3 Tue May 20 15:48:24 2008 +++ src/sys/compat/linux/common/linux_uid16.c Tue May 20 17:31:18 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_uid16.c,v 1.3 2008/05/20 15:48:24 njoly Exp $ */ +/* $NetBSD: linux_uid16.c,v 1.4 2014/05/20 17:31:18 njoly Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_uid16.c,v 1.3 2008/05/20 15:48:24 njoly Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_uid16.c,v 1.4 2014/05/20 17:31:18 njoly Exp $); #include sys/param.h #include sys/proc.h @@ -241,7 +241,7 @@ linux_sys_getgroups16(struct lwp *l, con *retval = ngrps; if (SCARG(uap, gidsetsize) == 0) return 0; - if (SCARG(uap, gidsetsize) ngrps) + if (SCARG(uap, gidsetsize) (int)ngrps) return EINVAL; gidset = SCARG(uap, gidset);
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: njoly Date: Tue May 6 13:21:50 UTC 2014 Modified Files: src/sys/compat/linux/common: linux_file.c Log Message: linux_off_t - off_t in pwrite() syscall args comment. To generate a diff of this commit: cvs rdiff -u -r1.109 -r1.110 src/sys/compat/linux/common/linux_file.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_file.c diff -u src/sys/compat/linux/common/linux_file.c:1.109 src/sys/compat/linux/common/linux_file.c:1.110 --- src/sys/compat/linux/common/linux_file.c:1.109 Sun May 4 10:08:53 2014 +++ src/sys/compat/linux/common/linux_file.c Tue May 6 13:21:50 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_file.c,v 1.109 2014/05/04 10:08:53 njoly Exp $ */ +/* $NetBSD: linux_file.c,v 1.110 2014/05/06 13:21:50 njoly Exp $ */ /*- * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_file.c,v 1.109 2014/05/04 10:08:53 njoly Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_file.c,v 1.110 2014/05/06 13:21:50 njoly Exp $); #include sys/param.h #include sys/systm.h @@ -762,7 +762,7 @@ linux_sys_pwrite(struct lwp *l, const st syscallarg(int) fd; syscallarg(void *) buf; syscallarg(size_t) nbyte; - syscallarg(linux_off_t) offset; + syscallarg(off_t) offset; } */ struct sys_pwrite_args pra;
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: njoly Date: Tue May 6 18:17:22 UTC 2014 Modified Files: src/sys/compat/linux/common: linux_fadvise64_64.c Log Message: Fix cp error for the length argument in fadvise64_64. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/compat/linux/common/linux_fadvise64_64.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_fadvise64_64.c diff -u src/sys/compat/linux/common/linux_fadvise64_64.c:1.1 src/sys/compat/linux/common/linux_fadvise64_64.c:1.2 --- src/sys/compat/linux/common/linux_fadvise64_64.c:1.1 Mon May 30 17:50:32 2011 +++ src/sys/compat/linux/common/linux_fadvise64_64.c Tue May 6 18:17:22 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_fadvise64_64.c,v 1.1 2011/05/30 17:50:32 alnsn Exp $ */ +/* $NetBSD: linux_fadvise64_64.c,v 1.2 2014/05/06 18:17:22 njoly Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -27,7 +27,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_fadvise64_64.c,v 1.1 2011/05/30 17:50:32 alnsn Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_fadvise64_64.c,v 1.2 2014/05/06 18:17:22 njoly Exp $); #include sys/param.h #include sys/types.h @@ -73,5 +73,5 @@ linux_sys_fadvise64_64(struct lwp *l, } */ return do_posix_fadvise(SCARG(uap, fd), SCARG(uap, offset), - SCARG(uap, offset), linux_to_bsd_posix_fadv(SCARG(uap, advice))); + SCARG(uap, len), linux_to_bsd_posix_fadv(SCARG(uap, advice))); }
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: maxv Date: Tue Feb 11 16:00:13 UTC 2014 Modified Files: src/sys/compat/linux/common: linux_futex.c Log Message: Fix uninitialized variable. Harmless: it does not change the behavior at all. ok rmind@ christos@ To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/sys/compat/linux/common/linux_futex.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_futex.c diff -u src/sys/compat/linux/common/linux_futex.c:1.32 src/sys/compat/linux/common/linux_futex.c:1.33 --- src/sys/compat/linux/common/linux_futex.c:1.32 Thu Oct 17 21:08:16 2013 +++ src/sys/compat/linux/common/linux_futex.c Tue Feb 11 16:00:13 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_futex.c,v 1.32 2013/10/17 21:08:16 christos Exp $ */ +/* $NetBSD: linux_futex.c,v 1.33 2014/02/11 16:00:13 maxv Exp $ */ /*- * Copyright (c) 2005 Emmanuel Dreyfus, all rights reserved. @@ -32,7 +32,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(1, $NetBSD: linux_futex.c,v 1.32 2013/10/17 21:08:16 christos Exp $); +__KERNEL_RCSID(1, $NetBSD: linux_futex.c,v 1.33 2014/02/11 16:00:13 maxv Exp $); #include sys/param.h #include sys/time.h @@ -610,7 +610,7 @@ futex_atomic_op(lwp_t *l, int encoded_op } error = ucas_int(uaddr, cval, nval, oldval); - if (oldval == cval || error) { + if (error || oldval == cval) { break; } cval = oldval;
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: njoly Date: Mon Jan 27 13:23:33 UTC 2014 Modified Files: src/sys/compat/linux/common: linux_socket.c Log Message: Add SO_SNDLOWAT, SO_RCVLOWAT and SO_ACCEPTCONN support for socket options. To generate a diff of this commit: cvs rdiff -u -r1.115 -r1.116 src/sys/compat/linux/common/linux_socket.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_socket.c diff -u src/sys/compat/linux/common/linux_socket.c:1.115 src/sys/compat/linux/common/linux_socket.c:1.116 --- src/sys/compat/linux/common/linux_socket.c:1.115 Fri Jan 11 19:01:36 2013 +++ src/sys/compat/linux/common/linux_socket.c Mon Jan 27 13:23:33 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_socket.c,v 1.115 2013/01/11 19:01:36 christos Exp $ */ +/* $NetBSD: linux_socket.c,v 1.116 2014/01/27 13:23:33 njoly Exp $ */ /*- * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_socket.c,v 1.115 2013/01/11 19:01:36 christos Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_socket.c,v 1.116 2014/01/27 13:23:33 njoly Exp $); #if defined(_KERNEL_OPT) #include opt_inet.h @@ -873,12 +873,18 @@ linux_to_bsd_so_sockopt(int lopt) return SO_SNDBUF; case LINUX_SO_RCVBUF: return SO_RCVBUF; + case LINUX_SO_SNDLOWAT: + return SO_SNDLOWAT; + case LINUX_SO_RCVLOWAT: + return SO_RCVLOWAT; case LINUX_SO_KEEPALIVE: return SO_KEEPALIVE; case LINUX_SO_OOBINLINE: return SO_OOBINLINE; case LINUX_SO_LINGER: return SO_LINGER; + case LINUX_SO_ACCEPTCONN: + return SO_ACCEPTCONN; case LINUX_SO_PRIORITY: case LINUX_SO_NO_CHECK: default:
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: njoly Date: Mon Jan 27 19:19:15 UTC 2014 Modified Files: src/sys/compat/linux/common: linux_socket.c linux_socket.h Log Message: Add basic IPV6 level socket options support (IPV6_V6ONLY). To generate a diff of this commit: cvs rdiff -u -r1.116 -r1.117 src/sys/compat/linux/common/linux_socket.c cvs rdiff -u -r1.21 -r1.22 src/sys/compat/linux/common/linux_socket.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_socket.c diff -u src/sys/compat/linux/common/linux_socket.c:1.116 src/sys/compat/linux/common/linux_socket.c:1.117 --- src/sys/compat/linux/common/linux_socket.c:1.116 Mon Jan 27 13:23:33 2014 +++ src/sys/compat/linux/common/linux_socket.c Mon Jan 27 19:19:15 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_socket.c,v 1.116 2014/01/27 13:23:33 njoly Exp $ */ +/* $NetBSD: linux_socket.c,v 1.117 2014/01/27 19:19:15 njoly Exp $ */ /*- * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_socket.c,v 1.116 2014/01/27 13:23:33 njoly Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_socket.c,v 1.117 2014/01/27 19:19:15 njoly Exp $); #if defined(_KERNEL_OPT) #include opt_inet.h @@ -114,6 +114,7 @@ static int bsd_to_linux_domain(int); int linux_to_bsd_sopt_level(int); int linux_to_bsd_so_sockopt(int); int linux_to_bsd_ip_sockopt(int); +int linux_to_bsd_ipv6_sockopt(int); int linux_to_bsd_tcp_sockopt(int); int linux_to_bsd_udp_sockopt(int); int linux_getifname(struct lwp *, register_t *, void *); @@ -833,6 +834,10 @@ linux_to_bsd_sopt_level(int llevel) return SOL_SOCKET; case LINUX_SOL_IP: return IPPROTO_IP; +#ifdef INET6 + case LINUX_SOL_IPV6: + return IPPROTO_IPV6; +#endif case LINUX_SOL_TCP: return IPPROTO_TCP; case LINUX_SOL_UDP: @@ -922,6 +927,23 @@ linux_to_bsd_ip_sockopt(int lopt) } /* + * Convert Linux IPV6 level socket option number to NetBSD values. + */ +#ifdef INET6 +int +linux_to_bsd_ipv6_sockopt(int lopt) +{ + + switch (lopt) { + case LINUX_IPV6_V6ONLY: + return IPV6_V6ONLY; + default: + return -1; + } +} +#endif + +/* * Convert Linux TCP level socket option number to NetBSD values. */ int @@ -1000,6 +1022,11 @@ linux_sys_setsockopt(struct lwp *l, cons case IPPROTO_IP: name = linux_to_bsd_ip_sockopt(SCARG(uap, optname)); break; +#ifdef INET6 + case IPPROTO_IPV6: + name = linux_to_bsd_ipv6_sockopt(SCARG(uap, optname)); + break; +#endif case IPPROTO_TCP: name = linux_to_bsd_tcp_sockopt(SCARG(uap, optname)); break; @@ -1045,6 +1072,11 @@ linux_sys_getsockopt(struct lwp *l, cons case IPPROTO_IP: name = linux_to_bsd_ip_sockopt(SCARG(uap, optname)); break; +#ifdef INET6 + case IPPROTO_IPV6: + name = linux_to_bsd_ipv6_sockopt(SCARG(uap, optname)); + break; +#endif case IPPROTO_TCP: name = linux_to_bsd_tcp_sockopt(SCARG(uap, optname)); break; Index: src/sys/compat/linux/common/linux_socket.h diff -u src/sys/compat/linux/common/linux_socket.h:1.21 src/sys/compat/linux/common/linux_socket.h:1.22 --- src/sys/compat/linux/common/linux_socket.h:1.21 Thu Jun 30 20:09:39 2011 +++ src/sys/compat/linux/common/linux_socket.h Mon Jan 27 19:19:15 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_socket.h,v 1.21 2011/06/30 20:09:39 wiz Exp $ */ +/* $NetBSD: linux_socket.h,v 1.22 2014/01/27 19:19:15 njoly Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -78,8 +78,8 @@ #define LINUX_SOL_IP 0 #define LINUX_SOL_TCP 6 #define LINUX_SOL_UDP 17 -/* Unused for now: */ #define LINUX_SOL_IPV6 41 +/* Unused for now: */ #define LINUX_SOL_ICMPV6 58 #define LINUX_SOL_RAW 255 #define LINUX_SOL_IPX 256 @@ -111,6 +111,12 @@ #define LINUX_IP_DROP_MEMBERSHIP 36 /* + * Options for [gs]etsockopt(2), IPV6 level. + */ + +#define LINUX_IPV6_V6ONLY 26 + +/* * Options for [gs]etsockopt(2), TCP level. */
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: njoly Date: Thu Jan 23 19:18:08 UTC 2014 Modified Files: src/sys/compat/linux/common: linux_sched.c Log Message: Fix inverted pid/lid arguments in do_sched_{get,set}param calls. To generate a diff of this commit: cvs rdiff -u -r1.65 -r1.66 src/sys/compat/linux/common/linux_sched.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_sched.c diff -u src/sys/compat/linux/common/linux_sched.c:1.65 src/sys/compat/linux/common/linux_sched.c:1.66 --- src/sys/compat/linux/common/linux_sched.c:1.65 Thu Aug 18 02:26:38 2011 +++ src/sys/compat/linux/common/linux_sched.c Thu Jan 23 19:18:08 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_sched.c,v 1.65 2011/08/18 02:26:38 christos Exp $ */ +/* $NetBSD: linux_sched.c,v 1.66 2014/01/23 19:18:08 njoly Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_sched.c,v 1.65 2011/08/18 02:26:38 christos Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_sched.c,v 1.66 2014/01/23 19:18:08 njoly Exp $); #include sys/param.h #include sys/mount.h @@ -418,7 +418,7 @@ linux_sys_sched_setparam(struct lwp *l, goto out; /* We need the current policy in Linux terms. */ - error = do_sched_getparam(0, SCARG(uap, pid), policy, NULL); + error = do_sched_getparam(SCARG(uap, pid), 0, policy, NULL); if (error) goto out; error = sched_native2linux(policy, NULL, policy, NULL); @@ -429,7 +429,7 @@ linux_sys_sched_setparam(struct lwp *l, if (error) goto out; - error = do_sched_setparam(0, SCARG(uap, pid), policy, sp); + error = do_sched_setparam(SCARG(uap, pid), 0, policy, sp); if (error) goto out; @@ -453,7 +453,7 @@ linux_sys_sched_getparam(struct lwp *l, goto out; } - error = do_sched_getparam(0, SCARG(uap, pid), policy, sp); + error = do_sched_getparam(SCARG(uap, pid), 0, policy, sp); if (error) goto out; DPRINTF((%s: native: policy %d, priority %d\n, @@ -502,7 +502,7 @@ linux_sys_sched_setscheduler(struct lwp DPRINTF((%s: native: policy %d, priority %d\n, __func__, policy, sp.sched_priority)); - error = do_sched_setparam(0, SCARG(uap, pid), policy, sp); + error = do_sched_setparam(SCARG(uap, pid), 0, policy, sp); if (error) goto out; @@ -520,7 +520,7 @@ linux_sys_sched_getscheduler(struct lwp *retval = -1; - error = do_sched_getparam(0, SCARG(uap, pid), policy, NULL); + error = do_sched_getparam(SCARG(uap, pid), 0, policy, NULL); if (error) goto out;
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: njoly Date: Fri Dec 27 15:10:53 UTC 2013 Modified Files: src/sys/compat/linux/common: linux_ipccall.c linux_ipccall.h linux_socketcall.c linux_socketcall.h Log Message: Rename ipcall/socketcall specific defines to avoid conflict with syscalls definitions. No functional changes. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/sys/compat/linux/common/linux_ipccall.c cvs rdiff -u -r1.15 -r1.16 src/sys/compat/linux/common/linux_ipccall.h cvs rdiff -u -r1.42 -r1.43 src/sys/compat/linux/common/linux_socketcall.c cvs rdiff -u -r1.16 -r1.17 src/sys/compat/linux/common/linux_socketcall.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_ipccall.c diff -u src/sys/compat/linux/common/linux_ipccall.c:1.32 src/sys/compat/linux/common/linux_ipccall.c:1.33 --- src/sys/compat/linux/common/linux_ipccall.c:1.32 Tue Aug 18 11:22:09 2009 +++ src/sys/compat/linux/common/linux_ipccall.c Fri Dec 27 15:10:53 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_ipccall.c,v 1.32 2009/08/18 11:22:09 drochner Exp $ */ +/* $NetBSD: linux_ipccall.c,v 1.33 2013/12/27 15:10:53 njoly Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_ipccall.c,v 1.32 2009/08/18 11:22:09 drochner Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_ipccall.c,v 1.33 2013/12/27 15:10:53 njoly Exp $); #if defined(_KERNEL_OPT) #include opt_sysv.h @@ -91,11 +91,11 @@ linux_sys_ipc(struct lwp *l, const struc switch (SCARG(uap, what)) { #ifdef SYSVSEM - case LINUX_SYS_semop: + case LINUX_SYS_SEMOP: return linux_semop(l, uap, retval); - case LINUX_SYS_semget: + case LINUX_SYS_SEMGET: return linux_semget(l, uap, retval); - case LINUX_SYS_semctl: { + case LINUX_SYS_SEMCTL: { struct linux_sys_semctl_args bsa; union linux_semun arg; int error; @@ -112,13 +112,13 @@ linux_sys_ipc(struct lwp *l, const struc } #endif #ifdef SYSVMSG - case LINUX_SYS_msgsnd: + case LINUX_SYS_MSGSND: return linux_msgsnd(l, uap, retval); - case LINUX_SYS_msgrcv: + case LINUX_SYS_MSGRCV: return linux_msgrcv(l, uap, retval); - case LINUX_SYS_msgget: + case LINUX_SYS_MSGGET: return linux_msgget(l, uap, retval); - case LINUX_SYS_msgctl: { + case LINUX_SYS_MSGCTL: { struct linux_sys_msgctl_args bsa; SCARG(bsa, msqid) = SCARG(uap, a1); @@ -129,7 +129,7 @@ linux_sys_ipc(struct lwp *l, const struc } #endif #ifdef SYSVSHM - case LINUX_SYS_shmat: { + case LINUX_SYS_SHMAT: { struct linux_sys_shmat_args bsa; SCARG(bsa, shmid) = SCARG(uap, a1); @@ -140,11 +140,11 @@ linux_sys_ipc(struct lwp *l, const struc return linux_sys_shmat(l, bsa, retval); } - case LINUX_SYS_shmdt: + case LINUX_SYS_SHMDT: return linux_shmdt(l, uap, retval); - case LINUX_SYS_shmget: + case LINUX_SYS_SHMGET: return linux_shmget(l, uap, retval); - case LINUX_SYS_shmctl: { + case LINUX_SYS_SHMCTL: { struct linux_sys_shmctl_args bsa; SCARG(bsa, shmid) = SCARG(uap, a1); Index: src/sys/compat/linux/common/linux_ipccall.h diff -u src/sys/compat/linux/common/linux_ipccall.h:1.15 src/sys/compat/linux/common/linux_ipccall.h:1.16 --- src/sys/compat/linux/common/linux_ipccall.h:1.15 Tue Aug 18 11:22:09 2009 +++ src/sys/compat/linux/common/linux_ipccall.h Fri Dec 27 15:10:53 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_ipccall.h,v 1.15 2009/08/18 11:22:09 drochner Exp $ */ +/* $NetBSD: linux_ipccall.h,v 1.16 2013/12/27 15:10:53 njoly Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -45,17 +45,17 @@ * linux_ipc() call, and based on which the actual system calls * are made. */ -#define LINUX_SYS_semop 1 -#define LINUX_SYS_semget 2 -#define LINUX_SYS_semctl 3 -#define LINUX_SYS_msgsnd 11 -#define LINUX_SYS_msgrcv 12 -#define LINUX_SYS_msgget 13 -#define LINUX_SYS_msgctl 14 -#define LINUX_SYS_shmat 21 -#define LINUX_SYS_shmdt 22 -#define LINUX_SYS_shmget 23 -#define LINUX_SYS_shmctl 24 +#define LINUX_SYS_SEMOP 1 +#define LINUX_SYS_SEMGET 2 +#define LINUX_SYS_SEMCTL 3 +#define LINUX_SYS_MSGSND 11 +#define LINUX_SYS_MSGRCV 12 +#define LINUX_SYS_MSGGET 13 +#define LINUX_SYS_MSGCTL 14 +#define LINUX_SYS_SHMAT 21 +#define LINUX_SYS_SHMDT 22 +#define LINUX_SYS_SHMGET 23 +#define LINUX_SYS_SHMCTL 24 # ifdef SYSVSEM Index: src/sys/compat/linux/common/linux_socketcall.c diff -u src/sys/compat/linux/common/linux_socketcall.c:1.42 src/sys/compat/linux/common/linux_socketcall.c:1.43 --- src/sys/compat/linux/common/linux_socketcall.c:1.42 Fri Jun 22 08:47:47 2012 +++ src/sys/compat/linux/common/linux_socketcall.c Fri Dec 27 15:10:53 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_socketcall.c,v 1.42 2012/06/22 08:47:47 martin Exp $ */ +/* $NetBSD: linux_socketcall.c,v 1.43 2013/12/27 15:10:53 njoly Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: njoly Date: Fri Dec 27 16:58:50 UTC 2013 Modified Files: src/sys/compat/linux/common: linux_termios.c Log Message: Add easy parts (TCOOFF/TCOON) of the TCXONC linux termios ioctl. To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/sys/compat/linux/common/linux_termios.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_termios.c diff -u src/sys/compat/linux/common/linux_termios.c:1.36 src/sys/compat/linux/common/linux_termios.c:1.37 --- src/sys/compat/linux/common/linux_termios.c:1.36 Fri Jul 4 10:13:52 2008 +++ src/sys/compat/linux/common/linux_termios.c Fri Dec 27 16:58:50 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_termios.c,v 1.36 2008/07/04 10:13:52 matthias Exp $ */ +/* $NetBSD: linux_termios.c,v 1.37 2013/12/27 16:58:50 njoly Exp $ */ /*- * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_termios.c,v 1.36 2008/07/04 10:13:52 matthias Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_termios.c,v 1.37 2013/12/27 16:58:50 njoly Exp $); #if defined(_KERNEL_OPT) #include opt_ptm.h @@ -348,6 +348,22 @@ linux_ioctl_termios(struct lwp *l, const DPRINTF((TIOCSPTLCK %d\n, idat)); return 0; #endif + case LINUX_TCXONC: + idat = (u_long)SCARG(uap, data); + switch (idat) { + case LINUX_TCOOFF: + SCARG(ia, com) = TIOCSTOP; + break; + case LINUX_TCOON: + SCARG(ia, com) = TIOCSTART; + break; + case LINUX_TCIOFF: + case LINUX_TCION: + default: + error = EINVAL; + goto out; + } + break; default: error = EINVAL; goto out;
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: njoly Date: Sun Dec 8 14:59:43 UTC 2013 Modified Files: src/sys/compat/linux/common: linux_file.c Log Message: Add missing syscall argument fd in comment. To generate a diff of this commit: cvs rdiff -u -r1.106 -r1.107 src/sys/compat/linux/common/linux_file.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_file.c diff -u src/sys/compat/linux/common/linux_file.c:1.106 src/sys/compat/linux/common/linux_file.c:1.107 --- src/sys/compat/linux/common/linux_file.c:1.106 Mon Nov 18 01:32:52 2013 +++ src/sys/compat/linux/common/linux_file.c Sun Dec 8 14:59:43 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_file.c,v 1.106 2013/11/18 01:32:52 chs Exp $ */ +/* $NetBSD: linux_file.c,v 1.107 2013/12/08 14:59:43 njoly Exp $ */ /*- * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_file.c,v 1.106 2013/11/18 01:32:52 chs Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_file.c,v 1.107 2013/12/08 14:59:43 njoly Exp $); #include sys/param.h #include sys/systm.h @@ -215,6 +215,7 @@ int linux_sys_openat(struct lwp *l, const struct linux_sys_openat_args *uap, register_t *retval) { /* { + syscallarg(int) fd; syscallarg(const char *) path; syscallarg(int) flags; syscallarg(int) mode;
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: slp Date: Sun Nov 10 12:07:52 UTC 2013 Modified Files: src/sys/compat/linux/common: linux_misc.c Log Message: On linux_sys_getdents, insert d_type at the end of each record. Fixes PR kern/47806. To generate a diff of this commit: cvs rdiff -u -r1.226 -r1.227 src/sys/compat/linux/common/linux_misc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_misc.c diff -u src/sys/compat/linux/common/linux_misc.c:1.226 src/sys/compat/linux/common/linux_misc.c:1.227 --- src/sys/compat/linux/common/linux_misc.c:1.226 Tue Sep 24 13:27:50 2013 +++ src/sys/compat/linux/common/linux_misc.c Sun Nov 10 12:07:52 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_misc.c,v 1.226 2013/09/24 13:27:50 njoly Exp $ */ +/* $NetBSD: linux_misc.c,v 1.227 2013/11/10 12:07:52 slp Exp $ */ /*- * Copyright (c) 1995, 1998, 1999, 2008 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_misc.c,v 1.226 2013/09/24 13:27:50 njoly Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_misc.c,v 1.227 2013/11/10 12:07:52 slp Exp $); #include sys/param.h #include sys/systm.h @@ -784,9 +784,10 @@ again: } idb.d_off = (linux_off_t)off; idb.d_reclen = (u_short)linux_reclen; + /* Linux puts d_type at the end of each record */ + *((char *)idb + idb.d_reclen - 1) = bdp-d_type; } strcpy(idb.d_name, bdp-d_name); - idb.d_name[strlen(idb.d_name) + 1] = bdp-d_type; if ((error = copyout((void *)idb, outp, linux_reclen))) goto out; /* advance past this real entry */
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: christos Date: Thu Oct 17 21:08:16 UTC 2013 Modified Files: src/sys/compat/linux/common: linux_futex.c Log Message: remove unused variable To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/sys/compat/linux/common/linux_futex.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_futex.c diff -u src/sys/compat/linux/common/linux_futex.c:1.31 src/sys/compat/linux/common/linux_futex.c:1.32 --- src/sys/compat/linux/common/linux_futex.c:1.31 Thu Jul 18 13:31:02 2013 +++ src/sys/compat/linux/common/linux_futex.c Thu Oct 17 17:08:16 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_futex.c,v 1.31 2013/07/18 17:31:02 njoly Exp $ */ +/* $NetBSD: linux_futex.c,v 1.32 2013/10/17 21:08:16 christos Exp $ */ /*- * Copyright (c) 2005 Emmanuel Dreyfus, all rights reserved. @@ -32,7 +32,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(1, $NetBSD: linux_futex.c,v 1.31 2013/07/18 17:31:02 njoly Exp $); +__KERNEL_RCSID(1, $NetBSD: linux_futex.c,v 1.32 2013/10/17 21:08:16 christos Exp $); #include sys/param.h #include sys/time.h @@ -741,10 +741,8 @@ static int fetch_robust_entry(struct lwp *l, struct linux_robust_list **entry, struct linux_robust_list **head, int *pi) { - struct linux_emuldata *led; unsigned long uentry; - led = l-l_emuldata; #ifdef __arch64__ if (l-l_proc-p_flag PK_32) { uint32_t u32;
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: pooka Date: Sun Aug 11 09:07:15 UTC 2013 Modified Files: src/sys/compat/linux/common: linux_misc.c Log Message: Allow to build in envs without USRSTACK (namely, rump kernels on powerpc). TODO: all of the m*() calls are by definition incompatible with rump kernels; including them is no great damage, but they're not useful either. To generate a diff of this commit: cvs rdiff -u -r1.223 -r1.224 src/sys/compat/linux/common/linux_misc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_misc.c diff -u src/sys/compat/linux/common/linux_misc.c:1.223 src/sys/compat/linux/common/linux_misc.c:1.224 --- src/sys/compat/linux/common/linux_misc.c:1.223 Mon Apr 15 19:24:04 2013 +++ src/sys/compat/linux/common/linux_misc.c Sun Aug 11 09:07:15 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_misc.c,v 1.223 2013/04/15 19:24:04 christos Exp $ */ +/* $NetBSD: linux_misc.c,v 1.224 2013/08/11 09:07:15 pooka Exp $ */ /*- * Copyright (c) 1995, 1998, 1999, 2008 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_misc.c,v 1.223 2013/04/15 19:24:04 christos Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_misc.c,v 1.224 2013/08/11 09:07:15 pooka Exp $); #include sys/param.h #include sys/systm.h @@ -539,6 +539,7 @@ done: return error; } +#ifdef USRSTACK int linux_sys_mprotect(struct lwp *l, const struct linux_sys_mprotect_args *uap, register_t *retval) { @@ -604,6 +605,7 @@ linux_sys_mprotect(struct lwp *l, const vm_map_unlock(map); return uvm_map_protect(map, start, end, prot, FALSE); } +#endif /* USRSTACK */ /* * This code is partly stolen from src/lib/libc/compat-43/times.c
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: njoly Date: Thu Jul 18 17:31:02 UTC 2013 Modified Files: src/sys/compat/linux/common: linux_futex.c Log Message: Do not make FUTEX_WAIT wait indefinitely for an invalid timeout (tv_nsec = -1). To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/sys/compat/linux/common/linux_futex.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_futex.c diff -u src/sys/compat/linux/common/linux_futex.c:1.30 src/sys/compat/linux/common/linux_futex.c:1.31 --- src/sys/compat/linux/common/linux_futex.c:1.30 Wed Apr 17 14:39:40 2013 +++ src/sys/compat/linux/common/linux_futex.c Thu Jul 18 17:31:02 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_futex.c,v 1.30 2013/04/17 14:39:40 christos Exp $ */ +/* $NetBSD: linux_futex.c,v 1.31 2013/07/18 17:31:02 njoly Exp $ */ /*- * Copyright (c) 2005 Emmanuel Dreyfus, all rights reserved. @@ -32,7 +32,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(1, $NetBSD: linux_futex.c,v 1.30 2013/04/17 14:39:40 christos Exp $); +__KERNEL_RCSID(1, $NetBSD: linux_futex.c,v 1.31 2013/07/18 17:31:02 njoly Exp $); #include sys/param.h #include sys/time.h @@ -195,6 +195,8 @@ linux_do_futex(struct lwp *l, const stru /*FALLTHROUGH*/ case LINUX_FUTEX_WAIT_BITSET: if ((error = ts2timo(clk, 0, ts, tout, NULL)) != 0) { + if (error != ETIMEDOUT) +return error; /* * If the user process requests a non null timeout, * make sure we do not turn it into an infinite @@ -203,7 +205,7 @@ linux_do_futex(struct lwp *l, const stru * We use a minimal timeout of 1/hz. Maybe it would make * sense to just return ETIMEDOUT without sleeping. */ - if (error == ETIMEDOUT SCARG(uap, timeout) != NULL) + if (SCARG(uap, timeout) != NULL) tout = 1; else tout = 0;
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: stacktic Date: Sat Jun 8 12:50:32 UTC 2013 Modified Files: src/sys/compat/linux/common: linux_ioctl.h Log Message: Typo To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/sys/compat/linux/common/linux_ioctl.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_ioctl.h diff -u src/sys/compat/linux/common/linux_ioctl.h:1.26 src/sys/compat/linux/common/linux_ioctl.h:1.27 --- src/sys/compat/linux/common/linux_ioctl.h:1.26 Mon Apr 28 20:23:43 2008 +++ src/sys/compat/linux/common/linux_ioctl.h Sat Jun 8 12:50:32 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_ioctl.h,v 1.26 2008/04/28 20:23:43 martin Exp $ */ +/* $NetBSD: linux_ioctl.h,v 1.27 2013/06/08 12:50:32 stacktic Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -76,7 +76,7 @@ __END_DECLS #define _LINUX_IOC_NRMASK ((1 _LINUX_IOC_NRBITS) - 1) #define _LINUX_IOC_TYPEMASK ((1 _LINUX_IOC_TYPEBITS) - 1) -#define _LINUX_IOC_SIZEMAEK ((1 _LINUX_IOC_SIZEBITS) - 1) +#define _LINUX_IOC_SIZEMASK ((1 _LINUX_IOC_SIZEBITS) - 1) #define _LINUX_IOC_DIRMASK ((1 _LINUX_IOC_DIRBITS) - 1) #define _LINUX_IOC_TYPESHIFT (_LINUX_IOC_NRSHIFT + _LINUX_IOC_NRBITS)
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: christos Date: Wed Apr 17 14:39:41 UTC 2013 Modified Files: src/sys/compat/linux/common: linux_futex.c Log Message: handle timeouts like before. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/sys/compat/linux/common/linux_futex.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_futex.c diff -u src/sys/compat/linux/common/linux_futex.c:1.29 src/sys/compat/linux/common/linux_futex.c:1.30 --- src/sys/compat/linux/common/linux_futex.c:1.29 Tue Apr 16 19:03:05 2013 +++ src/sys/compat/linux/common/linux_futex.c Wed Apr 17 10:39:40 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_futex.c,v 1.29 2013/04/16 23:03:05 christos Exp $ */ +/* $NetBSD: linux_futex.c,v 1.30 2013/04/17 14:39:40 christos Exp $ */ /*- * Copyright (c) 2005 Emmanuel Dreyfus, all rights reserved. @@ -32,7 +32,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(1, $NetBSD: linux_futex.c,v 1.29 2013/04/16 23:03:05 christos Exp $); +__KERNEL_RCSID(1, $NetBSD: linux_futex.c,v 1.30 2013/04/17 14:39:40 christos Exp $); #include sys/param.h #include sys/time.h @@ -206,7 +206,7 @@ linux_do_futex(struct lwp *l, const stru if (error == ETIMEDOUT SCARG(uap, timeout) != NULL) tout = 1; else -return error; +tout = 0; } FUTEX_SYSTEM_LOCK; if ((error = copyin(SCARG(uap, uaddr),
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: christos Date: Tue Apr 16 23:03:05 UTC 2013 Modified Files: src/sys/compat/linux/common: linux_futex.c linux_futex.h Log Message: Add some more futex gunk and explain why it does not work (yet). Now skype aborts with a futex timeout, instead of a stack smash leading to a SEGV. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/sys/compat/linux/common/linux_futex.c cvs rdiff -u -r1.6 -r1.7 src/sys/compat/linux/common/linux_futex.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_futex.c diff -u src/sys/compat/linux/common/linux_futex.c:1.28 src/sys/compat/linux/common/linux_futex.c:1.29 --- src/sys/compat/linux/common/linux_futex.c:1.28 Thu Nov 17 23:07:44 2011 +++ src/sys/compat/linux/common/linux_futex.c Tue Apr 16 19:03:05 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_futex.c,v 1.28 2011/11/18 04:07:44 christos Exp $ */ +/* $NetBSD: linux_futex.c,v 1.29 2013/04/16 23:03:05 christos Exp $ */ /*- * Copyright (c) 2005 Emmanuel Dreyfus, all rights reserved. @@ -32,7 +32,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(1, $NetBSD: linux_futex.c,v 1.28 2011/11/18 04:07:44 christos Exp $); +__KERNEL_RCSID(1, $NetBSD: linux_futex.c,v 1.29 2013/04/16 23:03:05 christos Exp $); #include sys/param.h #include sys/time.h @@ -67,6 +67,7 @@ struct waiting_proc { struct futex { void *f_uaddr; int f_refcount; + uint32_t f_bitset; LIST_ENTRY(futex) f_list; TAILQ_HEAD(, waiting_proc) f_waiting_proc; TAILQ_HEAD(, waiting_proc) f_requeue_proc; @@ -105,7 +106,7 @@ linux_futex_fini(void) static struct waiting_proc *futex_wp_alloc(void); static void futex_wp_free(struct waiting_proc *); -static struct futex *futex_get(void *); +static struct futex *futex_get(void *, uint32_t); static void futex_ref(struct futex *); static void futex_put(struct futex *); static int futex_sleep(struct futex **, lwp_t *, int, struct waiting_proc *); @@ -127,7 +128,7 @@ linux_sys_futex(struct lwp *l, const str struct timespec ts = { 0, 0 }; int error; - if ((SCARG(uap, op) ~LINUX_FUTEX_PRIVATE_FLAG) == LINUX_FUTEX_WAIT + if ((SCARG(uap, op) LINUX_FUTEX_CMD_MASK) == LINUX_FUTEX_WAIT SCARG(uap, timeout) != NULL) { if ((error = copyin(SCARG(uap, timeout), lts, sizeof(lts))) != 0) { @@ -149,15 +150,31 @@ linux_do_futex(struct lwp *l, const stru syscallarg(int *) uaddr2; syscallarg(int) val3; } */ - int val; + int val, val3; int ret; int error = 0; struct futex *f; struct futex *newf; - int timeout_hz; + int tout; struct futex *f2; struct waiting_proc *wp; - int op_ret; + int op_ret, cmd; + clockid_t clk; + + cmd = SCARG(uap, op) LINUX_FUTEX_CMD_MASK; + val3 = SCARG(uap, val3); + + if (SCARG(uap, op) LINUX_FUTEX_CLOCK_REALTIME) { + switch (cmd) { + case LINUX_FUTEX_WAIT_BITSET: + case LINUX_FUTEX_WAIT: + clk = CLOCK_REALTIME; + break; + default: + return ENOSYS; + } + } else + clk = CLOCK_MONOTONIC; /* * Our implementation provides only private futexes. Most of the apps @@ -165,11 +182,33 @@ linux_do_futex(struct lwp *l, const stru * all futexes as private by clearing the FUTEX_PRIVATE_FLAG. It works * in most cases (ie. when futexes are not shared on file descriptor * or between different processes). + * + * Note that we don't handle bitsets at all at the moment. We need + * to move from refcounting uaddr's to handling multiple futex entries + * pointing to the same uaddr, but having possibly different bitmask. + * Perhaps move to an implementation where each uaddr has a list of + * futexes. */ - switch (SCARG(uap, op) ~LINUX_FUTEX_PRIVATE_FLAG) { + switch (cmd) { case LINUX_FUTEX_WAIT: + val3 = FUTEX_BITSET_MATCH_ANY; + /*FALLTHROUGH*/ + case LINUX_FUTEX_WAIT_BITSET: + if ((error = ts2timo(clk, 0, ts, tout, NULL)) != 0) { + /* + * If the user process requests a non null timeout, + * make sure we do not turn it into an infinite + * timeout because tout is 0. + * + * We use a minimal timeout of 1/hz. Maybe it would make + * sense to just return ETIMEDOUT without sleeping. + */ + if (error == ETIMEDOUT SCARG(uap, timeout) != NULL) +tout = 1; + else +return error; + } FUTEX_SYSTEM_LOCK; - if ((error = copyin(SCARG(uap, uaddr), val, sizeof(val))) != 0) { FUTEX_SYSTEM_UNLOCK; @@ -187,27 +226,11 @@ linux_do_futex(struct lwp *l, const stru SCARG(uap, uaddr), val, (long long)ts-tv_sec, ts-tv_nsec)); - if ((error = itimespecfix(ts)) != 0) { - FUTEX_SYSTEM_UNLOCK; - return error; - } - timeout_hz = tstohz(ts); - - /* - * If the user process requests a non null timeout, - * make sure we do not turn it into an infinite - * timeout because timeout_hz is 0. - * - * We use a minimal timeout of 1/hz. Maybe it would make - * sense to just return ETIMEDOUT without sleeping. -
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: christos Date: Mon Apr 15 19:24:04 UTC 2013 Modified Files: src/sys/compat/linux/common: linux_misc.c Log Message: alpha uses standard utimes. To generate a diff of this commit: cvs rdiff -u -r1.222 -r1.223 src/sys/compat/linux/common/linux_misc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_misc.c diff -u src/sys/compat/linux/common/linux_misc.c:1.222 src/sys/compat/linux/common/linux_misc.c:1.223 --- src/sys/compat/linux/common/linux_misc.c:1.222 Tue Apr 9 04:00:20 2013 +++ src/sys/compat/linux/common/linux_misc.c Mon Apr 15 15:24:04 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_misc.c,v 1.222 2013/04/09 08:00:20 pooka Exp $ */ +/* $NetBSD: linux_misc.c,v 1.223 2013/04/15 19:24:04 christos Exp $ */ /*- * Copyright (c) 1995, 1998, 1999, 2008 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_misc.c,v 1.222 2013/04/09 08:00:20 pooka Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_misc.c,v 1.223 2013/04/15 19:24:04 christos Exp $); #include sys/param.h #include sys/systm.h @@ -1379,6 +1379,7 @@ linux_sys_getpriority(struct lwp *l, con return 0; } +#ifndef __alpha__ int linux_sys_utimes(struct lwp *l, const struct linux_sys_utimes_args *uap, register_t *retval) { @@ -1435,4 +1436,5 @@ linux_sys_lutimes(struct lwp *l, const s return do_sys_utimes(l, NULL, SCARG(uap, path), NOFOLLOW, tptr, UIO_SYSSPACE); } +#endif /* __alpha__ */ #endif /* !COMPAT_LINUX32 */
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: pooka Date: Tue Apr 9 08:00:20 UTC 2013 Modified Files: src/sys/compat/linux/common: linux_misc.c Log Message: Fix COMPAT_LINUX32. To generate a diff of this commit: cvs rdiff -u -r1.221 -r1.222 src/sys/compat/linux/common/linux_misc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_misc.c diff -u src/sys/compat/linux/common/linux_misc.c:1.221 src/sys/compat/linux/common/linux_misc.c:1.222 --- src/sys/compat/linux/common/linux_misc.c:1.221 Mon Apr 8 20:54:49 2013 +++ src/sys/compat/linux/common/linux_misc.c Tue Apr 9 08:00:20 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_misc.c,v 1.221 2013/04/08 20:54:49 pooka Exp $ */ +/* $NetBSD: linux_misc.c,v 1.222 2013/04/09 08:00:20 pooka Exp $ */ /*- * Copyright (c) 1995, 1998, 1999, 2008 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_misc.c,v 1.221 2013/04/08 20:54:49 pooka Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_misc.c,v 1.222 2013/04/09 08:00:20 pooka Exp $); #include sys/param.h #include sys/systm.h @@ -1378,7 +1378,6 @@ linux_sys_getpriority(struct lwp *l, con return 0; } -#endif /* !COMPAT_LINUX32 */ int linux_sys_utimes(struct lwp *l, const struct linux_sys_utimes_args *uap, register_t *retval) @@ -1436,3 +1435,4 @@ linux_sys_lutimes(struct lwp *l, const s return do_sys_utimes(l, NULL, SCARG(uap, path), NOFOLLOW, tptr, UIO_SYSSPACE); } +#endif /* !COMPAT_LINUX32 */
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: christos Date: Fri Jan 11 02:49:09 UTC 2013 Modified Files: src/sys/compat/linux/common: linux_futex.h Log Message: add the futex PI commands (not implemented yet) PI = Priotity Inheritance To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/compat/linux/common/linux_futex.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_futex.h diff -u src/sys/compat/linux/common/linux_futex.h:1.5 src/sys/compat/linux/common/linux_futex.h:1.6 --- src/sys/compat/linux/common/linux_futex.h:1.5 Wed Sep 14 08:28:08 2011 +++ src/sys/compat/linux/common/linux_futex.h Thu Jan 10 21:49:09 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_futex.h,v 1.5 2011/09/14 12:28:08 christos Exp $ */ +/* $NetBSD: linux_futex.h,v 1.6 2013/01/11 02:49:09 christos Exp $ */ /*- * Copyright (c) 2005 Emmanuel Dreyfus, all rights reserved. @@ -34,21 +34,28 @@ #ifndef _LINUX_FUTEX_H #define _LINUX_FUTEX_H -#define LINUX_FUTEX_WAIT 0 -#define LINUX_FUTEX_WAKE 1 -#define LINUX_FUTEX_FD 2 -#define LINUX_FUTEX_REQUEUE 3 -#define LINUX_FUTEX_CMP_REQUEUE 4 -#define LINUX_FUTEX_WAKE_OP 5 +#define LINUX_FUTEX_WAIT 0 +#define LINUX_FUTEX_WAKE 1 +#define LINUX_FUTEX_FD 2 +#define LINUX_FUTEX_REQUEUE 3 +#define LINUX_FUTEX_CMP_REQUEUE 4 +#define LINUX_FUTEX_WAKE_OP 5 +#define LINUX_FUTEX_LOCK_PI 6 +#define LINUX_FUTEX_UNLOCK_PI 7 +#define LINUX_FUTEX_TRYLOCK_PI 8 +#define LINUX_FUTEX_WAIT_BITSET 9 +#define LINUX_FUTEX_WAKE_BITSET 10 +#define LINUX_FUTEX_WAIT_REQUEUE_PI 11 +#define LINUX_FUTEX_CMP_REQUEUE_PI 12 #define LINUX_FUTEX_PRIVATE_FLAG 128 +#define LINUX_FUTEX_CLOCK_REALTIME 256 #define FUTEX_OP_SET 0 #define FUTEX_OP_ADD 1 #define FUTEX_OP_OR 2 #define FUTEX_OP_ANDN 3 #define FUTEX_OP_XOR 4 - #define FUTEX_OP_OPARG_SHIFT 8 #define FUTEX_OP_CMP_EQ 0
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: pooka Date: Thu Sep 13 13:59:33 UTC 2012 Modified Files: src/sys/compat/linux/common: linux_misc.h linux_statfs.h Log Message: Rename structure members to make the code compile in environments where linux is #defined. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sys/compat/linux/common/linux_misc.h cvs rdiff -u -r1.5 -r1.6 src/sys/compat/linux/common/linux_statfs.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_misc.h diff -u src/sys/compat/linux/common/linux_misc.h:1.21 src/sys/compat/linux/common/linux_misc.h:1.22 --- src/sys/compat/linux/common/linux_misc.h:1.21 Mon May 30 17:50:32 2011 +++ src/sys/compat/linux/common/linux_misc.h Thu Sep 13 13:59:33 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_misc.h,v 1.21 2011/05/30 17:50:32 alnsn Exp $ */ +/* $NetBSD: linux_misc.h,v 1.22 2012/09/13 13:59:33 pooka Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -116,8 +116,8 @@ struct linux_sysinfo { #define LINUX_XENIX_SUPER_MAGIC (LINUX_SYSV_MAGIC_BASE + 1) struct linux_mnttypes { - const char *bsd; - int linux; + const char *mty_bsd; + int mty_linux; }; extern const struct linux_mnttypes linux_fstypes[]; extern const int linux_fstypes_cnt; Index: src/sys/compat/linux/common/linux_statfs.h diff -u src/sys/compat/linux/common/linux_statfs.h:1.5 src/sys/compat/linux/common/linux_statfs.h:1.6 --- src/sys/compat/linux/common/linux_statfs.h:1.5 Tue Nov 2 18:14:05 2010 +++ src/sys/compat/linux/common/linux_statfs.h Thu Sep 13 13:59:33 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_statfs.h,v 1.5 2010/11/02 18:14:05 chs Exp $ */ +/* $NetBSD: linux_statfs.h,v 1.6 2012/09/13 13:59:33 pooka Exp $ */ /*- * Copyright (c) 1995, 1998, 1999 The NetBSD Foundation, Inc. @@ -49,8 +49,8 @@ bsd_to_linux_statfs(const struct statvfs int i; for (i = 0; i linux_fstypes_cnt; i++) { - if (strcmp(bsp-f_fstypename, linux_fstypes[i].bsd) == 0) { - lsp-l_ftype = linux_fstypes[i].linux; + if (strcmp(bsp-f_fstypename, linux_fstypes[i].mty_bsd) == 0) { + lsp-l_ftype = linux_fstypes[i].mty_linux; break; } } @@ -97,8 +97,8 @@ bsd_to_linux_statfs64(const struct statv int i, div; for (i = 0; i linux_fstypes_cnt; i++) { - if (strcmp(bsp-f_fstypename, linux_fstypes[i].bsd) == 0) { - lsp-l_ftype = linux_fstypes[i].linux; + if (strcmp(bsp-f_fstypename, linux_fstypes[i].mty_bsd) == 0) { + lsp-l_ftype = linux_fstypes[i].mty_linux; break; } }
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: martin Date: Fri Jun 22 08:47:48 UTC 2012 Modified Files: src/sys/compat/linux/common: linux_socketcall.c Log Message: From the parse errors that you just do not see as a human department: build fix. To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sys/compat/linux/common/linux_socketcall.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_socketcall.c diff -u src/sys/compat/linux/common/linux_socketcall.c:1.41 src/sys/compat/linux/common/linux_socketcall.c:1.42 --- src/sys/compat/linux/common/linux_socketcall.c:1.41 Thu Jun 21 17:55:15 2012 +++ src/sys/compat/linux/common/linux_socketcall.c Fri Jun 22 08:47:47 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_socketcall.c,v 1.41 2012/06/21 17:55:15 christos Exp $ */ +/* $NetBSD: linux_socketcall.c,v 1.42 2012/06/22 08:47:47 martin Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_socketcall.c,v 1.41 2012/06/21 17:55:15 christos Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_socketcall.c,v 1.42 2012/06/22 08:47:47 martin Exp $); #include sys/param.h #include sys/kernel.h @@ -96,8 +96,8 @@ static const struct { {L(connect), sizeof(struct linux_sys_connect_args)}, /* 3 */ {L(listen), sizeof(struct linux_sys_listen_args)}, /* 4 */ {L(accept), sizeof(struct linux_sys_accept_args)}, /* 5 */ - {L(getsockname),sizeof(struct linux_sys_getsockname_args)}, /* 6 */ - {L(getpeername),sizeof(struct linux_sys_getpeername_args)}, /* 7 */ + {L(getsockname),sizeof(struct linux_sys_getsockname_args)}, /* 6 */ + {L(getpeername),sizeof(struct linux_sys_getpeername_args)}, /* 7 */ {L(socketpair),sizeof(struct linux_sys_socketpair_args)}, /* 8 */ {L(send), sizeof(struct linux_sys_send_args)}, /* 9 */ {L(recv), sizeof(struct linux_sys_recv_args)}, /* 10 */
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: christos Date: Thu Jun 21 17:55:16 UTC 2012 Modified Files: src/sys/compat/linux/common: linux_socketcall.c Log Message: fix token pasting. To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/sys/compat/linux/common/linux_socketcall.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_socketcall.c diff -u src/sys/compat/linux/common/linux_socketcall.c:1.40 src/sys/compat/linux/common/linux_socketcall.c:1.41 --- src/sys/compat/linux/common/linux_socketcall.c:1.40 Wed Jun 20 11:03:18 2012 +++ src/sys/compat/linux/common/linux_socketcall.c Thu Jun 21 13:55:15 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_socketcall.c,v 1.40 2012/06/20 15:03:18 christos Exp $ */ +/* $NetBSD: linux_socketcall.c,v 1.41 2012/06/21 17:55:15 christos Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_socketcall.c,v 1.40 2012/06/20 15:03:18 christos Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_socketcall.c,v 1.41 2012/06/21 17:55:15 christos Exp $); #include sys/param.h #include sys/kernel.h @@ -89,7 +89,7 @@ static const struct { const char *name; int argsize; } linux_socketcall[LINUX_MAX_SOCKETCALL+1] = { -#define L(a) linux/ ## a +#define L(a) linux/ a {L(invalid), -1}, /* 0 */ {L(socket), sizeof(struct linux_sys_socket_args)}, /* 1 */ {L(bind), sizeof(struct linux_sys_bind_args)}, /* 2 */
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: christos Date: Wed Jun 20 15:03:18 UTC 2012 Modified Files: src/sys/compat/linux/common: linux_socket.c linux_socketcall.c Log Message: print proper ktruser names depending on the emulation. To generate a diff of this commit: cvs rdiff -u -r1.113 -r1.114 src/sys/compat/linux/common/linux_socket.c cvs rdiff -u -r1.39 -r1.40 src/sys/compat/linux/common/linux_socketcall.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_socket.c diff -u src/sys/compat/linux/common/linux_socket.c:1.113 src/sys/compat/linux/common/linux_socket.c:1.114 --- src/sys/compat/linux/common/linux_socket.c:1.113 Thu Mar 15 12:17:48 2012 +++ src/sys/compat/linux/common/linux_socket.c Wed Jun 20 11:03:18 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_socket.c,v 1.113 2012/03/15 16:17:48 bouyer Exp $ */ +/* $NetBSD: linux_socket.c,v 1.114 2012/06/20 15:03:18 christos Exp $ */ /*- * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_socket.c,v 1.113 2012/03/15 16:17:48 bouyer Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_socket.c,v 1.114 2012/06/20 15:03:18 christos Exp $); #if defined(_KERNEL_OPT) #include opt_inet.h @@ -619,7 +619,7 @@ linux_sys_sendmsg(struct lwp *l, const s msg.msg_control = ctl_mbuf; msg.msg_flags |= MSG_CONTROLMBUF; - ktrkuser(msgcontrol, mtod(ctl_mbuf, void *), + ktrkuser(mbcontrol, mtod(ctl_mbuf, void *), msg.msg_controllen); } @@ -1495,7 +1495,7 @@ linux_get_sa(struct lwp *l, int s, struc goto bad; } - ktrkuser(linux sockaddr, kosa, salen); + ktrkuser(linux/sockaddr, kosa, salen); bdom = linux_to_bsd_domain(kosa-sa_family); if (bdom == -1) { @@ -1557,7 +1557,7 @@ linux_get_sa(struct lwp *l, int s, struc sa-sa_family = bdom; sa-sa_len = salen; m-m_len = salen; - ktrkuser(new sockaddr, kosa, salen); + ktrkuser(mbsoname, kosa, salen); #ifdef DEBUG_LINUX DPRINTF((family %d, len = %d [ , sa-sa_family, sa-sa_len)); Index: src/sys/compat/linux/common/linux_socketcall.c diff -u src/sys/compat/linux/common/linux_socketcall.c:1.39 src/sys/compat/linux/common/linux_socketcall.c:1.40 --- src/sys/compat/linux/common/linux_socketcall.c:1.39 Thu Jul 3 10:07:09 2008 +++ src/sys/compat/linux/common/linux_socketcall.c Wed Jun 20 11:03:18 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_socketcall.c,v 1.39 2008/07/03 14:07:09 njoly Exp $ */ +/* $NetBSD: linux_socketcall.c,v 1.40 2012/06/20 15:03:18 christos Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_socketcall.c,v 1.39 2008/07/03 14:07:09 njoly Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_socketcall.c,v 1.40 2012/06/20 15:03:18 christos Exp $); #include sys/param.h #include sys/kernel.h @@ -89,24 +89,26 @@ static const struct { const char *name; int argsize; } linux_socketcall[LINUX_MAX_SOCKETCALL+1] = { - {invalid, -1}, /* 0 */ - {socket, sizeof(struct linux_sys_socket_args)}, /* 1 */ - {bind, sizeof(struct linux_sys_bind_args)}, /* 2 */ - {connect, sizeof(struct linux_sys_connect_args)}, /* 3 */ - {listen, sizeof(struct linux_sys_listen_args)}, /* 4 */ - {accept, sizeof(struct linux_sys_accept_args)}, /* 5 */ - {getsockname, sizeof(struct linux_sys_getsockname_args)}, /* 6 */ - {getpeername, sizeof(struct linux_sys_getpeername_args)}, /* 7 */ - {socketpair, sizeof(struct linux_sys_socketpair_args)}, /* 8 */ - {send, sizeof(struct linux_sys_send_args)}, /* 9 */ - {recv, sizeof(struct linux_sys_recv_args)}, /* 10 */ - {sendto, sizeof(struct linux_sys_sendto_args)}, /* 11 */ - {recvfrom, sizeof(struct linux_sys_recvfrom_args)}, /* 12 */ - {shutdown, sizeof(struct linux_sys_shutdown_args)}, /* 13 */ - {setsockopt, sizeof(struct linux_sys_setsockopt_args)}, /* 14 */ - {getsockopt, sizeof(struct linux_sys_getsockopt_args)}, /* 15 */ - {sendmsg, sizeof(struct linux_sys_sendmsg_args)}, /* 16 */ - {recvmsg, sizeof(struct linux_sys_recvmsg_args)}, /* 17 */ +#define L(a) linux/ ## a + {L(invalid), -1}, /* 0 */ + {L(socket), sizeof(struct linux_sys_socket_args)}, /* 1 */ + {L(bind), sizeof(struct linux_sys_bind_args)}, /* 2 */ + {L(connect), sizeof(struct linux_sys_connect_args)}, /* 3 */ + {L(listen), sizeof(struct linux_sys_listen_args)}, /* 4 */ + {L(accept), sizeof(struct linux_sys_accept_args)}, /* 5 */ + {L(getsockname),sizeof(struct linux_sys_getsockname_args)}, /* 6 */ + {L(getpeername),sizeof(struct linux_sys_getpeername_args)}, /* 7 */ + {L(socketpair),sizeof(struct linux_sys_socketpair_args)}, /* 8 */ + {L(send), sizeof(struct linux_sys_send_args)}, /* 9 */ + {L(recv), sizeof(struct linux_sys_recv_args)}, /* 10 */ + {L(sendto), sizeof(struct linux_sys_sendto_args)}, /* 11 */ + {L(recvfrom), sizeof(struct linux_sys_recvfrom_args)}, /* 12 */
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: martin Date: Fri Nov 18 09:17:09 UTC 2011 Modified Files: src/sys/compat/linux/common: linux_siginfo.h Log Message: Provide linux_siginfo_t for all archs, to unbreak kdump build. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/compat/linux/common/linux_siginfo.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_siginfo.h diff -u src/sys/compat/linux/common/linux_siginfo.h:1.15 src/sys/compat/linux/common/linux_siginfo.h:1.16 --- src/sys/compat/linux/common/linux_siginfo.h:1.15 Fri Nov 18 04:07:44 2011 +++ src/sys/compat/linux/common/linux_siginfo.h Fri Nov 18 09:17:09 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_siginfo.h,v 1.15 2011/11/18 04:07:44 christos Exp $ */ +/* $NetBSD: linux_siginfo.h,v 1.16 2011/11/18 09:17:09 martin Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -46,6 +46,8 @@ #include compat/linux/arch/arm/linux_siginfo.h #elif defined(__amd64__) #include compat/linux/arch/amd64/linux_siginfo.h +#else +#define linux_siginfo_t siginfo_t #endif /* si_code values for non signal */
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: christos Date: Fri Nov 18 15:45:47 UTC 2011 Modified Files: src/sys/compat/linux/common: linux_signal.c Log Message: remove incorrect assertions (the len passed is the size of the bsd structure not the linux one) To generate a diff of this commit: cvs rdiff -u -r1.73 -r1.74 src/sys/compat/linux/common/linux_signal.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_signal.c diff -u src/sys/compat/linux/common/linux_signal.c:1.73 src/sys/compat/linux/common/linux_signal.c:1.74 --- src/sys/compat/linux/common/linux_signal.c:1.73 Thu Nov 17 23:07:44 2011 +++ src/sys/compat/linux/common/linux_signal.c Fri Nov 18 10:45:47 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_signal.c,v 1.73 2011/11/18 04:07:44 christos Exp $ */ +/* $NetBSD: linux_signal.c,v 1.74 2011/11/18 15:45:47 christos Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -48,7 +48,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_signal.c,v 1.73 2011/11/18 04:07:44 christos Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_signal.c,v 1.74 2011/11/18 15:45:47 christos Exp $); #define COMPAT_LINUX 1 @@ -559,7 +559,6 @@ fetchss(const void *u, void *s, size_t l int error; linux_sigset_t lss; - KASSERT(len == sizeof(lss)); if ((error = copyin(u, lss, sizeof(lss))) != 0) return error; @@ -573,7 +572,6 @@ fetchts(const void *u, void *s, size_t l int error; struct linux_timespec lts; - KASSERT(len == sizeof(lts)); if ((error = copyin(u, lts, sizeof(lts))) != 0) return error;
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: christos Date: Fri Nov 18 17:36:06 UTC 2011 Modified Files: src/sys/compat/linux/common: linux_signal.c Log Message: remove one more kassert To generate a diff of this commit: cvs rdiff -u -r1.74 -r1.75 src/sys/compat/linux/common/linux_signal.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_signal.c diff -u src/sys/compat/linux/common/linux_signal.c:1.74 src/sys/compat/linux/common/linux_signal.c:1.75 --- src/sys/compat/linux/common/linux_signal.c:1.74 Fri Nov 18 10:45:47 2011 +++ src/sys/compat/linux/common/linux_signal.c Fri Nov 18 12:36:06 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_signal.c,v 1.74 2011/11/18 15:45:47 christos Exp $ */ +/* $NetBSD: linux_signal.c,v 1.75 2011/11/18 17:36:06 christos Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -48,7 +48,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_signal.c,v 1.74 2011/11/18 15:45:47 christos Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_signal.c,v 1.75 2011/11/18 17:36:06 christos Exp $); #define COMPAT_LINUX 1 @@ -553,6 +553,7 @@ linux_sys_rt_sigsuspend(struct lwp *l, c return (sigsuspend1(l, bss)); } + static int fetchss(const void *u, void *s, size_t len) { @@ -591,8 +592,6 @@ storeinfo(const void *s, void *u, size_t { struct linux_siginfo lsi; - KASSERT(len == sizeof(lsi)); - native_to_linux_siginfo(lsi, ((const siginfo_t *)s)-_info); return copyout(lsi, u, sizeof(lsi)); }
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: chs Date: Sun Sep 25 13:40:07 UTC 2011 Modified Files: src/sys/compat/linux/common: linux_termios.h Log Message: linux_termio c_cc array should be indexed by LINUX_OLD_V* rather than LINUX_V*. fixes array overrun on alpha noticed by gcc 4.5. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/sys/compat/linux/common/linux_termios.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_termios.h diff -u src/sys/compat/linux/common/linux_termios.h:1.20 src/sys/compat/linux/common/linux_termios.h:1.21 --- src/sys/compat/linux/common/linux_termios.h:1.20 Mon Jul 4 12:39:36 2011 +++ src/sys/compat/linux/common/linux_termios.h Sun Sep 25 13:40:07 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_termios.h,v 1.20 2011/07/04 12:39:36 mrg Exp $ */ +/* $NetBSD: linux_termios.h,v 1.21 2011/09/25 13:40:07 chs Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -345,16 +345,16 @@ bsd_termios_to_linux_termio(struct termi } lt-c_cflag |= mask; - lt-c_cc[LINUX_VINTR] = bts-c_cc[VINTR]; - lt-c_cc[LINUX_VQUIT] = bts-c_cc[VQUIT]; - lt-c_cc[LINUX_VERASE] = bts-c_cc[VERASE]; - lt-c_cc[LINUX_VKILL] = bts-c_cc[VKILL]; -#if LINUX_VEOF LINUX_NCC - lt-c_cc[LINUX_VEOF] = bts-c_cc[VEOF]; + lt-c_cc[LINUX_OLD_VINTR] = bts-c_cc[VINTR]; + lt-c_cc[LINUX_OLD_VQUIT] = bts-c_cc[VQUIT]; + lt-c_cc[LINUX_OLD_VERASE] = bts-c_cc[VERASE]; + lt-c_cc[LINUX_OLD_VKILL] = bts-c_cc[VKILL]; +#if LINUX_OLD_VEOF LINUX_NCC + lt-c_cc[LINUX_OLD_VEOF] = bts-c_cc[VEOF]; #endif - lt-c_cc[LINUX_VTIME] = bts-c_cc[VTIME]; - lt-c_cc[LINUX_VMIN] = bts-c_cc[VMIN]; - lt-c_cc[LINUX_VSWTC] = 0; + lt-c_cc[LINUX_OLD_VTIME] = bts-c_cc[VTIME]; + lt-c_cc[LINUX_OLD_VMIN] = bts-c_cc[VMIN]; + lt-c_cc[LINUX_OLD_VSWTC] = 0; /* XXX should be fixed someday */ lt-c_line = 0;
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: christos Date: Wed Sep 14 12:28:09 UTC 2011 Modified Files: src/sys/compat/linux/common: linux_futex.c linux_futex.h linux_mod.c Log Message: Can't use RUN_ONCE here to initialize the futex_lock, otherwise we cannot unload the module. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/sys/compat/linux/common/linux_futex.c cvs rdiff -u -r1.4 -r1.5 src/sys/compat/linux/common/linux_futex.h cvs rdiff -u -r1.1 -r1.2 src/sys/compat/linux/common/linux_mod.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_futex.c diff -u src/sys/compat/linux/common/linux_futex.c:1.26 src/sys/compat/linux/common/linux_futex.c:1.27 --- src/sys/compat/linux/common/linux_futex.c:1.26 Tue Jul 6 21:30:35 2010 +++ src/sys/compat/linux/common/linux_futex.c Wed Sep 14 08:28:08 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_futex.c,v 1.26 2010/07/07 01:30:35 chs Exp $ */ +/* $NetBSD: linux_futex.c,v 1.27 2011/09/14 12:28:08 christos Exp $ */ /*- * Copyright (c) 2005 Emmanuel Dreyfus, all rights reserved. @@ -32,7 +32,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(1, $NetBSD: linux_futex.c,v 1.26 2010/07/07 01:30:35 chs Exp $); +__KERNEL_RCSID(1, $NetBSD: linux_futex.c,v 1.27 2011/09/14 12:28:08 christos Exp $); #include sys/param.h #include sys/time.h @@ -42,7 +42,6 @@ #include sys/queue.h #include sys/condvar.h #include sys/mutex.h -#include sys/once.h #include sys/kmem.h #include sys/kernel.h #include sys/atomic.h @@ -92,14 +91,18 @@ #define FUTEXPRINTF(a) #endif -static ONCE_DECL(futex_once); - -static int -futex_init(void) +void +linux_futex_init(void) { - FUTEXPRINTF((futex_init: initializing futex\n)); + FUTEXPRINTF((%s: initializing futex\n, __func__)); mutex_init(futex_lock, MUTEX_DEFAULT, IPL_NONE); - return 0; +} + +void +linux_futex_fini(void) +{ + FUTEXPRINTF((%s: destroying futex\n, __func__)); + mutex_destroy(futex_lock); } static struct waiting_proc *futex_wp_alloc(void); @@ -158,8 +161,6 @@ struct waiting_proc *wp; int op_ret; - RUN_ONCE(futex_once, futex_init); - /* * Our implementation provides only private futexes. Most of the apps * should use private futexes but don't claim so. Therefore we treat Index: src/sys/compat/linux/common/linux_futex.h diff -u src/sys/compat/linux/common/linux_futex.h:1.4 src/sys/compat/linux/common/linux_futex.h:1.5 --- src/sys/compat/linux/common/linux_futex.h:1.4 Tue Jul 6 21:30:35 2010 +++ src/sys/compat/linux/common/linux_futex.h Wed Sep 14 08:28:08 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_futex.h,v 1.4 2010/07/07 01:30:35 chs Exp $ */ +/* $NetBSD: linux_futex.h,v 1.5 2011/09/14 12:28:08 christos Exp $ */ /*- * Copyright (c) 2005 Emmanuel Dreyfus, all rights reserved. @@ -76,5 +76,7 @@ struct linux_sys_futex_args; int linux_do_futex(struct lwp *, const struct linux_sys_futex_args *, register_t *, struct timespec *); +void linux_futex_init(void); +void linux_futex_fini(void); #endif /* !_LINUX_FUTEX_H */ Index: src/sys/compat/linux/common/linux_mod.c diff -u src/sys/compat/linux/common/linux_mod.c:1.1 src/sys/compat/linux/common/linux_mod.c:1.2 --- src/sys/compat/linux/common/linux_mod.c:1.1 Wed Nov 19 13:36:03 2008 +++ src/sys/compat/linux/common/linux_mod.c Wed Sep 14 08:28:08 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_mod.c,v 1.1 2008/11/19 18:36:03 ad Exp $ */ +/* $NetBSD: linux_mod.c,v 1.2 2011/09/14 12:28:08 christos Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_mod.c,v 1.1 2008/11/19 18:36:03 ad Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_mod.c,v 1.2 2011/09/14 12:28:08 christos Exp $); #ifdef _KERNEL_OPT #include opt_execfmt.h @@ -46,6 +46,7 @@ #include sys/signalvar.h #include compat/linux/common/linux_sysctl.h +#include compat/linux/common/linux_futex.h #include compat/linux/common/linux_exec.h #if defined(EXEC_ELF32) ELFSIZE == 32 @@ -111,6 +112,7 @@ switch (cmd) { case MODULE_CMD_INIT: + linux_futex_init(); linux_sysctl_init(); error = exec_add(linux_execsw, __arraycount(linux_execsw)); @@ -121,8 +123,10 @@ case MODULE_CMD_FINI: error = exec_remove(linux_execsw, __arraycount(linux_execsw)); - if (error == 0) + if (error == 0) { linux_sysctl_fini(); + linux_futex_fini(); + } return error; default:
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: njoly Date: Thu Sep 1 12:44:10 UTC 2011 Modified Files: src/sys/compat/linux/common: linux_file64.c Log Message: Make linux_sys_getdents64 fails with ENOTDIR instead of EINVAL, when fd does not refer to a directory. To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/sys/compat/linux/common/linux_file64.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_file64.c diff -u src/sys/compat/linux/common/linux_file64.c:1.51 src/sys/compat/linux/common/linux_file64.c:1.52 --- src/sys/compat/linux/common/linux_file64.c:1.51 Thu Jun 24 13:03:07 2010 +++ src/sys/compat/linux/common/linux_file64.c Thu Sep 1 12:44:10 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_file64.c,v 1.51 2010/06/24 13:03:07 hannken Exp $ */ +/* $NetBSD: linux_file64.c,v 1.52 2011/09/01 12:44:10 njoly Exp $ */ /*- * Copyright (c) 1995, 1998, 2000, 2008 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_file64.c,v 1.51 2010/06/24 13:03:07 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_file64.c,v 1.52 2011/09/01 12:44:10 njoly Exp $); #include sys/param.h #include sys/systm.h @@ -254,7 +254,7 @@ vp = (struct vnode *)fp-f_data; if (vp-v_type != VDIR) { - error = EINVAL; + error = ENOTDIR; goto out1; }
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: christos Date: Thu Aug 18 02:21:02 UTC 2011 Modified Files: src/sys/compat/linux/common: linux_exec.c Log Message: sizeof type - sizeof *var To generate a diff of this commit: cvs rdiff -u -r1.114 -r1.115 src/sys/compat/linux/common/linux_exec.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_exec.c diff -u src/sys/compat/linux/common/linux_exec.c:1.114 src/sys/compat/linux/common/linux_exec.c:1.115 --- src/sys/compat/linux/common/linux_exec.c:1.114 Tue Jul 6 21:30:35 2010 +++ src/sys/compat/linux/common/linux_exec.c Wed Aug 17 22:21:02 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_exec.c,v 1.114 2010/07/07 01:30:35 chs Exp $ */ +/* $NetBSD: linux_exec.c,v 1.115 2011/08/18 02:21:02 christos Exp $ */ /*- * Copyright (c) 1994, 1995, 1998, 2000, 2007, 2008 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_exec.c,v 1.114 2010/07/07 01:30:35 chs Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_exec.c,v 1.115 2011/08/18 02:21:02 christos Exp $); #include sys/param.h #include sys/systm.h @@ -165,7 +165,7 @@ { struct linux_emuldata *led2; - led2 = kmem_zalloc(sizeof(struct linux_emuldata), KM_SLEEP); + led2 = kmem_zalloc(sizeof(*led2), KM_SLEEP); l2-l_emuldata = led2; } @@ -202,5 +202,5 @@ led = l-l_emuldata; l-l_emuldata = NULL; - kmem_free(led, sizeof (struct linux_emuldata)); + kmem_free(led, sizeof(*led)); }
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: christos Date: Thu Aug 18 02:26:39 UTC 2011 Modified Files: src/sys/compat/linux/common: linux_sched.c Log Message: Better debugging. To generate a diff of this commit: cvs rdiff -u -r1.64 -r1.65 src/sys/compat/linux/common/linux_sched.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_sched.c diff -u src/sys/compat/linux/common/linux_sched.c:1.64 src/sys/compat/linux/common/linux_sched.c:1.65 --- src/sys/compat/linux/common/linux_sched.c:1.64 Sun Jun 5 04:42:59 2011 +++ src/sys/compat/linux/common/linux_sched.c Wed Aug 17 22:26:38 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_sched.c,v 1.64 2011/06/05 08:42:59 dsl Exp $ */ +/* $NetBSD: linux_sched.c,v 1.65 2011/08/18 02:26:38 christos Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_sched.c,v 1.64 2011/06/05 08:42:59 dsl Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_sched.c,v 1.65 2011/08/18 02:26:38 christos Exp $); #include sys/param.h #include sys/mount.h @@ -63,7 +63,14 @@ #include compat/linux/common/linux_sched.h -static int linux_clone_nptl(struct lwp *, const struct linux_sys_clone_args *, register_t *); +static int linux_clone_nptl(struct lwp *, const struct linux_sys_clone_args *, +register_t *); + +#if DEBUG_LINUX +#define DPRINTF(x) uprintf x +#else +#define DPRINTF(x) +#endif static void linux_child_return(void *arg) @@ -72,18 +79,20 @@ struct proc *p = l-l_proc; struct linux_emuldata *led = l-l_emuldata; void *ctp = led-led_child_tidptr; + int error; if (ctp) { - if (copyout(p-p_pid, ctp, sizeof(p-p_pid)) != 0) + if ((error = copyout(p-p_pid, ctp, sizeof(p-p_pid))) != 0) printf(%s: LINUX_CLONE_CHILD_SETTID - failed (child_tidptr = %p, tid = %d)\n, - __func__, ctp, p-p_pid); + failed (child_tidptr = %p, tid = %d error =%d)\n, + __func__, ctp, p-p_pid, error); } child_return(arg); } int -linux_sys_clone(struct lwp *l, const struct linux_sys_clone_args *uap, register_t *retval) +linux_sys_clone(struct lwp *l, const struct linux_sys_clone_args *uap, +register_t *retval) { /* { syscallarg(int) flags; @@ -100,7 +109,7 @@ * We don't support the Linux CLONE_PID or CLONE_PTRACE flags. */ if (SCARG(uap, flags) (LINUX_CLONE_PID|LINUX_CLONE_PTRACE)) - return (EINVAL); + return EINVAL; /* * Thread group implies shared signals. Shared signals @@ -108,17 +117,16 @@ */ if (SCARG(uap, flags) LINUX_CLONE_THREAD (SCARG(uap, flags) LINUX_CLONE_SIGHAND) == 0) - return (EINVAL); + return EINVAL; if (SCARG(uap, flags) LINUX_CLONE_SIGHAND (SCARG(uap, flags) LINUX_CLONE_VM) == 0) - return (EINVAL); + return EINVAL; /* * The thread group flavor is implemented totally differently. */ - if (SCARG(uap, flags) LINUX_CLONE_THREAD) { + if (SCARG(uap, flags) LINUX_CLONE_THREAD) return linux_clone_nptl(l, uap, retval); - } flags = 0; if (SCARG(uap, flags) LINUX_CLONE_VM) @@ -134,7 +142,7 @@ sig = SCARG(uap, flags) LINUX_CLONE_CSIGNAL; if (sig 0 || sig = LINUX__NSIG) - return (EINVAL); + return EINVAL; sig = linux_to_native_signo[sig]; if (SCARG(uap, flags) LINUX_CLONE_CHILD_SETTID) { @@ -149,8 +157,10 @@ * that makes this adjustment is a noop. */ if ((error = fork1(l, flags, sig, SCARG(uap, stack), 0, - linux_child_return, NULL, retval, p)) != 0) + linux_child_return, NULL, retval, p)) != 0) { + DPRINTF((%s: fork1: error %d\n, __func__, error)); return error; + } return 0; } @@ -183,7 +193,7 @@ tnprocs = atomic_inc_uint_nv(nprocs); if (__predict_false(tnprocs = maxproc) || kauth_authorize_process(l-l_cred, KAUTH_PROCESS_FORK, p, -KAUTH_ARG(tnprocs), NULL, NULL) != 0) { + KAUTH_ARG(tnprocs), NULL, NULL) != 0) { atomic_dec_uint(nprocs); return EAGAIN; } @@ -195,9 +205,9 @@ } error = lwp_create(l, p, uaddr, LWP_DETACHED | LWP_PIDLID, - SCARG(uap, stack), 0, child_return, NULL, l2, - l-l_class); + SCARG(uap, stack), 0, child_return, NULL, l2, l-l_class); if (__predict_false(error)) { + DPRINTF((%s: lwp_create error=%d\n, __func__, error)); atomic_dec_uint(nprocs); uvm_uarea_free(uaddr); return error; @@ -212,23 +222,25 @@ /* LINUX_CLONE_PARENT_SETTID: store child's TID in parent's memory */ if (flags LINUX_CLONE_PARENT_SETTID) { - if (copyout(lid, parent_tidptr, sizeof(lid)) != 0) + if ((error = copyout(lid, parent_tidptr, sizeof(lid))) != 0) printf(%s: LINUX_CLONE_PARENT_SETTID - failed (parent_tidptr = %p tid = %d)\n, - __func__, parent_tidptr, lid); + failed (parent_tidptr = %p tid = %d error=%d)\n, + __func__, parent_tidptr, lid, error); } /* LINUX_CLONE_CHILD_SETTID: store child's TID in child's memory */ if (flags
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: christos Date: Sun Jul 17 23:59:55 UTC 2011 Modified Files: src/sys/compat/linux/common: linux_socket.c Log Message: fail early on socket domain+type combinations we don't support To generate a diff of this commit: cvs rdiff -u -r1.109 -r1.110 src/sys/compat/linux/common/linux_socket.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_socket.c diff -u src/sys/compat/linux/common/linux_socket.c:1.109 src/sys/compat/linux/common/linux_socket.c:1.110 --- src/sys/compat/linux/common/linux_socket.c:1.109 Thu Jun 30 16:09:39 2011 +++ src/sys/compat/linux/common/linux_socket.c Sun Jul 17 19:59:54 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_socket.c,v 1.109 2011/06/30 20:09:39 wiz Exp $ */ +/* $NetBSD: linux_socket.c,v 1.110 2011/07/17 23:59:54 christos Exp $ */ /*- * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_socket.c,v 1.109 2011/06/30 20:09:39 wiz Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_socket.c,v 1.110 2011/07/17 23:59:54 christos Exp $); #if defined(_KERNEL_OPT) #include opt_inet.h @@ -309,6 +309,13 @@ SCARG(bsa, domain) = linux_to_bsd_domain(SCARG(uap, domain)); if (SCARG(bsa, domain) == -1) return EINVAL; + /* + * Apparently linux uses this to talk to ISDN sockets. If we fail + * now programs seems to handle it, but if we don't we are going + * to fail when we bind and programs don't handle this well. + */ + if (SCARG(bsa, domain) == AF_ROUTE SCARG(bsa, type) == SOCK_RAW) + return ENOTSUP; flags = SCARG(uap, type) ~LINUX_SOCK_TYPE_MASK; if (flags ~(LINUX_SOCK_CLOEXEC | LINUX_SOCK_NONBLOCK)) return EINVAL;
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: mrg Date: Mon Jul 4 12:39:36 UTC 2011 Modified Files: src/sys/compat/linux/common: linux_termios.h Log Message: avoid array bounds violation on netbsd/mips when dealing with termio structures. (did linux/mips ever support termio?). the effect of this is that termio linux apps won't have VEOF support. i can't tell what it should be since that code isn't in linux going back quite some years. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/compat/linux/common/linux_termios.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_termios.h diff -u src/sys/compat/linux/common/linux_termios.h:1.19 src/sys/compat/linux/common/linux_termios.h:1.20 --- src/sys/compat/linux/common/linux_termios.h:1.19 Sun Mar 15 15:55:51 2009 +++ src/sys/compat/linux/common/linux_termios.h Mon Jul 4 12:39:36 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_termios.h,v 1.19 2009/03/15 15:55:51 cegger Exp $ */ +/* $NetBSD: linux_termios.h,v 1.20 2011/07/04 12:39:36 mrg Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -263,7 +263,9 @@ bts-c_cc[VQUIT] = lt-c_cc[LINUX_OLD_VQUIT]; bts-c_cc[VERASE] = lt-c_cc[LINUX_OLD_VERASE]; bts-c_cc[VKILL] = lt-c_cc[LINUX_OLD_VKILL]; +#if LINUX_VEOF LINUX_NCC bts-c_cc[VEOF] = lt-c_cc[LINUX_OLD_VEOF]; +#endif bts-c_cc[VTIME] = lt-c_cc[LINUX_OLD_VTIME]; bts-c_cc[VMIN] = lt-c_cc[LINUX_OLD_VMIN]; } @@ -347,7 +349,9 @@ lt-c_cc[LINUX_VQUIT] = bts-c_cc[VQUIT]; lt-c_cc[LINUX_VERASE] = bts-c_cc[VERASE]; lt-c_cc[LINUX_VKILL] = bts-c_cc[VKILL]; +#if LINUX_VEOF LINUX_NCC lt-c_cc[LINUX_VEOF] = bts-c_cc[VEOF]; +#endif lt-c_cc[LINUX_VTIME] = bts-c_cc[VTIME]; lt-c_cc[LINUX_VMIN] = bts-c_cc[VMIN]; lt-c_cc[LINUX_VSWTC] = 0;
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: alnsn Date: Sat May 28 23:24:58 UTC 2011 Modified Files: src/sys/compat/linux/common: linux_ipc.c Log Message: Fix typo in a comment. To generate a diff of this commit: cvs rdiff -u -r1.54 -r1.55 src/sys/compat/linux/common/linux_ipc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_ipc.c diff -u src/sys/compat/linux/common/linux_ipc.c:1.54 src/sys/compat/linux/common/linux_ipc.c:1.55 --- src/sys/compat/linux/common/linux_ipc.c:1.54 Mon Nov 16 08:44:19 2009 +++ src/sys/compat/linux/common/linux_ipc.c Sat May 28 23:24:58 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_ipc.c,v 1.54 2009/11/16 08:44:19 joerg Exp $ */ +/* $NetBSD: linux_ipc.c,v 1.55 2011/05/28 23:24:58 alnsn Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_ipc.c,v 1.54 2009/11/16 08:44:19 joerg Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_ipc.c,v 1.55 2011/05/28 23:24:58 alnsn Exp $); #if defined(_KERNEL_OPT) #include opt_sysv.h @@ -74,7 +74,7 @@ * * Function in multiarch: * linux_sys_ipc : linux_ipccall.c - * liunx_semop : linux_ipccall.c + * linux_semop : linux_ipccall.c * linux_semget : linux_ipccall.c * linux_msgsnd : linux_ipccall.c * linux_msgrcv : linux_ipccall.c
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: christos Date: Thu Apr 14 00:59:06 UTC 2011 Modified Files: src/sys/compat/linux/common: linux_file.c linux_pipe.c Log Message: move dup3 to a more appropriate place because pipe is special. Gotta love linux. To generate a diff of this commit: cvs rdiff -u -r1.102 -r1.103 src/sys/compat/linux/common/linux_file.c cvs rdiff -u -r1.64 -r1.65 src/sys/compat/linux/common/linux_pipe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_file.c diff -u src/sys/compat/linux/common/linux_file.c:1.102 src/sys/compat/linux/common/linux_file.c:1.103 --- src/sys/compat/linux/common/linux_file.c:1.102 Sun Apr 10 11:49:56 2011 +++ src/sys/compat/linux/common/linux_file.c Wed Apr 13 20:59:06 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_file.c,v 1.102 2011/04/10 15:49:56 christos Exp $ */ +/* $NetBSD: linux_file.c,v 1.103 2011/04/14 00:59:06 christos Exp $ */ /*- * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. @@ -35,13 +35,14 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_file.c,v 1.102 2011/04/10 15:49:56 christos Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_file.c,v 1.103 2011/04/14 00:59:06 christos Exp $); #include sys/param.h #include sys/systm.h #include sys/namei.h #include sys/proc.h #include sys/file.h +#include sys/fcntl.h #include sys/stat.h #include sys/filedesc.h #include sys/ioctl.h @@ -621,6 +622,25 @@ return sys_pwrite(l, pra, retval); } +int +linux_sys_dup3(struct lwp *l, const struct linux_sys_dup3_args *uap, +register_t *retval) +{ + /* { + syscallarg(int) from; + syscallarg(int) to; + syscallarg(int) flags; + } */ + int error; + if ((error = sys_dup2(l, (const struct sys_dup2_args *)uap, retval))) + return error; + + if (SCARG(uap, flags) LINUX_O_CLOEXEC) + fd_set_exclose(l, SCARG(uap, to), true); + + return 0; +} + #define LINUX_NOT_SUPPORTED(fun) \ int \ fun(struct lwp *l, const struct fun##_args *uap, register_t *retval) \ Index: src/sys/compat/linux/common/linux_pipe.c diff -u src/sys/compat/linux/common/linux_pipe.c:1.64 src/sys/compat/linux/common/linux_pipe.c:1.65 --- src/sys/compat/linux/common/linux_pipe.c:1.64 Sun Apr 10 11:50:34 2011 +++ src/sys/compat/linux/common/linux_pipe.c Wed Apr 13 20:59:06 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_pipe.c,v 1.64 2011/04/10 15:50:34 christos Exp $ */ +/* $NetBSD: linux_pipe.c,v 1.65 2011/04/14 00:59:06 christos Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_pipe.c,v 1.64 2011/04/10 15:50:34 christos Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_pipe.c,v 1.65 2011/04/14 00:59:06 christos Exp $); #include sys/param.h #include sys/systm.h @@ -130,22 +130,3 @@ return linux_pipe_return(l, SCARG(uap, pfds), retval, SCARG(uap, flags)); } - -int -linux_sys_dup3(struct lwp *l, const struct linux_sys_dup3_args *uap, -register_t *retval) -{ - /* { - syscallarg(int) from; - syscallarg(int) to; - syscallarg(int) flags; - } */ - int error; - if ((error = sys_dup2(l, (const struct sys_dup2_args *)uap, retval))) - return error; - - if (SCARG(uap, flags) LINUX_O_CLOEXEC) - fd_set_exclose(l, SCARG(uap, to), true); - - return 0; -}
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: christos Date: Sun Apr 10 15:49:56 UTC 2011 Modified Files: src/sys/compat/linux/common: linux_file.c Log Message: We have O_CLOEXEC now To generate a diff of this commit: cvs rdiff -u -r1.101 -r1.102 src/sys/compat/linux/common/linux_file.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_file.c diff -u src/sys/compat/linux/common/linux_file.c:1.101 src/sys/compat/linux/common/linux_file.c:1.102 --- src/sys/compat/linux/common/linux_file.c:1.101 Fri Nov 19 01:44:37 2010 +++ src/sys/compat/linux/common/linux_file.c Sun Apr 10 11:49:56 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_file.c,v 1.101 2010/11/19 06:44:37 dholland Exp $ */ +/* $NetBSD: linux_file.c,v 1.102 2011/04/10 15:49:56 christos Exp $ */ /*- * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_file.c,v 1.101 2010/11/19 06:44:37 dholland Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_file.c,v 1.102 2011/04/10 15:49:56 christos Exp $); #include sys/param.h #include sys/systm.h @@ -102,6 +102,7 @@ res |= cvtto_bsd_mask(lflags, LINUX_FASYNC, O_ASYNC); res |= cvtto_bsd_mask(lflags, LINUX_O_APPEND, O_APPEND); res |= cvtto_bsd_mask(lflags, LINUX_O_DIRECTORY, O_DIRECTORY); + res |= cvtto_bsd_mask(lflags, LINUX_O_CLOEXEC, O_CLOEXEC); return res; } @@ -123,6 +124,7 @@ res |= cvtto_linux_mask(bflags, O_ASYNC, LINUX_FASYNC); res |= cvtto_linux_mask(bflags, O_APPEND, LINUX_O_APPEND); res |= cvtto_linux_mask(bflags, O_DIRECTORY, LINUX_O_DIRECTORY); + res |= cvtto_linux_mask(bflags, O_CLOEXEC, LINUX_O_CLOEXEC); return res; }
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: christos Date: Sun Apr 10 15:50:34 UTC 2011 Modified Files: src/sys/compat/linux/common: linux_pipe.c Log Message: - implement dup3 and pipe2 - eliminate amd64 ifdef To generate a diff of this commit: cvs rdiff -u -r1.63 -r1.64 src/sys/compat/linux/common/linux_pipe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_pipe.c diff -u src/sys/compat/linux/common/linux_pipe.c:1.63 src/sys/compat/linux/common/linux_pipe.c:1.64 --- src/sys/compat/linux/common/linux_pipe.c:1.63 Wed Jun 18 08:24:18 2008 +++ src/sys/compat/linux/common/linux_pipe.c Sun Apr 10 11:50:34 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_pipe.c,v 1.63 2008/06/18 12:24:18 tsutsui Exp $ */ +/* $NetBSD: linux_pipe.c,v 1.64 2011/04/10 15:50:34 christos Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_pipe.c,v 1.63 2008/06/18 12:24:18 tsutsui Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_pipe.c,v 1.64 2011/04/10 15:50:34 christos Exp $); #include sys/param.h #include sys/systm.h @@ -39,6 +39,8 @@ #include sys/mbuf.h #include sys/mman.h #include sys/mount.h +#include sys/fcntl.h +#include sys/filedesc.h #include sys/sched.h #include sys/syscallargs.h @@ -48,6 +50,7 @@ #include compat/linux/common/linux_signal.h #include compat/linux/common/linux_ipc.h #include compat/linux/common/linux_sem.h +#include compat/linux/common/linux_fcntl.h #include compat/linux/linux_syscallargs.h @@ -59,33 +62,90 @@ * NetBSD passes fd[0] in retval[0], and fd[1] in retval[1]. * Linux directly passes the pointer. */ +static int +linux_pipe_return(struct lwp *l, int *pfds, register_t *retval, int flags) +{ + int error; + + if (sizeof(*retval) != sizeof(*pfds)) { + /* On amd64, sizeof(register_t) != sizeof(int) */ + int rpfds[2]; + rpfds[0] = (int)retval[0]; + rpfds[1] = (int)retval[1]; + + if ((error = copyout(rpfds, pfds, sizeof(rpfds + return error; + } else { + if ((error = copyout(retval, pfds, 2 * sizeof(*pfds + return error; + } + if (flags LINUX_O_CLOEXEC) { + fd_set_exclose(l, retval[0], true); + fd_set_exclose(l, retval[1], true); + } + retval[0] = 0; + return 0; +} + int -linux_sys_pipe(struct lwp *l, const struct linux_sys_pipe_args *uap, register_t *retval) +linux_sys_pipe(struct lwp *l, const struct linux_sys_pipe_args *uap, +register_t *retval) { /* { syscallarg(int *) pfds; } */ int error; -#ifdef __amd64__ - int pfds[2]; -#endif - if ((error = sys_pipe(l, 0, retval))) + if ((error = pipe1(l, retval, 0))) return error; -#ifndef __amd64__ - /* Assumes register_t is an int */ - if ((error = copyout(retval, SCARG(uap, pfds), 2 * sizeof (int + return linux_pipe_return(l, SCARG(uap, pfds), retval, 0); +} + +int +linux_sys_pipe2(struct lwp *l, const struct linux_sys_pipe2_args *uap, +register_t *retval) +{ + /* { + syscallarg(int *) pfds; + syscallarg(int) flags; + } */ + int error; + int flag = 0; + + switch (SCARG(uap, flags)) { + case LINUX_O_CLOEXEC: + break; + case LINUX_O_NONBLOCK: + case LINUX_O_NONBLOCK|LINUX_O_CLOEXEC: + flag = O_NONBLOCK; + break; + default: + return EINVAL; + } + + if ((error = pipe1(l, retval, flag))) return error; -#else - /* On amd64, sizeof(register_t) != sizeof(int) */ - pfds[0] = (int)retval[0]; - pfds[1] = (int)retval[1]; - if ((error = copyout(pfds, SCARG(uap, pfds), sizeof(pfds + return linux_pipe_return(l, SCARG(uap, pfds), retval, + SCARG(uap, flags)); +} + +int +linux_sys_dup3(struct lwp *l, const struct linux_sys_dup3_args *uap, +register_t *retval) +{ + /* { + syscallarg(int) from; + syscallarg(int) to; + syscallarg(int) flags; + } */ + int error; + if ((error = sys_dup2(l, (const struct sys_dup2_args *)uap, retval))) return error; -#endif - retval[0] = 0; + if (SCARG(uap, flags) LINUX_O_CLOEXEC) + fd_set_exclose(l, SCARG(uap, to), true); + return 0; }
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: chs Date: Tue Nov 2 18:03:00 UTC 2010 Modified Files: src/sys/compat/linux/common: linux_socket.c linux_socket.h Log Message: update linux_sys_socket() to understand the flags that are now included in the type parameter. in linux_sys_sendmsg(), if we see an SCM_CREDENTIALS control message, just drop it instead of giving an error. the linux and native versions of the cred-passing operation are very different and some apps (eg. linux pulseaudio library talking to a native server) will work without the control data. To generate a diff of this commit: cvs rdiff -u -r1.107 -r1.108 src/sys/compat/linux/common/linux_socket.c cvs rdiff -u -r1.19 -r1.20 src/sys/compat/linux/common/linux_socket.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_socket.c diff -u src/sys/compat/linux/common/linux_socket.c:1.107 src/sys/compat/linux/common/linux_socket.c:1.108 --- src/sys/compat/linux/common/linux_socket.c:1.107 Sat Nov 28 22:11:42 2009 +++ src/sys/compat/linux/common/linux_socket.c Tue Nov 2 18:02:59 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_socket.c,v 1.107 2009/11/28 22:11:42 dsl Exp $ */ +/* $NetBSD: linux_socket.c,v 1.108 2010/11/02 18:02:59 chs Exp $ */ /*- * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_socket.c,v 1.107 2009/11/28 22:11:42 dsl Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_socket.c,v 1.108 2010/11/02 18:02:59 chs Exp $); #if defined(_KERNEL_OPT) #include opt_inet.h @@ -70,6 +70,7 @@ #include sys/kauth.h #include sys/syscallargs.h #include sys/ktrace.h +#include sys/fcntl.h #include lib/libkern/libkern.h @@ -84,6 +85,7 @@ #include compat/linux/common/linux_signal.h #include compat/linux/common/linux_ioctl.h #include compat/linux/common/linux_socket.h +#include compat/linux/common/linux_fcntl.h #if !defined(__alpha__) !defined(__amd64__) #include compat/linux/common/linux_socketcall.h #endif @@ -200,13 +202,13 @@ {MSG_DONTWAIT, LINUX_MSG_DONTWAIT}, {MSG_BCAST, 0}, /* not supported, clear */ {MSG_MCAST, 0}, /* not supported, clear */ + {MSG_NOSIGNAL, LINUX_MSG_NOSIGNAL}, {-1, /* not supp */ LINUX_MSG_PROBE}, {-1, /* not supp */ LINUX_MSG_FIN}, {-1, /* not supp */ LINUX_MSG_SYN}, {-1, /* not supp */ LINUX_MSG_CONFIRM}, {-1, /* not supp */ LINUX_MSG_RST}, {-1, /* not supp */ LINUX_MSG_ERRQUEUE}, - {-1, /* not supp */ LINUX_MSG_NOSIGNAL}, {-1, /* not supp */ LINUX_MSG_MORE}, }; @@ -297,15 +299,46 @@ syscallarg(int) protocol; } */ struct sys___socket30_args bsa; - int error; + struct sys_fcntl_args fsa; + register_t fretval[2]; + int error, flags; + SCARG(bsa, protocol) = SCARG(uap, protocol); - SCARG(bsa, type) = SCARG(uap, type); + SCARG(bsa, type) = SCARG(uap, type) LINUX_SOCK_TYPE_MASK; SCARG(bsa, domain) = linux_to_bsd_domain(SCARG(uap, domain)); if (SCARG(bsa, domain) == -1) return EINVAL; + flags = SCARG(uap, type) ~LINUX_SOCK_TYPE_MASK; + if (flags ~(LINUX_SOCK_CLOEXEC | LINUX_SOCK_NONBLOCK)) + return EINVAL; error = sys___socket30(l, bsa, retval); + /* + * Linux overloads the type parameter to include some + * fcntl flags to be set on the file descriptor. + * Process those if creating the socket succeeded. + */ + + if (!error flags LINUX_SOCK_CLOEXEC) { + SCARG(fsa, fd) = *retval; + SCARG(fsa, cmd) = F_SETFD; + SCARG(fsa, arg) = (void *)(uintptr_t)FD_CLOEXEC; + (void) sys_fcntl(l, fsa, fretval); + } + if (!error flags LINUX_SOCK_NONBLOCK) { + SCARG(fsa, fd) = *retval; + SCARG(fsa, cmd) = F_SETFL; + SCARG(fsa, arg) = (void *)(uintptr_t)O_NONBLOCK; + error = sys_fcntl(l, fsa, fretval); + if (error) { + struct sys_close_args csa; + + SCARG(csa, fd) = *retval; + (void) sys_close(l, csa, fretval); + } + } + #ifdef INET6 /* * Linux AF_INET6 socket has IPV6_V6ONLY setsockopt set to 0 by @@ -505,6 +538,14 @@ /* Linux SCM_RIGHTS is same as NetBSD */ break; +case LINUX_SCM_CREDENTIALS: + /* no native equivalent, just drop it */ + m_free(ctl_mbuf); + ctl_mbuf = NULL; + msg.msg_control = NULL; + msg.msg_controllen = 0; + goto skipcmsg; + default: /* other types not supported */ error = EINVAL; @@ -545,7 +586,7 @@ cmsg-cmsg_level = l_cmsg.cmsg_level; cmsg-cmsg_type = l_cmsg.cmsg_type; - /* Zero are between header and data */ + /* Zero area between header and data */ memset(cmsg + 1, 0, CMSG_ALIGN(sizeof(cmsg)) - sizeof(cmsg)); @@ -575,6 +616,7 @@ msg.msg_controllen); } +skipcmsg: error = do_sys_sendmsg(l, SCARG(uap, s), msg, bflags, retval); /* Freed internally */ ctl_mbuf = NULL; Index: src/sys/compat/linux/common/linux_socket.h diff -u src/sys/compat/linux/common/linux_socket.h:1.19 src/sys/compat/linux/common/linux_socket.h:1.20
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: joerg Date: Mon Nov 16 08:44:21 UTC 2009 Modified Files: src/sys/compat/linux/common: linux_ipc.c Log Message: Make sure to never leak padding space before copyout or copyin uninitialized fields by explicitly using memset in the conversion routines. To generate a diff of this commit: cvs rdiff -u -r1.53 -r1.54 src/sys/compat/linux/common/linux_ipc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_ipc.c diff -u src/sys/compat/linux/common/linux_ipc.c:1.53 src/sys/compat/linux/common/linux_ipc.c:1.54 --- src/sys/compat/linux/common/linux_ipc.c:1.53 Thu Apr 23 17:40:57 2009 +++ src/sys/compat/linux/common/linux_ipc.c Mon Nov 16 08:44:19 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_ipc.c,v 1.53 2009/04/23 17:40:57 njoly Exp $ */ +/* $NetBSD: linux_ipc.c,v 1.54 2009/11/16 08:44:19 joerg Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_ipc.c,v 1.53 2009/04/23 17:40:57 njoly Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_ipc.c,v 1.54 2009/11/16 08:44:19 joerg Exp $); #if defined(_KERNEL_OPT) #include opt_sysv.h @@ -306,6 +306,7 @@ linux_to_bsd_msqid_ds(struct linux_msqid_ds *lmp, struct msqid_ds *bmp) { + memset(bmp, 0, sizeof(*bmp)); linux_to_bsd_ipc_perm(lmp-l_msg_perm, bmp-msg_perm); bmp-_msg_first = lmp-l_msg_first; bmp-_msg_last = lmp-l_msg_last; @@ -322,6 +323,8 @@ void linux_to_bsd_msqid64_ds(struct linux_msqid64_ds *lmp, struct msqid_ds *bmp) { + + memset(bmp, 0, sizeof(*bmp)); linux_to_bsd_ipc64_perm(lmp-l_msg_perm, bmp-msg_perm); bmp-msg_stime = lmp-l_msg_stime; bmp-msg_rtime = lmp-l_msg_rtime; @@ -337,6 +340,7 @@ bsd_to_linux_msqid_ds(struct msqid_ds *bmp, struct linux_msqid_ds *lmp) { + memset(lmp, 0, sizeof(*lmp)); bsd_to_linux_ipc_perm(bmp-msg_perm, lmp-l_msg_perm); lmp-l_msg_first = bmp-_msg_first; lmp-l_msg_last = bmp-_msg_last; @@ -353,6 +357,8 @@ void bsd_to_linux_msqid64_ds(struct msqid_ds *bmp, struct linux_msqid64_ds *lmp) { + + memset(lmp, 0, sizeof(*lmp)); bsd_to_linux_ipc64_perm(bmp-msg_perm, lmp-l_msg_perm); lmp-l_msg_stime = bmp-msg_stime; lmp-l_msg_rtime = bmp-msg_rtime;
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: njoly Date: Thu Sep 3 17:15:17 UTC 2009 Modified Files: src/sys/compat/linux/common: linux_sched.c Log Message: Use correct sched_setscheduler syscall 3rd argument type. To generate a diff of this commit: cvs rdiff -u -r1.60 -r1.61 src/sys/compat/linux/common/linux_sched.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_sched.c diff -u src/sys/compat/linux/common/linux_sched.c:1.60 src/sys/compat/linux/common/linux_sched.c:1.61 --- src/sys/compat/linux/common/linux_sched.c:1.60 Tue Jun 23 13:18:59 2009 +++ src/sys/compat/linux/common/linux_sched.c Thu Sep 3 17:15:17 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_sched.c,v 1.60 2009/06/23 13:18:59 njoly Exp $ */ +/* $NetBSD: linux_sched.c,v 1.61 2009/09/03 17:15:17 njoly Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_sched.c,v 1.60 2009/06/23 13:18:59 njoly Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_sched.c,v 1.61 2009/09/03 17:15:17 njoly Exp $); #include sys/param.h #include sys/mount.h @@ -351,7 +351,7 @@ /* { syscallarg(linux_pid_t) pid; syscallarg(int) policy; - syscallarg(cont struct linux_sched_scheduler *) sp; + syscallarg(cont struct linux_sched_param *) sp; } */ int error, policy; struct linux_sched_param lp;
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: dholland Date: Fri Aug 28 01:39:03 UTC 2009 Modified Files: src/sys/compat/linux/common: linux_uselib.c Log Message: Another one that needs sys/exec_aout.h. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/sys/compat/linux/common/linux_uselib.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_uselib.c diff -u src/sys/compat/linux/common/linux_uselib.c:1.29 src/sys/compat/linux/common/linux_uselib.c:1.30 --- src/sys/compat/linux/common/linux_uselib.c:1.29 Sat Aug 15 23:39:35 2009 +++ src/sys/compat/linux/common/linux_uselib.c Fri Aug 28 01:39:03 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_uselib.c,v 1.29 2009/08/15 23:39:35 matt Exp $ */ +/* $NetBSD: linux_uselib.c,v 1.30 2009/08/28 01:39:03 dholland Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_uselib.c,v 1.29 2009/08/15 23:39:35 matt Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_uselib.c,v 1.30 2009/08/28 01:39:03 dholland Exp $); #include sys/param.h #include sys/systm.h @@ -41,6 +41,7 @@ #include sys/vnode.h #include sys/mount.h #include sys/exec.h +#include sys/exec_aout.h #include sys/mman.h #include sys/syscallargs.h @@ -48,11 +49,6 @@ #include sys/cpu.h #include machine/reg.h -#ifndef EXEC_AOUT -/* define EXEC_AOUT to get prototype from linux_syscall.h */ -#define EXEC_AOUT -#endif - #include compat/linux/common/linux_types.h #include compat/linux/common/linux_signal.h #include compat/linux/common/linux_util.h @@ -61,6 +57,11 @@ #include compat/linux/common/linux_ipc.h #include compat/linux/common/linux_sem.h +#ifndef EXEC_AOUT +/* define EXEC_AOUT to get prototype from linux_syscall.h */ +#define EXEC_AOUT +#endif + #include compat/linux/linux_syscallargs.h #include compat/linux/linux_syscall.h
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: drochner Date: Tue Aug 18 11:22:09 UTC 2009 Modified Files: src/sys/compat/linux/common: linux_ipccall.c linux_ipccall.h Log Message: remove some inline from functions which are defined in a .c file but used elsewhere -- gcc-4.4.1 doesn't like it and I doubt it had any effect To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/sys/compat/linux/common/linux_ipccall.c cvs rdiff -u -r1.14 -r1.15 src/sys/compat/linux/common/linux_ipccall.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_ipccall.c diff -u src/sys/compat/linux/common/linux_ipccall.c:1.31 src/sys/compat/linux/common/linux_ipccall.c:1.32 --- src/sys/compat/linux/common/linux_ipccall.c:1.31 Mon Apr 28 20:23:43 2008 +++ src/sys/compat/linux/common/linux_ipccall.c Tue Aug 18 11:22:09 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_ipccall.c,v 1.31 2008/04/28 20:23:43 martin Exp $ */ +/* $NetBSD: linux_ipccall.c,v 1.32 2009/08/18 11:22:09 drochner Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_ipccall.c,v 1.31 2008/04/28 20:23:43 martin Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_ipccall.c,v 1.32 2009/08/18 11:22:09 drochner Exp $); #if defined(_KERNEL_OPT) #include opt_sysv.h @@ -160,7 +160,7 @@ } #ifdef SYSVSEM -inline int +int linux_semop(struct lwp *l, const struct linux_sys_ipc_args *uap, register_t *retval) { /* { @@ -179,7 +179,7 @@ return sys_semop(l, bsa, retval); } -inline int +int linux_semget(struct lwp *l, const struct linux_sys_ipc_args *uap, register_t *retval) { /* { @@ -202,7 +202,7 @@ #ifdef SYSVMSG -inline int +int linux_msgsnd(struct lwp *l, const struct linux_sys_ipc_args *uap, register_t *retval) { struct sys_msgsnd_args bma; @@ -215,7 +215,7 @@ return sys_msgsnd(l, bma, retval); } -inline int +int linux_msgrcv(struct lwp *l, const struct linux_sys_ipc_args *uap, register_t *retval) { struct sys_msgrcv_args bma; @@ -234,7 +234,7 @@ return sys_msgrcv(l, bma, retval); } -inline int +int linux_msgget(struct lwp *l, const struct linux_sys_ipc_args *uap, register_t *retval) { struct sys_msgget_args bma; @@ -252,7 +252,7 @@ * shmdt(): this could have been mapped directly, if it wasn't for * the extra indirection by the linux_ipc system call. */ -inline int +int linux_shmdt(struct lwp *l, const struct linux_sys_ipc_args *uap, register_t *retval) { struct sys_shmdt_args bsa; @@ -265,7 +265,7 @@ /* * Same story as shmdt. */ -inline int +int linux_shmget(struct lwp *l, const struct linux_sys_ipc_args *uap, register_t *retval) { struct linux_sys_shmget_args bsa; Index: src/sys/compat/linux/common/linux_ipccall.h diff -u src/sys/compat/linux/common/linux_ipccall.h:1.14 src/sys/compat/linux/common/linux_ipccall.h:1.15 --- src/sys/compat/linux/common/linux_ipccall.h:1.14 Mon Apr 28 20:23:43 2008 +++ src/sys/compat/linux/common/linux_ipccall.h Tue Aug 18 11:22:09 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_ipccall.h,v 1.14 2008/04/28 20:23:43 martin Exp $ */ +/* $NetBSD: linux_ipccall.h,v 1.15 2009/08/18 11:22:09 drochner Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -59,27 +59,27 @@ # ifdef SYSVSEM -__inline int linux_semop(struct lwp *, const struct linux_sys_ipc_args *, +int linux_semop(struct lwp *, const struct linux_sys_ipc_args *, register_t *); -__inline int linux_semget(struct lwp *, const struct linux_sys_ipc_args *, +int linux_semget(struct lwp *, const struct linux_sys_ipc_args *, register_t *); # endif # ifdef SYSVMSG -__inline int linux_msgsnd(struct lwp *, const struct linux_sys_ipc_args *, +int linux_msgsnd(struct lwp *, const struct linux_sys_ipc_args *, register_t *); -__inline int linux_msgrcv(struct lwp *, const struct linux_sys_ipc_args *, +int linux_msgrcv(struct lwp *, const struct linux_sys_ipc_args *, register_t *); -__inline int linux_msgget(struct lwp *, const struct linux_sys_ipc_args *, +int linux_msgget(struct lwp *, const struct linux_sys_ipc_args *, register_t *); # endif # ifdef SYSVSHM -__inline int linux_shmdt(struct lwp *, const struct linux_sys_ipc_args *, +int linux_shmdt(struct lwp *, const struct linux_sys_ipc_args *, register_t *); -__inline int linux_shmget(struct lwp *, const struct linux_sys_ipc_args *, +int linux_shmget(struct lwp *, const struct linux_sys_ipc_args *, register_t *); # endif
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: christos Date: Tue Aug 18 02:04:14 UTC 2009 Modified Files: src/sys/compat/linux/common: linux_oldmmap.c Log Message: more debugging for mmap To generate a diff of this commit: cvs rdiff -u -r1.71 -r1.72 src/sys/compat/linux/common/linux_oldmmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_oldmmap.c diff -u src/sys/compat/linux/common/linux_oldmmap.c:1.71 src/sys/compat/linux/common/linux_oldmmap.c:1.72 --- src/sys/compat/linux/common/linux_oldmmap.c:1.71 Wed Dec 3 07:51:11 2008 +++ src/sys/compat/linux/common/linux_oldmmap.c Mon Aug 17 22:04:14 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_oldmmap.c,v 1.71 2008/12/03 12:51:11 ad Exp $ */ +/* $NetBSD: linux_oldmmap.c,v 1.72 2009/08/18 02:04:14 christos Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_oldmmap.c,v 1.71 2008/12/03 12:51:11 ad Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_oldmmap.c,v 1.72 2009/08/18 02:04:14 christos Exp $); #include sys/param.h #include sys/systm.h @@ -86,8 +86,10 @@ if ((error = copyin(SCARG(uap, lmp), lmap, sizeof lmap))) return error; - if (lmap.lm_offset PAGE_MASK) + if (lmap.lm_offset PAGE_MASK) { + DPRINTF((old_mmap: 0x%x\n, lmap.lm_offset)); return EINVAL; + } SCARG(nlmap,addr) = lmap.lm_addr; SCARG(nlmap,len) = lmap.lm_len; @@ -95,9 +97,10 @@ SCARG(nlmap,flags) = lmap.lm_flags; SCARG(nlmap,fd) = lmap.lm_fd; SCARG(nlmap,offset) = lmap.lm_offset; - DPRINTF((old_mmap(%#x, %u, %u, %u, %d, %u)\n, + error = linux_sys_mmap(l, nlmap, retval); + DPRINTF((old_mmap(%#x, %u, %u, %u, %d, %u) = %d\n, lmap.lm_addr, lmap.lm_len, lmap.lm_prot, lmap.lm_flags, - lmap.lm_fd, lmap.lm_offset)); - return linux_sys_mmap(l, nlmap, retval); + lmap.lm_fd, lmap.lm_offset, error)); + return error; }
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: njoly Date: Tue Jul 21 18:42:56 UTC 2009 Modified Files: src/sys/compat/linux/common: linux_time.c Log Message: Do reject unknown/invalid linux clockid. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/sys/compat/linux/common/linux_time.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_time.c diff -u src/sys/compat/linux/common/linux_time.c:1.28 src/sys/compat/linux/common/linux_time.c:1.29 --- src/sys/compat/linux/common/linux_time.c:1.28 Sun Jan 11 02:45:48 2009 +++ src/sys/compat/linux/common/linux_time.c Tue Jul 21 18:42:56 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_time.c,v 1.28 2009/01/11 02:45:48 christos Exp $ */ +/* $NetBSD: linux_time.c,v 1.29 2009/07/21 18:42:56 njoly Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_time.c,v 1.28 2009/01/11 02:45:48 christos Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_time.c,v 1.29 2009/07/21 18:42:56 njoly Exp $); #include sys/param.h #include sys/ucred.h @@ -181,6 +181,7 @@ case LINUX_CLOCK_THREAD_CPUTIME_ID: case LINUX_CLOCK_REALTIME_HR: case LINUX_CLOCK_MONOTONIC_HR: + default: return EINVAL; }
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: njoly Date: Thu Jun 18 20:36:28 UTC 2009 Modified Files: src/sys/compat/linux/common: linux_sched.c Log Message: In linux_sys_sched_getaffinity(), do not leak memory on error. To generate a diff of this commit: cvs rdiff -u -r1.58 -r1.59 src/sys/compat/linux/common/linux_sched.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_sched.c diff -u src/sys/compat/linux/common/linux_sched.c:1.58 src/sys/compat/linux/common/linux_sched.c:1.59 --- src/sys/compat/linux/common/linux_sched.c:1.58 Sat Oct 25 23:38:28 2008 +++ src/sys/compat/linux/common/linux_sched.c Thu Jun 18 20:36:28 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_sched.c,v 1.58 2008/10/25 23:38:28 christos Exp $ */ +/* $NetBSD: linux_sched.c,v 1.59 2009/06/18 20:36:28 njoly Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_sched.c,v 1.58 2008/10/25 23:38:28 christos Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_sched.c,v 1.59 2009/06/18 20:36:28 njoly Exp $); #include sys/param.h #include sys/mount.h @@ -646,12 +646,11 @@ retp = (int *)data[SCARG(uap, len) - sizeof(ret)]; *retp = ret; - if ((error = copyout(data, SCARG(uap, mask), SCARG(uap, len))) != 0) - return error; + error = copyout(data, SCARG(uap, mask), SCARG(uap, len)); free(data, M_TEMP); - return 0; + return error; }
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: njoly Date: Tue Jun 16 22:56:49 UTC 2009 Modified Files: src/sys/compat/linux/common: linux_socket.c Log Message: For linux cmsg header copyout, use the linux structure size, not the native one. To generate a diff of this commit: cvs rdiff -u -r1.101 -r1.102 src/sys/compat/linux/common/linux_socket.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_socket.c diff -u src/sys/compat/linux/common/linux_socket.c:1.101 src/sys/compat/linux/common/linux_socket.c:1.102 --- src/sys/compat/linux/common/linux_socket.c:1.101 Tue Jun 16 15:56:10 2009 +++ src/sys/compat/linux/common/linux_socket.c Tue Jun 16 22:56:49 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_socket.c,v 1.101 2009/06/16 15:56:10 njoly Exp $ */ +/* $NetBSD: linux_socket.c,v 1.102 2009/06/16 22:56:49 njoly Exp $ */ /*- * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_socket.c,v 1.101 2009/06/16 15:56:10 njoly Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_socket.c,v 1.102 2009/06/16 22:56:49 njoly Exp $); #if defined(_KERNEL_OPT) #include opt_inet.h @@ -658,7 +658,7 @@ } /* There can be padding between the header and data... */ - error = copyout(linux_cmsg, q, sizeof *cmsg); + error = copyout(linux_cmsg, q, sizeof linux_cmsg); if (error != 0) { error = copyout(CCMSG_DATA(cmsg), q + sizeof linux_cmsg, dlen);
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: njoly Date: Tue Jun 16 23:17:02 UTC 2009 Modified Files: src/sys/compat/linux/common: linux_socket.c linux_socket.h Log Message: Add LINUX_CMSG_{SPACE,LEN} macros. Use then when calculating the msg_controllen size, when converting the control message buffer from native (previous version was missing the linux_cmsghdr size). To generate a diff of this commit: cvs rdiff -u -r1.102 -r1.103 src/sys/compat/linux/common/linux_socket.c cvs rdiff -u -r1.16 -r1.17 src/sys/compat/linux/common/linux_socket.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_socket.c diff -u src/sys/compat/linux/common/linux_socket.c:1.102 src/sys/compat/linux/common/linux_socket.c:1.103 --- src/sys/compat/linux/common/linux_socket.c:1.102 Tue Jun 16 22:56:49 2009 +++ src/sys/compat/linux/common/linux_socket.c Tue Jun 16 23:17:02 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_socket.c,v 1.102 2009/06/16 22:56:49 njoly Exp $ */ +/* $NetBSD: linux_socket.c,v 1.103 2009/06/16 23:17:02 njoly Exp $ */ /*- * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_socket.c,v 1.102 2009/06/16 22:56:49 njoly Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_socket.c,v 1.103 2009/06/16 23:17:02 njoly Exp $); #if defined(_KERNEL_OPT) #include opt_inet.h @@ -669,11 +669,11 @@ break; } m = m-m_next; - if (m == NULL || q + LINUX_CMSG_ALIGN(dlen) q_end) { - q += dlen; + if (m == NULL || q + LINUX_CMSG_SPACE(dlen) q_end) { + q += LINUX_CMSG_LEN(dlen); break; } - q += LINUX_CMSG_ALIGN(dlen); + q += LINUX_CMSG_SPACE(dlen); } done: Index: src/sys/compat/linux/common/linux_socket.h diff -u src/sys/compat/linux/common/linux_socket.h:1.16 src/sys/compat/linux/common/linux_socket.h:1.17 --- src/sys/compat/linux/common/linux_socket.h:1.16 Mon Apr 28 20:23:44 2008 +++ src/sys/compat/linux/common/linux_socket.h Tue Jun 16 23:17:02 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_socket.h,v 1.16 2008/04/28 20:23:44 martin Exp $ */ +/* $NetBSD: linux_socket.h,v 1.17 2009/06/16 23:17:02 njoly Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -179,6 +179,10 @@ ((mhdr)-msg_controllen = sizeof(struct linux_cmsghdr) ? \ (struct linux_cmsghdr *)(mhdr)-msg_control : NULL) +#define LINUX_CMSG_SPACE(l) \ + (sizeof(struct linux_cmsghdr) + LINUX_CMSG_ALIGN(l)) +#define LINUX_CMSG_LEN(l) \ + (sizeof(struct linux_cmsghdr) + (l)) /* * Machine specific definitions.
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: pooka Date: Fri May 15 17:02:54 UTC 2009 Modified Files: src/sys/compat/linux/common: linux_file64.c linux_misc.c Log Message: pad - PAD To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/sys/compat/linux/common/linux_file64.c cvs rdiff -u -r1.207 -r1.208 src/sys/compat/linux/common/linux_misc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_file64.c diff -u src/sys/compat/linux/common/linux_file64.c:1.48 src/sys/compat/linux/common/linux_file64.c:1.49 --- src/sys/compat/linux/common/linux_file64.c:1.48 Tue Jun 24 11:18:15 2008 +++ src/sys/compat/linux/common/linux_file64.c Fri May 15 17:02:54 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_file64.c,v 1.48 2008/06/24 11:18:15 ad Exp $ */ +/* $NetBSD: linux_file64.c,v 1.49 2009/05/15 17:02:54 pooka Exp $ */ /*- * Copyright (c) 1995, 1998, 2000, 2008 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_file64.c,v 1.48 2008/06/24 11:18:15 ad Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_file64.c,v 1.49 2009/05/15 17:02:54 pooka Exp $); #include sys/param.h #include sys/systm.h @@ -181,7 +181,7 @@ /* Linux doesn't have the 'pad' pseudo-parameter */ SCARG(ta, path) = SCARG(uap, path); - SCARG(ta, pad) = 0; + SCARG(ta, PAD) = 0; SCARG(ta, length) = SCARG(uap, length); return sys_truncate(l, ta, retval); @@ -198,7 +198,7 @@ /* Linux doesn't have the 'pad' pseudo-parameter */ SCARG(ta, fd) = SCARG(uap, fd); - SCARG(ta, pad) = 0; + SCARG(ta, PAD) = 0; SCARG(ta, length) = SCARG(uap, length); return sys_ftruncate(l, ta, retval); Index: src/sys/compat/linux/common/linux_misc.c diff -u src/sys/compat/linux/common/linux_misc.c:1.207 src/sys/compat/linux/common/linux_misc.c:1.208 --- src/sys/compat/linux/common/linux_misc.c:1.207 Sun Mar 29 19:21:19 2009 +++ src/sys/compat/linux/common/linux_misc.c Fri May 15 17:02:54 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_misc.c,v 1.207 2009/03/29 19:21:19 christos Exp $ */ +/* $NetBSD: linux_misc.c,v 1.208 2009/05/15 17:02:54 pooka Exp $ */ /*- * Copyright (c) 1995, 1998, 1999, 2008 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_misc.c,v 1.207 2009/03/29 19:21:19 christos Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_misc.c,v 1.208 2009/05/15 17:02:54 pooka Exp $); #include sys/param.h #include sys/systm.h @@ -485,7 +485,7 @@ SCARG(cma, prot) |= VM_PROT_READ; SCARG(cma, flags) = flags; SCARG(cma, fd) = flags MAP_ANON ? -1 : SCARG(uap, fd); - SCARG(cma, pad) = 0; + SCARG(cma, PAD) = 0; } #define LINUX_MREMAP_MAYMOVE 1
CVS commit: src/sys/compat/linux/common
Module Name:src Committed By: njoly Date: Thu Apr 23 17:40:58 UTC 2009 Modified Files: src/sys/compat/linux/common: linux_ipc.c Log Message: Add IPC_64 support for all semctl(2)/msgctl(2). Needed, at least on i386 for Linux 2.6 emulation. To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 src/sys/compat/linux/common/linux_ipc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/common/linux_ipc.c diff -u src/sys/compat/linux/common/linux_ipc.c:1.52 src/sys/compat/linux/common/linux_ipc.c:1.53 --- src/sys/compat/linux/common/linux_ipc.c:1.52 Wed Feb 18 14:30:43 2009 +++ src/sys/compat/linux/common/linux_ipc.c Thu Apr 23 17:40:57 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: linux_ipc.c,v 1.52 2009/02/18 14:30:43 njoly Exp $ */ +/* $NetBSD: linux_ipc.c,v 1.53 2009/04/23 17:40:57 njoly Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: linux_ipc.c,v 1.52 2009/02/18 14:30:43 njoly Exp $); +__KERNEL_RCSID(0, $NetBSD: linux_ipc.c,v 1.53 2009/04/23 17:40:57 njoly Exp $); #if defined(_KERNEL_OPT) #include opt_sysv.h @@ -209,33 +209,27 @@ lcmd = SCARG(uap, cmd); #ifdef LINUX_IPC_FORCE64 - if (lcmd == LINUX_IPC_STAT || lcmd == LINUX_IPC_SET) - lcmd |= LINUX_IPC_64; + lcmd |= LINUX_IPC_64; #endif - switch (lcmd) { + switch (lcmd ~LINUX_IPC_64) { case LINUX_IPC_SET: - error = copyin(SCARG(uap, arg).l_buf, lsembuf, - sizeof(lsembuf)); - if (error) - return (error); - linux_to_bsd_semid_ds(lsembuf, sembuf); - pass_arg = sembuf; - cmd = IPC_SET; - break; - - case LINUX_IPC_SET | LINUX_IPC_64: - error = copyin(SCARG(uap, arg).l_buf, lsembuf64, - sizeof(lsembuf64)); + if (lcmd LINUX_IPC_64) { + error = copyin(SCARG(uap, arg).l_buf, lsembuf64, + sizeof(lsembuf64)); + linux_to_bsd_semid64_ds(lsembuf64, sembuf); + } else { + error = copyin(SCARG(uap, arg).l_buf, lsembuf, + sizeof(lsembuf)); + linux_to_bsd_semid_ds(lsembuf, sembuf); + } if (error) return (error); - linux_to_bsd_semid64_ds(lsembuf64, sembuf); pass_arg = sembuf; cmd = IPC_SET; break; case LINUX_IPC_STAT: - case LINUX_IPC_STAT | LINUX_IPC_64: pass_arg = sembuf; cmd = IPC_STAT; break; @@ -385,27 +379,24 @@ lcmd = SCARG(uap, cmd); #ifdef LINUX_IPC_FORCE64 - if (lcmd == LINUX_IPC_STAT || lcmd == LINUX_IPC_SET) - lcmd |= LINUX_IPC_64; + lcmd |= LINUX_IPC_64; #endif - switch (lcmd) { + switch (lcmd ~LINUX_IPC_64) { case LINUX_IPC_STAT: - case LINUX_IPC_STAT|LINUX_IPC_64: cmd = IPC_STAT; bmp = bm; break; case LINUX_IPC_SET: - if ((error = copyin(SCARG(uap, buf), lm, sizeof lm))) - return error; - linux_to_bsd_msqid_ds(lm, bm); - cmd = IPC_SET; - bmp = bm; - break; - case LINUX_IPC_SET|LINUX_IPC_64: - if ((error = copyin(SCARG(uap, buf), lm64, sizeof lm64))) + if (lcmd LINUX_IPC_64) { + error = copyin(SCARG(uap, buf), lm64, sizeof lm64); + linux_to_bsd_msqid64_ds(lm64, bm); + } else { + error = copyin(SCARG(uap, buf), lm, sizeof lm); + linux_to_bsd_msqid_ds(lm, bm); + } + if (error) return error; - linux_to_bsd_msqid64_ds(lm64, bm); cmd = IPC_SET; bmp = bm; break;