CVS commit: src/sys/ufs/lfs
Module Name:src Committed By: dholland Date: Wed Nov 9 05:44:42 UTC 2016 Modified Files: src/sys/ufs/lfs: ulfs_extattr.c Log Message: Apply ufs_extattr.c 1.48: Explain why the lock in here needs to be recursive. Related to PR 46997. ufs_extattr 1.47 was also committed directly here, so this file is still fully synced with it. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/ufs/lfs/ulfs_extattr.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/ufs/lfs/ulfs_extattr.c diff -u src/sys/ufs/lfs/ulfs_extattr.c:1.13 src/sys/ufs/lfs/ulfs_extattr.c:1.14 --- src/sys/ufs/lfs/ulfs_extattr.c:1.13 Thu Jul 7 06:55:44 2016 +++ src/sys/ufs/lfs/ulfs_extattr.c Wed Nov 9 05:44:42 2016 @@ -1,5 +1,5 @@ -/* $NetBSD: ulfs_extattr.c,v 1.13 2016/07/07 06:55:44 msaitoh Exp $ */ -/* from NetBSD: ufs_extattr.c,v 1.46 2014/11/19 16:26:47 manu Exp */ +/* $NetBSD: ulfs_extattr.c,v 1.14 2016/11/09 05:44:42 dholland Exp $ */ +/* from NetBSD: ulfs_extattr.c,v 1.48 2016/11/09 05:08:35 dholland Exp */ /*- * Copyright (c) 1999-2002 Robert N. M. Watson @@ -49,7 +49,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ulfs_extattr.c,v 1.13 2016/07/07 06:55:44 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ulfs_extattr.c,v 1.14 2016/11/09 05:44:42 dholland Exp $"); #ifdef _KERNEL_OPT #include "opt_lfs.h" @@ -168,7 +168,13 @@ static void ulfs_extattr_uepm_lock(struct ulfsmount *ump) { - /* XXX Why does this need to be recursive? */ + /* + * XXX This needs to be recursive for the following reasons: + * - it is taken in ulfs_extattr_vnode_inactive + * - which is called from VOP_INACTIVE + * - which can be triggered by any vrele, vput, or vn_close + * - several of these can happen while it's held + */ if (mutex_owned(>um_extattr.uepm_lock)) { ump->um_extattr.uepm_lockcnt++; return;
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: dholland Date: Wed Nov 9 05:08:35 UTC 2016 Modified Files: src/sys/ufs/ufs: ufs_extattr.c Log Message: Explain why the lock in here needs to be recursive. Related to PR 46997. To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/sys/ufs/ufs/ufs_extattr.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/ufs/ufs/ufs_extattr.c diff -u src/sys/ufs/ufs/ufs_extattr.c:1.47 src/sys/ufs/ufs/ufs_extattr.c:1.48 --- src/sys/ufs/ufs/ufs_extattr.c:1.47 Thu Jul 7 06:55:44 2016 +++ src/sys/ufs/ufs/ufs_extattr.c Wed Nov 9 05:08:35 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_extattr.c,v 1.47 2016/07/07 06:55:44 msaitoh Exp $ */ +/* $NetBSD: ufs_extattr.c,v 1.48 2016/11/09 05:08:35 dholland Exp $ */ /*- * Copyright (c) 1999-2002 Robert N. M. Watson @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_extattr.c,v 1.47 2016/07/07 06:55:44 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_extattr.c,v 1.48 2016/11/09 05:08:35 dholland Exp $"); #ifdef _KERNEL_OPT #include "opt_ffs.h" @@ -168,7 +168,13 @@ static void ufs_extattr_uepm_lock(struct ufsmount *ump) { - /* XXX Why does this need to be recursive? */ + /* + * XXX This needs to be recursive for the following reasons: + * - it is taken in ufs_extattr_vnode_inactive + * - which is called from VOP_INACTIVE + * - which can be triggered by any vrele, vput, or vn_close + * - several of these can happen while it's held + */ if (mutex_owned(>um_extattr.uepm_lock)) { ump->um_extattr.uepm_lockcnt++; return;
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: dholland Date: Wed Nov 9 04:12:55 UTC 2016 Modified Files: src/sys/ufs/ufs: ufs_vnops.c Log Message: ufs_makeinode is declared file-static at the top of the file; mark it at its definition too, for consistency and to avoid misleading casual passersby. To generate a diff of this commit: cvs rdiff -u -r1.233 -r1.234 src/sys/ufs/ufs/ufs_vnops.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/ufs/ufs/ufs_vnops.c diff -u src/sys/ufs/ufs/ufs_vnops.c:1.233 src/sys/ufs/ufs/ufs_vnops.c:1.234 --- src/sys/ufs/ufs/ufs_vnops.c:1.233 Fri Oct 28 20:38:12 2016 +++ src/sys/ufs/ufs/ufs_vnops.c Wed Nov 9 04:12:55 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_vnops.c,v 1.233 2016/10/28 20:38:12 jdolecek Exp $ */ +/* $NetBSD: ufs_vnops.c,v 1.234 2016/11/09 04:12:55 dholland Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -66,7 +66,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.233 2016/10/28 20:38:12 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_vnops.c,v 1.234 2016/11/09 04:12:55 dholland Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -1764,7 +1764,7 @@ ufs_vinit(struct mount *mntp, int (**spe /* * Allocate a new inode. */ -int +static int ufs_makeinode(struct vattr *vap, struct vnode *dvp, const struct ufs_lookup_results *ulr, struct vnode **vpp, struct componentname *cnp)
CVS commit: src/sys/netinet6
Module Name:src Committed By: ozaki-r Date: Wed Nov 9 03:49:38 UTC 2016 Modified Files: src/sys/netinet6: frag6.c Log Message: Reduce the number of return points of frag6_input No functional change. To generate a diff of this commit: cvs rdiff -u -r1.56 -r1.57 src/sys/netinet6/frag6.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/netinet6/frag6.c diff -u src/sys/netinet6/frag6.c:1.56 src/sys/netinet6/frag6.c:1.57 --- src/sys/netinet6/frag6.c:1.56 Fri Sep 5 05:33:06 2014 +++ src/sys/netinet6/frag6.c Wed Nov 9 03:49:38 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: frag6.c,v 1.56 2014/09/05 05:33:06 matt Exp $ */ +/* $NetBSD: frag6.c,v 1.57 2016/11/09 03:49:38 ozaki-r Exp $ */ /* $KAME: frag6.c,v 1.40 2002/05/27 21:40:31 itojun Exp $ */ /* @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: frag6.c,v 1.56 2014/09/05 05:33:06 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: frag6.c,v 1.57 2016/11/09 03:49:38 ozaki-r Exp $"); #include #include @@ -148,7 +148,7 @@ frag6_input(struct mbuf **mp, int *offp, if (ip6->ip6_plen == 0) { icmp6_error(m, ICMP6_PARAM_PROB, ICMP6_PARAMPROB_HEADER, offset); in6_ifstat_inc(dstifp, ifs6_reass_fail); - return IPPROTO_DONE; + goto done; } /* @@ -162,7 +162,7 @@ frag6_input(struct mbuf **mp, int *offp, icmp6_error(m, ICMP6_PARAM_PROB, ICMP6_PARAMPROB_HEADER, offsetof(struct ip6_hdr, ip6_plen)); in6_ifstat_inc(dstifp, ifs6_reass_fail); - return IPPROTO_DONE; + goto done; } IP6_STATINC(IP6_STAT_FRAGMENTS); @@ -267,14 +267,14 @@ frag6_input(struct mbuf **mp, int *offp, icmp6_error(m, ICMP6_PARAM_PROB, ICMP6_PARAMPROB_HEADER, offset - sizeof(struct ip6_frag) + offsetof(struct ip6_frag, ip6f_offlg)); - return IPPROTO_DONE; + goto done; } } else if (fragoff + frgpartlen > IPV6_MAXPACKET) { mutex_exit(_lock); icmp6_error(m, ICMP6_PARAM_PROB, ICMP6_PARAMPROB_HEADER, offset - sizeof(struct ip6_frag) + offsetof(struct ip6_frag, ip6f_offlg)); - return IPPROTO_DONE; + goto done; } /* * If it's the first fragment, do the above check for each @@ -382,13 +382,13 @@ insert: af6 = af6->ip6af_down) { if (af6->ip6af_off != next) { mutex_exit(_lock); - return IPPROTO_DONE; + goto done; } next += af6->ip6af_frglen; } if (af6->ip6af_up->ip6af_mff) { mutex_exit(_lock); - return IPPROTO_DONE; + goto done; } /* @@ -479,6 +479,7 @@ insert: in6_ifstat_inc(dstifp, ifs6_reass_fail); IP6_STATINC(IP6_STAT_FRAGDROPPED); m_freem(m); + done: return IPPROTO_DONE; }
CVS commit: src/sys/netinet
Module Name:src Committed By: ozaki-r Date: Wed Nov 9 03:33:30 UTC 2016 Modified Files: src/sys/netinet: tcp_subr.c Log Message: Cleanup/KNF tcp6_mtudisc No functional change. To generate a diff of this commit: cvs rdiff -u -r1.266 -r1.267 src/sys/netinet/tcp_subr.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/netinet/tcp_subr.c diff -u src/sys/netinet/tcp_subr.c:1.266 src/sys/netinet/tcp_subr.c:1.267 --- src/sys/netinet/tcp_subr.c:1.266 Fri Jun 10 13:27:16 2016 +++ src/sys/netinet/tcp_subr.c Wed Nov 9 03:33:30 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: tcp_subr.c,v 1.266 2016/06/10 13:27:16 ozaki-r Exp $ */ +/* $NetBSD: tcp_subr.c,v 1.267 2016/11/09 03:33:30 ozaki-r Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -91,7 +91,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.266 2016/06/10 13:27:16 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.267 2016/11/09 03:33:30 ozaki-r Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -1822,39 +1822,42 @@ void tcp6_mtudisc(struct in6pcb *in6p, int errno) { struct tcpcb *tp = in6totcpcb(in6p); - struct rtentry *rt = in6_pcbrtentry(in6p); + struct rtentry *rt; - if (tp != 0) { - if (rt != 0) { - /* - * If this was not a host route, remove and realloc. - */ - if ((rt->rt_flags & RTF_HOST) == 0) { -in6_rtchange(in6p, errno); -if ((rt = in6_pcbrtentry(in6p)) == 0) - return; - } + if (tp == NULL) + return; - /* - * Slow start out of the error condition. We - * use the MTU because we know it's smaller - * than the previously transmitted segment. - * - * Note: This is more conservative than the - * suggestion in draft-floyd-incr-init-win-03. - */ - if (rt->rt_rmx.rmx_mtu != 0) -tp->snd_cwnd = -TCP_INITIAL_WINDOW(tcp_init_win, -rt->rt_rmx.rmx_mtu); + rt = in6_pcbrtentry(in6p); + if (rt != NULL) { + /* + * If this was not a host route, remove and realloc. + */ + if ((rt->rt_flags & RTF_HOST) == 0) { + in6_rtchange(in6p, errno); + rt = in6_pcbrtentry(in6p); + if (rt == NULL) +return; } /* - * Resend unacknowledged packets. + * Slow start out of the error condition. We + * use the MTU because we know it's smaller + * than the previously transmitted segment. + * + * Note: This is more conservative than the + * suggestion in draft-floyd-incr-init-win-03. */ - tp->snd_nxt = tp->sack_newdata = tp->snd_una; - tcp_output(tp); + if (rt->rt_rmx.rmx_mtu != 0) { + tp->snd_cwnd = TCP_INITIAL_WINDOW(tcp_init_win, + rt->rt_rmx.rmx_mtu); + } } + + /* + * Resend unacknowledged packets. + */ + tp->snd_nxt = tp->sack_newdata = tp->snd_una; + tcp_output(tp); } #endif /* INET6 */
CVS commit: src/sys/kern
Module Name:src Committed By: kre Date: Wed Nov 9 00:30:17 UTC 2016 Modified Files: src/sys/kern: kern_exit.c Log Message: PR kern/51600 ; PR standards/51606 Revert 1.264 - that was intended to fix 51600, but didn't, it just hid the problem, and caused 51606. This fixes 51606. Handle waiting on a process that has been detatched from its parent because of being ptrace'd by some other process. This fixes 51600. ("handle" here means that the wait() hangs, or with WNOHANG, returns 0, we cannot actually wait on a process that is not currently an attached child.) Note: the detatched process waiting is not yet perfect (it fails to take account of options like WALLSIG and WALTSIG) - suport for those (that is, ignoring a detatched child that one of those options will later cause to be ignored when the process is re-attached.) For now, for ither than when waiting for a specific process ID, when a process does a wait() sys call (any of them), has no applicable children attached that can be returned, and has at least one detatched child, then we do a linear search of all processes to look for a suitable detatched child. This is likely to be slow - but very rare. Eventually it might be better to keep a list of detatched children per process. To generate a diff of this commit: cvs rdiff -u -r1.264 -r1.265 src/sys/kern/kern_exit.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/kern/kern_exit.c diff -u src/sys/kern/kern_exit.c:1.264 src/sys/kern/kern_exit.c:1.265 --- src/sys/kern/kern_exit.c:1.264 Sat Nov 5 02:59:22 2016 +++ src/sys/kern/kern_exit.c Wed Nov 9 00:30:17 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_exit.c,v 1.264 2016/11/05 02:59:22 christos Exp $ */ +/* $NetBSD: kern_exit.c,v 1.265 2016/11/09 00:30:17 kre Exp $ */ /*- * Copyright (c) 1998, 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.264 2016/11/05 02:59:22 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.265 2016/11/09 00:30:17 kre Exp $"); #include "opt_ktrace.h" #include "opt_dtrace.h" @@ -826,7 +826,7 @@ sys_wait6(struct lwp *l, const struct sy * 2: This is the only match */ static int -match_process(struct proc *pp, struct proc **q, idtype_t idtype, id_t id, +match_process(const struct proc *pp, struct proc **q, idtype_t idtype, id_t id, int options, struct wrusage *wrusage, siginfo_t *siginfo) { struct rusage *rup; @@ -930,6 +930,66 @@ match_process(struct proc *pp, struct pr } /* + * Determine if there are existing processes being debugged + * that used to be (and sometime later will be again) children + * of a specific parent (while matching wait criteria) + */ +static bool +debugged_child_exists(idtype_t idtype, id_t id, int options, siginfo_t *si, +const struct proc *parent) +{ + struct proc *pp; + + /* + * If we are searching for a specific pid, we can optimise a little + */ + if (idtype == P_PID) { + /* + * Check the specific process to see if its real parent is us + */ + pp = proc_find_raw((pid_t)id); + if (pp != NULL && pp->p_stat != SIDL && pp->p_opptr == parent) { + /* + * using P_ALL here avoids match_process() doing the + * same work that we just did, but incorrectly for + * this scenario. + */ + if (match_process(parent, , P_ALL, id, options, + NULL, si)) +return true; + } + return false; + } + + /* + * For the hard cases, just look everywhere to see if some + * stolen (reparented) process is really our lost child. + * Then check if that process could satisfy the wait conditions. + */ + + /* + * XXX inefficient, but hopefully fairly rare. + * XXX should really use a list of reparented processes. + */ + PROCLIST_FOREACH(pp, ) { + if (pp->p_stat == SIDL) /* XXX impossible ?? */ + continue; + if (pp->p_opptr == parent && + match_process(parent, , idtype, id, options, NULL, si)) + return true; + } + PROCLIST_FOREACH(pp, ) { + if (pp->p_stat == SIDL) /* XXX impossible ?? */ + continue; + if (pp->p_opptr == parent && + match_process(parent, , idtype, id, options, NULL, si)) + return true; + } + + return false; +} + +/* * Scan list of child processes for a child process that has stopped or * exited. Used by sys_wait4 and 'compat' equivalents. * @@ -940,7 +1000,7 @@ find_stopped_child(struct proc *parent, struct proc **child_p, struct wrusage *wru, siginfo_t *si) { struct proc *child, *dead; - int error, nohang; + int error; KASSERT(mutex_owned(proc_lock)); @@ -969,7 +1029,6 @@ find_stopped_child(struct proc *parent, idtype = P_PGID; } - nohang = (options & WNOHANG) != 0; for (;;) { error = ECHILD; dead = NULL; @@ -1053,9 +1112,22 @@ find_stopped_child(struct proc *parent, } } - if (child != NULL || error != 0 || (nohang && dead == NULL)) { + /* + * If we found nothing,
CVS commit: src/tests/lib/libc/sys
Module Name:src Committed By: kamil Date: Tue Nov 8 15:21:34 UTC 2016 Modified Files: src/tests/lib/libc/sys: t_wait_noproc.c Log Message: Switch ATF_REQUIRE() to more appropriate ATF_REQUIRE_ERRNO() Simplify the code of t_wait_noproc Sponsored by To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/sys/t_wait_noproc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/sys/t_wait_noproc.c diff -u src/tests/lib/libc/sys/t_wait_noproc.c:1.2 src/tests/lib/libc/sys/t_wait_noproc.c:1.3 --- src/tests/lib/libc/sys/t_wait_noproc.c:1.2 Mon Nov 7 02:23:43 2016 +++ src/tests/lib/libc/sys/t_wait_noproc.c Tue Nov 8 15:21:34 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: t_wait_noproc.c,v 1.2 2016/11/07 02:23:43 kamil Exp $ */ +/* $NetBSD: t_wait_noproc.c,v 1.3 2016/11/08 15:21:34 kamil Exp $ */ /*- * Copyright (c) 2016 The NetBSD Foundation, Inc. @@ -27,7 +27,7 @@ */ #include -__RCSID("$NetBSD: t_wait_noproc.c,v 1.2 2016/11/07 02:23:43 kamil Exp $"); +__RCSID("$NetBSD: t_wait_noproc.c,v 1.3 2016/11/08 15:21:34 kamil Exp $"); #include #include @@ -50,9 +50,7 @@ ATF_TC_HEAD(wait, tc) ATF_TC_BODY(wait, tc) { - errno = 0; - ATF_REQUIRE(wait(NULL) == -1); - ATF_REQUIRE(errno == ECHILD); + ATF_REQUIRE_ERRNO(ECHILD, wait(NULL) == -1); } #endif @@ -70,9 +68,7 @@ ATF_TC_BODY(waitpid, tc) /* wait4() (and friends) with WNOHANG and no children does not error */ atf_tc_expect_fail("PR standards/51606"); #endif - errno = 0; - ATF_REQUIRE(waitpid(WAIT_ANY, NULL, TWAIT_OPTION) == -1); - ATF_REQUIRE(errno == ECHILD); + ATF_REQUIRE_ERRNO(ECHILD, waitpid(WAIT_ANY, NULL, TWAIT_OPTION) == -1); } ATF_TC(waitid); @@ -89,9 +85,8 @@ ATF_TC_BODY(waitid, tc) /* wait4() (and friends) with WNOHANG and no children does not error */ atf_tc_expect_fail("PR standards/51606"); #endif - errno = 0; - ATF_REQUIRE(waitid(P_ALL, 0, NULL, WEXITED | TWAIT_OPTION) == -1); - ATF_REQUIRE(errno == ECHILD); + ATF_REQUIRE_ERRNO(ECHILD, + waitid(P_ALL, 0, NULL, WEXITED | TWAIT_OPTION) == -1); } ATF_TC(wait3); @@ -107,9 +102,7 @@ ATF_TC_BODY(wait3, tc) /* wait4() (and friends) with WNOHANG and no children does not error */ atf_tc_expect_fail("PR standards/51606"); #endif - errno = 0; - ATF_REQUIRE(wait3(NULL, TWAIT_OPTION, NULL) == -1); - ATF_REQUIRE(errno == ECHILD); + ATF_REQUIRE_ERRNO(ECHILD, wait3(NULL, TWAIT_OPTION, NULL) == -1); } ATF_TC(wait4); @@ -126,9 +119,8 @@ ATF_TC_BODY(wait4, tc) /* wait4() (and friends) with WNOHANG and no children does not error */ atf_tc_expect_fail("PR standards/51606"); #endif - errno = 0; - ATF_REQUIRE(wait4(WAIT_ANY, NULL, TWAIT_OPTION, NULL) == -1); - ATF_REQUIRE(errno == ECHILD); + ATF_REQUIRE_ERRNO(ECHILD, + wait4(WAIT_ANY, NULL, TWAIT_OPTION, NULL) == -1); } ATF_TC(wait6); @@ -145,9 +137,8 @@ ATF_TC_BODY(wait6, tc) /* wait4() (and friends) with WNOHANG and no children does not error */ atf_tc_expect_fail("PR standards/51606"); #endif - errno = 0; - ATF_REQUIRE(wait6(P_ALL, 0, NULL, WEXITED | TWAIT_OPTION, NULL, NULL) == -1); - ATF_REQUIRE(errno == ECHILD); + ATF_REQUIRE_ERRNO(ECHILD, + wait6(P_ALL, 0, NULL, WEXITED | TWAIT_OPTION, NULL, NULL) == -1); } ATF_TP_ADD_TCS(tp)
CVS commit: src/tests/kernel
Module Name:src Committed By: kamil Date: Tue Nov 8 14:49:04 UTC 2016 Modified Files: src/tests/kernel: t_ptrace.c Log Message: Add new test attach_chroot in t_ptrace Assert that a debugger cannot trace another process unless the process's root directory is at or below the tracing process's root. Sponsored by . To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/tests/kernel/t_ptrace.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/kernel/t_ptrace.c diff -u src/tests/kernel/t_ptrace.c:1.14 src/tests/kernel/t_ptrace.c:1.15 --- src/tests/kernel/t_ptrace.c:1.14 Tue Nov 8 11:21:41 2016 +++ src/tests/kernel/t_ptrace.c Tue Nov 8 14:49:04 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: t_ptrace.c,v 1.14 2016/11/08 11:21:41 kamil Exp $ */ +/* $NetBSD: t_ptrace.c,v 1.15 2016/11/08 14:49:04 kamil Exp $ */ /*- * Copyright (c) 2016 The NetBSD Foundation, Inc. @@ -27,12 +27,12 @@ */ #include -__RCSID("$NetBSD: t_ptrace.c,v 1.14 2016/11/08 11:21:41 kamil Exp $"); +__RCSID("$NetBSD: t_ptrace.c,v 1.15 2016/11/08 14:49:04 kamil Exp $"); #include #include #include -#include +#include #include #include #include @@ -104,11 +104,76 @@ ATF_TC_BODY(attach_self, tc) ATF_REQUIRE_ERRNO(EINVAL, ptrace(PT_ATTACH, getpid(), NULL, 0) == -1); } +ATF_TC(attach_chroot); +ATF_TC_HEAD(attach_chroot, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Assert that a debugger cannot trace another process unless the " + "process's root directory is at or below the tracing process's " + "root"); + + atf_tc_set_md_var(tc, "require.user", "root"); +} + +ATF_TC_BODY(attach_chroot, tc) +{ + char buf[PATH_MAX]; + pid_t child; + int fds_toparent[2], fds_fromparent[2]; + int rv; + uint8_t msg = 0xde; /* dummy message for IPC based on pipe(2) */ + + (void)memset(buf, '\0', sizeof(buf)); + ATF_REQUIRE(getcwd(buf, sizeof(buf)) != NULL); + (void)strlcat(buf, "/dir", sizeof(buf)); + + ATF_REQUIRE(mkdir(buf, 0500) == 0); + ATF_REQUIRE(chdir(buf) == 0); + + ATF_REQUIRE(pipe(fds_toparent) == 0); + ATF_REQUIRE(pipe(fds_fromparent) == 0); + child = atf_utils_fork(); + if (child == 0) { + FORKEE_ASSERT(close(fds_toparent[0]) == 0); + FORKEE_ASSERT(close(fds_fromparent[1]) == 0); + + FORKEE_ASSERT(chroot(buf) == 0); + + rv = write(fds_toparent[1], , sizeof(msg)); + FORKEE_ASSERTX(rv == sizeof(msg)); + + ATF_REQUIRE_ERRNO(EPERM, + ptrace(PT_ATTACH, getppid(), NULL, 0) == -1); + + rv = read(fds_fromparent[0], , sizeof(msg)); + FORKEE_ASSERTX(rv == sizeof(msg)); + + _exit(0); + } + ATF_REQUIRE(close(fds_toparent[1]) == 0); + ATF_REQUIRE(close(fds_fromparent[0]) == 0); + + printf("Waiting for chrooting of the child PID %d", child); + rv = read(fds_toparent[0], , sizeof(msg)); + ATF_REQUIRE(rv == sizeof(msg)); + + printf("Child is ready, it will try to PT_ATTACH to parent\n"); + rv = write(fds_fromparent[1], , sizeof(msg)); + ATF_REQUIRE(rv == sizeof(msg)); + +printf("fds_fromparent is no longer needed - close it\n"); +ATF_REQUIRE(close(fds_fromparent[1]) == 0); + +printf("fds_toparent is no longer needed - close it\n"); +ATF_REQUIRE(close(fds_toparent[0]) == 0); +} + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, attach_pid0); ATF_TP_ADD_TC(tp, attach_pid1); ATF_TP_ADD_TC(tp, attach_self); + ATF_TP_ADD_TC(tp, attach_chroot); return atf_no_error(); }
CVS commit: src/tests/kernel
Module Name:src Committed By: kamil Date: Tue Nov 8 11:21:41 UTC 2016 Modified Files: src/tests/kernel: t_ptrace.c Log Message: Add new test attach_self in t_ptrace Assert that a debugger cannot attach to self (as it's nonsense). NetBSD returs here EINVAL. Clean up unused header includes. Sponsored by . To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/tests/kernel/t_ptrace.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/kernel/t_ptrace.c diff -u src/tests/kernel/t_ptrace.c:1.13 src/tests/kernel/t_ptrace.c:1.14 --- src/tests/kernel/t_ptrace.c:1.13 Mon Nov 7 21:09:03 2016 +++ src/tests/kernel/t_ptrace.c Tue Nov 8 11:21:41 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: t_ptrace.c,v 1.13 2016/11/07 21:09:03 kamil Exp $ */ +/* $NetBSD: t_ptrace.c,v 1.14 2016/11/08 11:21:41 kamil Exp $ */ /*- * Copyright (c) 2016 The NetBSD Foundation, Inc. @@ -27,19 +27,14 @@ */ #include -__RCSID("$NetBSD: t_ptrace.c,v 1.13 2016/11/07 21:09:03 kamil Exp $"); +__RCSID("$NetBSD: t_ptrace.c,v 1.14 2016/11/08 11:21:41 kamil Exp $"); #include #include #include -#include #include #include #include -#include -#include -#include -#include #include #include @@ -97,10 +92,23 @@ ATF_TC_BODY(attach_pid1, tc) ATF_REQUIRE_ERRNO(EPERM, ptrace(PT_ATTACH, 1, NULL, 0) == -1); } +ATF_TC(attach_self); +ATF_TC_HEAD(attach_self, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Assert that a debugger cannot attach to self (as it's nonsense)"); +} + +ATF_TC_BODY(attach_self, tc) +{ + ATF_REQUIRE_ERRNO(EINVAL, ptrace(PT_ATTACH, getpid(), NULL, 0) == -1); +} + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, attach_pid0); ATF_TP_ADD_TC(tp, attach_pid1); + ATF_TP_ADD_TC(tp, attach_self); return atf_no_error(); }
CVS commit: src/sys/dev
Module Name:src Committed By: msaitoh Date: Tue Nov 8 10:37:40 UTC 2016 Modified Files: src/sys/dev/mii: inbmphyreg.h src/sys/dev/pci: if_wm.c Log Message: Fix wm_access_phy_wakeup_reg_bm(). This change has no effect because this function is used for WUC register and our driver currenlty doesn't access to it. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/dev/mii/inbmphyreg.h cvs rdiff -u -r1.440 -r1.441 src/sys/dev/pci/if_wm.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/dev/mii/inbmphyreg.h diff -u src/sys/dev/mii/inbmphyreg.h:1.7 src/sys/dev/mii/inbmphyreg.h:1.8 --- src/sys/dev/mii/inbmphyreg.h:1.7 Fri Oct 28 05:50:18 2016 +++ src/sys/dev/mii/inbmphyreg.h Tue Nov 8 10:37:39 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: inbmphyreg.h,v 1.7 2016/10/28 05:50:18 msaitoh Exp $ */ +/* $NetBSD: inbmphyreg.h,v 1.8 2016/11/08 10:37:39 msaitoh Exp $ */ /*** Copyright (c) 2001-2005, Intel Corporation All rights reserved. @@ -111,5 +111,6 @@ POSSIBILITY OF SUCH DAMAGE. #define BM_WUC_ENABLE_REG 17 #define BM_WUC_ENABLE_BIT (1 << 2) #define BM_WUC_HOST_WU_BIT (1 << 4) +#define BM_WUC_ME_WU_BIT (1 << 5) #endif /* _DEV_MII_INBMPHYREG_H_ */ Index: src/sys/dev/pci/if_wm.c diff -u src/sys/dev/pci/if_wm.c:1.440 src/sys/dev/pci/if_wm.c:1.441 --- src/sys/dev/pci/if_wm.c:1.440 Tue Nov 8 09:38:36 2016 +++ src/sys/dev/pci/if_wm.c Tue Nov 8 10:37:40 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wm.c,v 1.440 2016/11/08 09:38:36 msaitoh Exp $ */ +/* $NetBSD: if_wm.c,v 1.441 2016/11/08 10:37:40 msaitoh Exp $ */ /* * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc. @@ -84,7 +84,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.440 2016/11/08 09:38:36 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.441 2016/11/08 10:37:40 msaitoh Exp $"); #ifdef _KERNEL_OPT #include "opt_net_mpsafe.h" @@ -8840,7 +8840,7 @@ wm_access_phy_wakeup_reg_bm(device_t sel { struct wm_softc *sc = device_private(self); uint16_t regnum = BM_PHY_REG_NUM(offset); - uint16_t wuce; + uint16_t wuce, reg; DPRINTF(WM_DEBUG_GMII, ("%s: %s called\n", device_xname(sc->sc_dev), __func__)); @@ -8849,20 +8849,31 @@ wm_access_phy_wakeup_reg_bm(device_t sel /* XXX e1000 driver do nothing... why? */ } + /* + * 1) Enable PHY wakeup register first. + * See e1000_enable_phy_wakeup_reg_access_bm(). + */ + /* Set page 769 */ wm_gmii_mdic_writereg(self, 1, MII_IGPHY_PAGE_SELECT, BM_WUC_ENABLE_PAGE << BME1000_PAGE_SHIFT); + /* Read WUCE and save it */ wuce = wm_gmii_mdic_readreg(self, 1, BM_WUC_ENABLE_REG); - wuce &= ~BM_WUC_HOST_WU_BIT; - wm_gmii_mdic_writereg(self, 1, BM_WUC_ENABLE_REG, - wuce | BM_WUC_ENABLE_BIT); + reg = wuce | BM_WUC_ENABLE_BIT; + reg &= ~(BM_WUC_ME_WU_BIT | BM_WUC_HOST_WU_BIT); + wm_gmii_mdic_writereg(self, 1, BM_WUC_ENABLE_REG, reg); /* Select page 800 */ wm_gmii_mdic_writereg(self, 1, MII_IGPHY_PAGE_SELECT, BM_WUC_PAGE << BME1000_PAGE_SHIFT); + /* + * 2) Access PHY wakeup register. + * See e1000_access_phy_wakeup_reg_bm. + */ + /* Write page 800 */ wm_gmii_mdic_writereg(self, 1, BM_WUC_ADDRESS_OPCODE, regnum); @@ -8871,6 +8882,10 @@ wm_access_phy_wakeup_reg_bm(device_t sel else wm_gmii_mdic_writereg(self, 1, BM_WUC_DATA_OPCODE, *val); + /* + * 3) Disable PHY wakeup register. + * See e1000_disable_phy_wakeup_reg_access_bm(). + */ /* Set page 769 */ wm_gmii_mdic_writereg(self, 1, MII_IGPHY_PAGE_SELECT, BM_WUC_ENABLE_PAGE << BME1000_PAGE_SHIFT);
CVS commit: src/sys/dev/pci
Module Name:src Committed By: msaitoh Date: Tue Nov 8 09:38:36 UTC 2016 Modified Files: src/sys/dev/pci: if_wm.c Log Message: Remove debug printf which was added in rev. 1.437. To generate a diff of this commit: cvs rdiff -u -r1.439 -r1.440 src/sys/dev/pci/if_wm.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/dev/pci/if_wm.c diff -u src/sys/dev/pci/if_wm.c:1.439 src/sys/dev/pci/if_wm.c:1.440 --- src/sys/dev/pci/if_wm.c:1.439 Tue Nov 8 08:54:30 2016 +++ src/sys/dev/pci/if_wm.c Tue Nov 8 09:38:36 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wm.c,v 1.439 2016/11/08 08:54:30 msaitoh Exp $ */ +/* $NetBSD: if_wm.c,v 1.440 2016/11/08 09:38:36 msaitoh Exp $ */ /* * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc. @@ -84,7 +84,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.439 2016/11/08 08:54:30 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.440 2016/11/08 09:38:36 msaitoh Exp $"); #ifdef _KERNEL_OPT #include "opt_net_mpsafe.h" @@ -8373,9 +8373,6 @@ wm_gmii_mediainit(struct wm_softc *sc, p sc->sc_phytype = WMPHY_IGP_3; ifmedia_set(>mii_media, IFM_ETHER | IFM_AUTO); - - printf("XXX OUI = %08x, model = %04x, rev = %04x\n", - child->mii_mpd_oui, child->mii_mpd_model, child->mii_mpd_rev); } }
CVS commit: src/sys/dev/pci
Module Name:src Committed By: msaitoh Date: Tue Nov 8 08:54:30 UTC 2016 Modified Files: src/sys/dev/pci: if_wm.c Log Message: Call wm_enable_wakeup() in wm_detach() and wm_suspend(). Now wake on lan works on Thinkpad X61(ICH8). Some workarounds will be required on PCH*. To generate a diff of this commit: cvs rdiff -u -r1.438 -r1.439 src/sys/dev/pci/if_wm.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/dev/pci/if_wm.c diff -u src/sys/dev/pci/if_wm.c:1.438 src/sys/dev/pci/if_wm.c:1.439 --- src/sys/dev/pci/if_wm.c:1.438 Sun Nov 6 02:38:25 2016 +++ src/sys/dev/pci/if_wm.c Tue Nov 8 08:54:30 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wm.c,v 1.438 2016/11/06 02:38:25 msaitoh Exp $ */ +/* $NetBSD: if_wm.c,v 1.439 2016/11/08 08:54:30 msaitoh Exp $ */ /* * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc. @@ -84,7 +84,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.438 2016/11/06 02:38:25 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.439 2016/11/08 08:54:30 msaitoh Exp $"); #ifdef _KERNEL_OPT #include "opt_net_mpsafe.h" @@ -824,7 +824,7 @@ static void wm_put_hw_semaphore_82573(st * Management mode and power management related subroutines. * BMC, AMT, suspend/resume and EEE. */ -#ifdef WM_WOL +#if 0 static int wm_check_mng_mode(struct wm_softc *); static int wm_check_mng_mode_ich8lan(struct wm_softc *); static int wm_check_mng_mode_82574(struct wm_softc *); @@ -839,11 +839,9 @@ static void wm_smbustopci(struct wm_soft static void wm_init_manageability(struct wm_softc *); static void wm_release_manageability(struct wm_softc *); static void wm_get_wakeup(struct wm_softc *); -#ifdef WM_WOL static void wm_enable_phy_wakeup(struct wm_softc *); static void wm_igp3_phy_powerdown_workaround_ich8lan(struct wm_softc *); static void wm_enable_wakeup(struct wm_softc *); -#endif /* LPLU (Low Power Link Up) */ static void wm_lplu_d0_disable(struct wm_softc *); static void wm_lplu_d0_disable_pch(struct wm_softc *); @@ -2678,6 +2676,7 @@ wm_detach(device_t self, int flags __unu WM_CORE_LOCK(sc); wm_release_manageability(sc); wm_release_hw_control(sc); + wm_enable_wakeup(sc); WM_CORE_UNLOCK(sc); mii_detach(>sc_mii, MII_PHY_ANY, MII_OFFSET_ANY); @@ -2740,9 +2739,7 @@ wm_suspend(device_t self, const pmf_qual wm_release_manageability(sc); wm_release_hw_control(sc); -#ifdef WM_WOL wm_enable_wakeup(sc); -#endif return true; } @@ -12019,7 +12016,6 @@ wm_get_wakeup(struct wm_softc *sc) */ } -#ifdef WM_WOL /* WOL in the newer chipset interfaces (pchlan) */ static void wm_enable_phy_wakeup(struct wm_softc *sc) @@ -12167,7 +12163,6 @@ wm_enable_wakeup(struct wm_softc *sc) #endif pci_conf_write(sc->sc_pc, sc->sc_pcitag, pmreg + PCI_PMCSR, pmode); } -#endif /* WM_WOL */ /* LPLU */
CVS commit: src/sys/dev/mii
Module Name:src Committed By: msaitoh Date: Tue Nov 8 08:48:35 UTC 2016 Modified Files: src/sys/dev/mii: makphy.c Log Message: Set mii_mpd_{oui,rev}. To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sys/dev/mii/makphy.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/dev/mii/makphy.c diff -u src/sys/dev/mii/makphy.c:1.41 src/sys/dev/mii/makphy.c:1.42 --- src/sys/dev/mii/makphy.c:1.41 Thu Jul 7 06:55:41 2016 +++ src/sys/dev/mii/makphy.c Tue Nov 8 08:48:35 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: makphy.c,v 1.41 2016/07/07 06:55:41 msaitoh Exp $ */ +/* $NetBSD: makphy.c,v 1.42 2016/11/08 08:48:35 msaitoh Exp $ */ /*- * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc. @@ -59,7 +59,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: makphy.c,v 1.41 2016/07/07 06:55:41 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: makphy.c,v 1.42 2016/11/08 08:48:35 msaitoh Exp $"); #include #include @@ -154,7 +154,9 @@ makphyattach(device_t parent, device_t s aprint_normal(": %s, rev. %d\n", mpd->mpd_name, MII_REV(ma->mii_id2)); sc->mii_dev = self; + sc->mii_mpd_oui = MII_OUI(ma->mii_id1, ma->mii_id2); sc->mii_mpd_model = MII_MODEL(ma->mii_id2); + sc->mii_mpd_rev = MII_REV(ma->mii_id2); sc->mii_inst = mii->mii_instance; sc->mii_phy = ma->mii_phyno; sc->mii_funcs = _funcs;
CVS commit: src/usr.sbin/paxctl
Module Name:src Committed By: wiz Date: Tue Nov 8 08:21:52 UTC 2016 Modified Files: src/usr.sbin/paxctl: paxctl.8 Log Message: New sentence, new line. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/usr.sbin/paxctl/paxctl.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/paxctl/paxctl.8 diff -u src/usr.sbin/paxctl/paxctl.8:1.15 src/usr.sbin/paxctl/paxctl.8:1.16 --- src/usr.sbin/paxctl/paxctl.8:1.15 Tue Nov 8 03:20:07 2016 +++ src/usr.sbin/paxctl/paxctl.8 Tue Nov 8 08:21:52 2016 @@ -1,4 +1,4 @@ -.\" $NetBSD: paxctl.8,v 1.15 2016/11/08 03:20:07 pgoyette Exp $ +.\" $NetBSD: paxctl.8,v 1.16 2016/11/08 08:21:52 wiz Exp $ .\" .\" Copyright 2006 Elad Efrat.\" Copyright 2008 Christos Zoulas @@ -114,5 +114,6 @@ sections to mark executables as having P This will be done using .Xr fileassoc 9 in the future so that we can control who does the marking and -not altering the binary file signature. (Note this also means that +not altering the binary file signature. +(Note this also means that at present any flags set do not survive binary file upgrades.)