svn commit: r315484 - head/tests/sys/kern
Author: badger Date: Sat Mar 18 15:25:51 2017 New Revision: 315484 URL: https://svnweb.freebsd.org/changeset/base/315484 Log: ptrace_test: eliminate assumption about thread scheduling A couple of the ptrace tests make assumptions about which thread in a multithreaded process will run after a halt. This makes the tests less portable across branches, and susceptible to future breakage. Instead, twiddle thread scheduling and priorities to match the tests' expectation. X-MFC with: r313992 Sponsored by: Dell EMC Modified: head/tests/sys/kern/ptrace_test.c Modified: head/tests/sys/kern/ptrace_test.c == --- head/tests/sys/kern/ptrace_test.c Sat Mar 18 13:58:25 2017 (r315483) +++ head/tests/sys/kern/ptrace_test.c Sat Mar 18 15:25:51 2017 (r315484) @@ -33,6 +33,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include #include #include #include @@ -40,6 +42,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -1872,15 +1875,11 @@ ATF_TC_BODY(ptrace__PT_KILL_competing_si cpuset_t setmask; pthread_t t; pthread_barrier_t barrier; + struct sched_param sched_param; ATF_REQUIRE((fpid = fork()) != -1); if (fpid == 0) { - /* -* Bind to one CPU so only one thread at a time will run. This -* test expects that the first thread created (the main thread) -* will be unsuspended first and will block the second thread -* from running. -*/ + /* Bind to one CPU so only one thread at a time will run. */ CPU_ZERO(); CPU_SET(0, ); cpusetid_t setid; @@ -1893,6 +1892,20 @@ ATF_TC_BODY(ptrace__PT_KILL_competing_si CHILD_REQUIRE(pthread_create(, NULL, mask_usr1_thread, (void*)) == 0); + /* +* Give the main thread higher priority. The test always +* assumes that, if both threads are able to run, the main +* thread runs first. +*/ + sched_param.sched_priority = + (sched_get_priority_max(SCHED_FIFO) + + sched_get_priority_min(SCHED_FIFO)) / 2; + CHILD_REQUIRE(pthread_setschedparam(pthread_self(), + SCHED_FIFO, _param) == 0); + sched_param.sched_priority -= RQ_PPQ; + CHILD_REQUIRE(pthread_setschedparam(t, SCHED_FIFO, + _param) == 0); + sigset_t sigmask; sigemptyset(); sigaddset(, SIGUSR2); @@ -1952,23 +1965,19 @@ ATF_TC_WITHOUT_HEAD(ptrace__PT_KILL_comp ATF_TC_BODY(ptrace__PT_KILL_competing_stop, tc) { pid_t fpid, wpid; - int status, i; + int status; cpuset_t setmask; pthread_t t; pthread_barrier_t barrier; lwpid_t main_lwp; struct ptrace_lwpinfo pl; + struct sched_param sched_param; ATF_REQUIRE((fpid = fork()) != -1); if (fpid == 0) { trace_me(); - /* -* Bind to one CPU so only one thread at a time will run. This -* test expects that the first thread created (the main thread) -* will be unsuspended first and will block the second thread -* from running. -*/ + /* Bind to one CPU so only one thread at a time will run. */ CPU_ZERO(); CPU_SET(0, ); cpusetid_t setid; @@ -1981,6 +1990,20 @@ ATF_TC_BODY(ptrace__PT_KILL_competing_st CHILD_REQUIRE(pthread_create(, NULL, mask_usr1_thread, (void*)) == 0); + /* +* Give the main thread higher priority. The test always +* assumes that, if both threads are able to run, the main +* thread runs first. +*/ + sched_param.sched_priority = + (sched_get_priority_max(SCHED_FIFO) + + sched_get_priority_min(SCHED_FIFO)) / 2; + CHILD_REQUIRE(pthread_setschedparam(pthread_self(), + SCHED_FIFO, _param) == 0); + sched_param.sched_priority -= RQ_PPQ; + CHILD_REQUIRE(pthread_setschedparam(t, SCHED_FIFO, + _param) == 0); + sigset_t sigmask; sigemptyset(); sigaddset(, SIGUSR2); @@ -2027,34 +2050,43 @@ ATF_TC_BODY(ptrace__PT_KILL_competing_st ATF_REQUIRE(ptrace(PT_SYSCALL, fpid, (caddr_t)1, 0) == 0); } - /* Let both threads hit their syscall entries. */ - for (i = 0; i < 2; ++i) { - ATF_REQUIRE(ptrace(PT_SYSCALL, fpid, (caddr_t)1, 0) ==
svn commit: r315412 - in head: sys/kern tests/sys/kern
Author: badger Date: Thu Mar 16 13:03:31 2017 New Revision: 315412 URL: https://svnweb.freebsd.org/changeset/base/315412 Log: Don't clear p_ptevents on normal SIGKILL delivery The ptrace() user has the option of discarding the signal. In such a case, p_ptevents should not be modified. If the ptrace() user decides to send a SIGKILL, ptevents will be cleared in ptracestop(). procfs events do not have the capability to discard the signal, so continue to clear the mask in that case. Reviewed by: jhb (initial revision) MFC after:1 week Sponsored by: Dell EMC Differential Revision:https://reviews.freebsd.org/D9939 Modified: head/sys/kern/kern_sig.c head/tests/sys/kern/ptrace_test.c Modified: head/sys/kern/kern_sig.c == --- head/sys/kern/kern_sig.cThu Mar 16 13:01:23 2017(r315411) +++ head/sys/kern/kern_sig.cThu Mar 16 13:03:31 2017(r315412) @@ -2179,11 +2179,9 @@ tdsendsignal(struct proc *p, struct thre if (action == SIG_HOLD && !((prop & SIGPROP_CONT) && (p->p_flag & P_STOPPED_SIG))) return (ret); - /* -* SIGKILL: Remove procfs STOPEVENTs and ptrace events. -*/ + + /* SIGKILL: Remove procfs STOPEVENTs. */ if (sig == SIGKILL) { - p->p_ptevents = 0; /* from procfs_ioctl.c: PIOCBIC */ p->p_stops = 0; /* from procfs_ioctl.c: PIOCCONT */ Modified: head/tests/sys/kern/ptrace_test.c == --- head/tests/sys/kern/ptrace_test.c Thu Mar 16 13:01:23 2017 (r315411) +++ head/tests/sys/kern/ptrace_test.c Thu Mar 16 13:03:31 2017 (r315412) @@ -2919,6 +2919,79 @@ ATF_TC_BODY(ptrace__parent_terminate_wit terminate_with_pending_sigstop(false); } +/* + * Verify that after ptrace() discards a SIGKILL signal, the event mask + * is not modified. + */ +ATF_TC_WITHOUT_HEAD(ptrace__event_mask_sigkill_discard); +ATF_TC_BODY(ptrace__event_mask_sigkill_discard, tc) +{ + struct ptrace_lwpinfo pl; + pid_t fpid, wpid; + int status, event_mask, new_event_mask; + + ATF_REQUIRE((fpid = fork()) != -1); + if (fpid == 0) { + trace_me(); + raise(SIGSTOP); + exit(0); + } + + /* The first wait() should report the stop from trace_me(). */ + wpid = waitpid(fpid, , 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGSTOP); + + /* Set several unobtrusive event bits. */ + event_mask = PTRACE_EXEC | PTRACE_FORK | PTRACE_LWP; + ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, wpid, (caddr_t)_mask, + sizeof(event_mask)) == 0); + + /* Send a SIGKILL without using ptrace. */ + ATF_REQUIRE(kill(fpid, SIGKILL) == 0); + + /* Continue the child ignoring the SIGSTOP. */ + ATF_REQUIRE(ptrace(PT_CONTINUE, fpid, (caddr_t)1, 0) == 0); + + /* The next stop should be due to the SIGKILL. */ + wpid = waitpid(fpid, , 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGKILL); + + ATF_REQUIRE(ptrace(PT_LWPINFO, wpid, (caddr_t), sizeof(pl)) != -1); + ATF_REQUIRE(pl.pl_flags & PL_FLAG_SI); + ATF_REQUIRE(pl.pl_siginfo.si_signo == SIGKILL); + + /* Continue the child ignoring the SIGKILL. */ + ATF_REQUIRE(ptrace(PT_CONTINUE, fpid, (caddr_t)1, 0) == 0); + + /* The next wait() should report the stop from SIGSTOP. */ + wpid = waitpid(fpid, , 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGSTOP); + + /* Check the current event mask. It should not have changed. */ + new_event_mask = 0; + ATF_REQUIRE(ptrace(PT_GET_EVENT_MASK, wpid, (caddr_t)_event_mask, + sizeof(new_event_mask)) == 0); + ATF_REQUIRE(event_mask == new_event_mask); + + /* Continue the child to let it exit. */ + ATF_REQUIRE(ptrace(PT_CONTINUE, fpid, (caddr_t)1, 0) == 0); + + /* The last event should be for the child process's exit. */ + wpid = waitpid(fpid, , 0); + ATF_REQUIRE(WIFEXITED(status)); + ATF_REQUIRE(WEXITSTATUS(status) == 0); + + wpid = wait(); + ATF_REQUIRE(wpid == -1); + ATF_REQUIRE(errno == ECHILD); +} + ATF_TP_ADD_TCS(tp) { @@ -2965,6 +3038,7 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, ptrace__PT_CONTINUE_with_signal_thread_sigmask); ATF_TP_ADD_TC(tp, ptrace__parent_terminate_with_pending_sigstop1); ATF_TP_ADD_TC(tp, ptrace__parent_terminate_with_pending_sigstop2); + ATF_TP_ADD_TC(tp, ptrace__event_mask_sigkill_discard); return (atf_no_error()); } ___
svn commit: r314852 - in head: sys/kern tests/sys/kern
Author: badger Date: Tue Mar 7 13:41:01 2017 New Revision: 314852 URL: https://svnweb.freebsd.org/changeset/base/314852 Log: don't stop in issignal() if P_SINGLE_EXIT is set Suppose a traced process is stopped in ptracestop() due to receipt of a SIGSTOP signal, and is awaiting orders from the tracing process on how to handle the signal. Before sending any such orders, the tracing process exits. This should kill the traced process. But suppose a second thread handles the SIGKILL and proceeds to exit1(), calling thread_single(). The first thread will now awaken and will have a chance to check once more if it should go to sleep due to the SIGSTOP. It must not sleep after P_SINGLE_EXIT has been set; this would prevent the SIGKILL from taking effect, leaving a stopped orphan behind after the tracing process dies. Also add new tests for this condition. Reviewed by: kib MFC after:2 weeks Sponsored by: Dell EMC Differential Revision:https://reviews.freebsd.org/D9890 Modified: head/sys/kern/kern_sig.c head/tests/sys/kern/ptrace_test.c Modified: head/sys/kern/kern_sig.c == --- head/sys/kern/kern_sig.cTue Mar 7 13:38:25 2017(r314851) +++ head/sys/kern/kern_sig.cTue Mar 7 13:41:01 2017(r314852) @@ -2859,14 +2859,15 @@ issignal(struct thread *td) break; /* == ignore */ } /* -* If there is a pending stop signal to process -* with default action, stop here, -* then clear the signal. However, -* if process is member of an orphaned -* process group, ignore tty stop signals. +* If there is a pending stop signal to process with +* default action, stop here, then clear the signal. +* Traced or exiting processes should ignore stops. +* Additionally, a member of an orphaned process group +* should ignore tty stops. */ if (prop & SIGPROP_STOP) { - if (p->p_flag & (P_TRACED|P_WEXIT) || + if (p->p_flag & + (P_TRACED | P_WEXIT | P_SINGLE_EXIT) || (p->p_pgrp->pg_jobc == 0 && prop & SIGPROP_TTYSTOP)) break; /* == ignore */ Modified: head/tests/sys/kern/ptrace_test.c == --- head/tests/sys/kern/ptrace_test.c Tue Mar 7 13:38:25 2017 (r314851) +++ head/tests/sys/kern/ptrace_test.c Tue Mar 7 13:41:01 2017 (r314852) @@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -2785,6 +2786,139 @@ ATF_TC_BODY(ptrace__PT_CONTINUE_with_sig ATF_REQUIRE(errno == ECHILD); } +static void * +raise_sigstop_thread(void *arg __unused) +{ + + raise(SIGSTOP); + return NULL; +} + +static void * +sleep_thread(void *arg __unused) +{ + + sleep(60); + return NULL; +} + +static void +terminate_with_pending_sigstop(bool sigstop_from_main_thread) +{ + pid_t fpid, wpid; + int status, i; + cpuset_t setmask; + cpusetid_t setid; + pthread_t t; + + /* +* Become the reaper for this process tree. We need to be able to check +* that both child and grandchild have died. +*/ + ATF_REQUIRE(procctl(P_PID, getpid(), PROC_REAP_ACQUIRE, NULL) == 0); + + fpid = fork(); + ATF_REQUIRE(fpid >= 0); + if (fpid == 0) { + fpid = fork(); + CHILD_REQUIRE(fpid >= 0); + if (fpid == 0) { + trace_me(); + + /* Pin to CPU 0 to serialize thread execution. */ + CPU_ZERO(); + CPU_SET(0, ); + CHILD_REQUIRE(cpuset() == 0); + CHILD_REQUIRE(cpuset_setaffinity(CPU_LEVEL_CPUSET, + CPU_WHICH_CPUSET, setid, + sizeof(setmask), ) == 0); + + if (sigstop_from_main_thread) { + /* +* We expect the SIGKILL sent when our parent +* dies to be delivered to the new thread. +* Raise the SIGSTOP in this thread so the +* threads compete. +*/ + CHILD_REQUIRE(pthread_create(, NULL, + sleep_thread, NULL) == 0); +
svn commit: r314690 - in head: share/man/man5 sys/conf sys/fs/procfs sys/modules/procfs
Author: badger Date: Sun Mar 5 03:05:24 2017 New Revision: 314690 URL: https://svnweb.freebsd.org/changeset/base/314690 Log: remove procfs ctl interface This interface has no in-tree consumers and has been more or less non-functional for several releases. Remove manpage note that the procfs special file 'mem' is grouped to kmem. This hasn't been true since r81107. Remove procfs' README file. It is an out of date duplication of the manpage (quoth the README: "since the bsd kernel is single-processor..."). Reviewed by: vangyzen, bcr (manpage) Approved by: des (procfs maintainer), vangyzen (mentor) Differential Revision:https://reviews.freebsd.org/D9802 Deleted: head/sys/fs/procfs/README head/sys/fs/procfs/procfs_ctl.c Modified: head/share/man/man5/procfs.5 head/sys/conf/files head/sys/fs/procfs/procfs.c head/sys/fs/procfs/procfs.h head/sys/modules/procfs/Makefile Modified: head/share/man/man5/procfs.5 == --- head/share/man/man5/procfs.5Sun Mar 5 00:37:23 2017 (r314689) +++ head/share/man/man5/procfs.5Sun Mar 5 03:05:24 2017 (r314690) @@ -2,7 +2,7 @@ .\" Written by Garrett Wollman .\" This file is in the public domain. .\" -.Dd December 26, 2015 +.Dd March 4, 2017 .Dt PROCFS 5 .Os .Sh NAME @@ -33,48 +33,7 @@ special node called which always refers to the process making the lookup request. .Pp Each node is a directory which contains the following entries: -.Pp -Each directory contains several files: .Bl -tag -width status -.It Pa ctl -a write-only file which supports a variety -of control operations. -Control commands are written as strings to the -.Pa ctl -file. -The control commands are: -.Bl -tag -width detach -compact -.It attach -stops the target process and arranges for the sending -process to become the debug control process. -.It detach -continue execution of the target process and -remove it from control by the debug process (which -need not be the sending process). -.It run -continue running the target process until -a signal is delivered, a breakpoint is hit, or the -target process exits. -.It step -single step the target process, with no signal delivery. -.It wait -wait for the target process to come to a steady -state ready for debugging. -The target process must be in this state before -any of the other commands are allowed. -.El -.Pp -The string can also be the name of a signal, lower case -and without the -.Dv SIG -prefix, -in which case that signal is delivered to the process -(see -.Xr sigaction 2 ) . -.Pp -The -.Xr procctl 8 -utility can be used to clear tracepoints in a stuck process. .It Pa dbregs The debug registers as defined by .Dv "struct dbregs" @@ -188,30 +147,8 @@ to indicate that the process is not runn .El .El .Pp -In a normal debugging environment, -where the target is fork/exec'd by the debugger, -the debugger should fork and the child should stop -itself (with a self-inflicted -.Dv SIGSTOP -for example). -The parent should issue a -.Dv wait -and then an -.Dv attach -command via the appropriate -.Pa ctl -file. -The child process will receive a -.Dv SIGTRAP -immediately after the call to exec (see -.Xr execve 2 ) . -.Pp Each node is owned by the process's user, and belongs to that user's -primary group, except for the -.Pa mem -node, which belongs to the -.Li kmem -group. +primary group. .Sh FILES .Bl -tag -width /proc/curproc/XXX -compact .It Pa /proc @@ -224,8 +161,6 @@ directory containing process information directory containing process information for the current process .It Pa /proc/curproc/cmdline the process executable name -.It Pa /proc/curproc/ctl -used to send control messages to the process .It Pa /proc/curproc/etype executable type .It Pa /proc/curproc/file Modified: head/sys/conf/files == --- head/sys/conf/files Sun Mar 5 00:37:23 2017(r314689) +++ head/sys/conf/files Sun Mar 5 03:05:24 2017(r314690) @@ -3384,7 +3384,6 @@ fs/nullfs/null_subr.c optional nullfs fs/nullfs/null_vfsops.coptional nullfs fs/nullfs/null_vnops.c optional nullfs fs/procfs/procfs.c optional procfs -fs/procfs/procfs_ctl.c optional procfs fs/procfs/procfs_dbregs.c optional procfs fs/procfs/procfs_fpregs.c optional procfs fs/procfs/procfs_ioctl.c optional procfs Modified: head/sys/fs/procfs/procfs.c == --- head/sys/fs/procfs/procfs.c Sun Mar 5 00:37:23 2017(r314689) +++ head/sys/fs/procfs/procfs.c Sun Mar 5 03:05:24 2017(r314690) @@ -104,8 +104,7 @@ procfs_attr(PFS_ATTR_ARGS) { /* XXX inefficient, split into separate functions */ - if (strcmp(pn->pn_name, "ctl") == 0 || - strcmp(pn->pn_name, "note") == 0 || +
Re: svn commit: r314075 - head/tests/sys/kern
On 02/22/2017 10:05 PM, Ian Lepore wrote: On Wed, 2017-02-22 at 04:35 +, Eric Badger wrote: Author: badger Date: Wed Feb 22 04:35:07 2017 New Revision: 314075 URL: https://svnweb.freebsd.org/changeset/base/314075 Log: Fix world build for archs where __builtin_debugtrap() does not work. The offending code was introduced in r313992. Reported by: rpokala Approved by: kib (mentor) Modified: head/tests/sys/kern/ptrace_test.c Modified: head/tests/sys/kern/ptrace_test.c = = --- head/tests/sys/kern/ptrace_test.c Wed Feb 22 04:28:10 2017 (r314074) +++ head/tests/sys/kern/ptrace_test.c Wed Feb 22 04:35:07 2017 (r314075) @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -1690,7 +1691,7 @@ ATF_TC_BODY(ptrace__PT_KILL_breakpoint, ATF_REQUIRE((fpid = fork()) != -1); if (fpid == 0) { trace_me(); - __builtin_debugtrap(); + breakpoint(); exit(1); } This fixes only x86 and sparc64. All other arches have breakpoint() under the #ifdef KERNEL wrapper (I have no idea why). If fixing this is going to take any longer, can we disconnect this test from the build until it gets worked out? -- Ian Yes, that was my error. In my haste to fix things, I misread the headers and thought I had breakpoint() everywhere (and only tested sparc64/amd64). Sorry about that. It should be fixed in r314118. Eric ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r314118 - head/tests/sys/kern
Author: badger Date: Thu Feb 23 04:26:17 2017 New Revision: 314118 URL: https://svnweb.freebsd.org/changeset/base/314118 Log: Actually fix buildworlds other than i386/amd64/sparc64 after r313992 Disable offending test for platforms without a userspace visible breakpoint(). Reported by: rpokala Approved by: vangyzen (mentor) Modified: head/tests/sys/kern/ptrace_test.c Modified: head/tests/sys/kern/ptrace_test.c == --- head/tests/sys/kern/ptrace_test.c Thu Feb 23 02:28:08 2017 (r314117) +++ head/tests/sys/kern/ptrace_test.c Thu Feb 23 04:26:17 2017 (r314118) @@ -1679,6 +1679,11 @@ ATF_TC_BODY(ptrace__ptrace_vfork_follow, } /* + * XXX: There's nothing inherently platform specific about this test, however a + * userspace visible breakpoint() is a prerequisite. + */ + #if defined(__amd64__) || defined(__i386__) || defined(__sparc64__) +/* * Verify that no more events are reported after PT_KILL except for the * process exit when stopped due to a breakpoint trap. */ @@ -1723,6 +1728,7 @@ ATF_TC_BODY(ptrace__PT_KILL_breakpoint, ATF_REQUIRE(wpid == -1); ATF_REQUIRE(errno == ECHILD); } +#endif /* defined(__amd64__) || defined(__i386__) || defined(__sparc64__) */ /* * Verify that no more events are reported after PT_KILL except for the @@ -2806,7 +2812,9 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, ptrace__event_mask); ATF_TP_ADD_TC(tp, ptrace__ptrace_vfork); ATF_TP_ADD_TC(tp, ptrace__ptrace_vfork_follow); +#if defined(__amd64__) || defined(__i386__) || defined(__sparc64__) ATF_TP_ADD_TC(tp, ptrace__PT_KILL_breakpoint); +#endif ATF_TP_ADD_TC(tp, ptrace__PT_KILL_system_call); ATF_TP_ADD_TC(tp, ptrace__PT_KILL_threads); ATF_TP_ADD_TC(tp, ptrace__PT_KILL_competing_signal); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r313992 - in head: sys/kern sys/sys tests/sys/kern
On 02/21/2017 05:45 PM, Ravi Pokala wrote: Hi Eric, This appears to break buildworld for a bunch of platforms -- possibly all the ones that use gcc rather than clang? A representative example from sparc64: /usr/home/rpokala/freebsd/clean/base/head/tests/sys/kern/ptrace_test.c: In function 'atfu_ptrace__PT_KILL_breakpoint_body': /usr/home/rpokala/freebsd/clean/base/head/tests/sys/kern/ptrace_test.c:1693: warning: implicit declaration of function '__builtin_debugtrap' *** [ptrace_test.o] Error code 1 Thanks, Ravi (rpokala@) Hi Ravi, Thanks for letting me know, and sorry for the breakage. It should be fixed as of r314075. Eric ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r314075 - head/tests/sys/kern
Author: badger Date: Wed Feb 22 04:35:07 2017 New Revision: 314075 URL: https://svnweb.freebsd.org/changeset/base/314075 Log: Fix world build for archs where __builtin_debugtrap() does not work. The offending code was introduced in r313992. Reported by: rpokala Approved by: kib (mentor) Modified: head/tests/sys/kern/ptrace_test.c Modified: head/tests/sys/kern/ptrace_test.c == --- head/tests/sys/kern/ptrace_test.c Wed Feb 22 04:28:10 2017 (r314074) +++ head/tests/sys/kern/ptrace_test.c Wed Feb 22 04:35:07 2017 (r314075) @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -1690,7 +1691,7 @@ ATF_TC_BODY(ptrace__PT_KILL_breakpoint, ATF_REQUIRE((fpid = fork()) != -1); if (fpid == 0) { trace_me(); - __builtin_debugtrap(); + breakpoint(); exit(1); } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r314036 - head/usr.sbin/bsdinstall/scripts
On 02/21/2017 03:37 AM, Bartek Rutkowski wrote: Author: robak (ports committer) Date: Tue Feb 21 09:37:33 2017 New Revision: 314036 URL: https://svnweb.freebsd.org/changeset/base/314036 Log: Enable bsdinstall hardening options by default. As discussed previously, in order to introduce new OS hardening defaults, we've added them to bsdinstall in 'off by default' mode. It has been there for a while, so the next step is to change them to 'on by defaul' mode, so that in future we could simply enable them in base OS. Reviewed by: brd Approved by: adrian Differential Revision:https://reviews.freebsd.org/D9641 Modified: head/usr.sbin/bsdinstall/scripts/hardening Modified: head/usr.sbin/bsdinstall/scripts/hardening == --- head/usr.sbin/bsdinstall/scripts/hardening Tue Feb 21 09:33:21 2017 (r314035) +++ head/usr.sbin/bsdinstall/scripts/hardening Tue Feb 21 09:37:33 2017 (r314036) @@ -36,15 +36,15 @@ FEATURES=$( dialog --backtitle "FreeBSD --title "System Hardening" --nocancel --separate-output \ --checklist "Choose system security hardening options:" \ 0 0 0 \ - "0 hide_uids" "Hide processes running as other users" ${hide_uids:-off} \ - "1 hide_gids" "Hide processes running as other groups" ${hide_gids:-off} \ - "2 read_msgbuf" "Disable reading kernel message buffer for unprivileged users" ${read_msgbuf:-off} \ - "3 proc_debug" "Disable process debugging facilities for unprivileged users" ${proc_debug:-off} \ - "4 random_pid" "Randomize the PID of newly created processes" ${random_pid:-off} \ - "5 stack_guard" "Insert stack guard page ahead of the growable segments" ${stack_guard:-off} \ - "6 clear_tmp" "Clean the /tmp filesystem on system startup" ${clear_tmp:-off} \ - "7 disable_syslogd" "Disable opening Syslogd network socket (disables remote logging)" ${disable_syslogd:-off} \ - "8 disable_sendmail" "Disable Sendmail service" ${disable_sendmail:-off} \ + "0 hide_uids" "Hide processes running as other users" ${hide_uids:-on} \ + "1 hide_gids" "Hide processes running as other groups" ${hide_gids:-on} \ + "2 read_msgbuf" "Disable reading kernel message buffer for unprivileged users" ${read_msgbuf:-on} \ + "3 proc_debug" "Disable process debugging facilities for unprivileged users" ${proc_debug:-on} \ + "4 random_pid" "Randomize the PID of newly created processes" ${random_pid:-on} \ + "5 stack_guard" "Insert stack guard page ahead of the growable segments" ${stack_guard:-on} \ + "6 clear_tmp" "Clean the /tmp filesystem on system startup" ${clear_tmp:-on} \ + "7 disable_syslogd" "Disable opening Syslogd network socket (disables remote logging)" ${disable_syslogd:-on} \ + "8 disable_sendmail" "Disable Sendmail service" ${disable_sendmail:-on} \ 2>&1 1>&3 ) exec 3>&- Hi Bartek, Thanks for working on making it easier to harden FreeBSD. While defaulting some of these options to "on" seem pretty harmless (e.g. random_pid), others are likely to cause confusion for new and experienced users alike (e.g. proc_debug. I've never used that option before, so I gave it a try. It simply causes gdb to hang when attempting to start a process, with no obvious indication of why). I think more discussion is merited before they are turned on by default; personally I think they have potential to sour a first impression of FreeBSD by making things people are used to doing on other OSes hard. Eric ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r313992 - in head: sys/kern sys/sys tests/sys/kern
Author: badger Date: Mon Feb 20 15:53:16 2017 New Revision: 313992 URL: https://svnweb.freebsd.org/changeset/base/313992 Log: Defer ptracestop() signals that cannot be delivered immediately When a thread is stopped in ptracestop(), the ptrace(2) user may request a signal be delivered upon resumption of the thread. Heretofore, those signals were discarded unless ptracestop()'s caller was issignal(). Fix this by modifying ptracestop() to queue up signals requested by the ptrace user that will be delivered when possible. Take special care when the signal is SIGKILL (usually generated from a PT_KILL request); no new stop events should be triggered after a PT_KILL. Add a number of tests for the new functionality. Several tests were authored by jhb. PR: 212607 Reviewed by: kib Approved by: kib (mentor) MFC after:2 weeks Sponsored by: Dell EMC In collaboration with:jhb Differential Revision:https://reviews.freebsd.org/D9260 Modified: head/sys/kern/kern_fork.c head/sys/kern/kern_sig.c head/sys/kern/kern_thr.c head/sys/kern/subr_syscall.c head/sys/kern/sys_process.c head/sys/sys/signalvar.h head/tests/sys/kern/Makefile head/tests/sys/kern/ptrace_test.c Modified: head/sys/kern/kern_fork.c == --- head/sys/kern/kern_fork.c Mon Feb 20 10:51:46 2017(r313991) +++ head/sys/kern/kern_fork.c Mon Feb 20 15:53:16 2017(r313992) @@ -1081,7 +1081,7 @@ fork_return(struct thread *td, struct tr proc_reparent(p, dbg); sx_xunlock(_lock); td->td_dbgflags |= TDB_CHILD | TDB_SCX | TDB_FSTP; - ptracestop(td, SIGSTOP); + ptracestop(td, SIGSTOP, NULL); td->td_dbgflags &= ~(TDB_CHILD | TDB_SCX); } else { /* @@ -1102,7 +1102,7 @@ fork_return(struct thread *td, struct tr _STOPEVENT(p, S_SCX, td->td_dbg_sc_code); if ((p->p_ptevents & PTRACE_SCX) != 0 || (td->td_dbgflags & TDB_BORN) != 0) - ptracestop(td, SIGTRAP); + ptracestop(td, SIGTRAP, NULL); td->td_dbgflags &= ~(TDB_SCX | TDB_BORN); PROC_UNLOCK(p); } Modified: head/sys/kern/kern_sig.c == --- head/sys/kern/kern_sig.cMon Feb 20 10:51:46 2017(r313991) +++ head/sys/kern/kern_sig.cMon Feb 20 15:53:16 2017(r313992) @@ -278,6 +278,7 @@ sigqueue_init(sigqueue_t *list, struct p { SIGEMPTYSET(list->sq_signals); SIGEMPTYSET(list->sq_kill); + SIGEMPTYSET(list->sq_ptrace); TAILQ_INIT(>sq_list); list->sq_proc = p; list->sq_flags = SQ_INIT; @@ -301,9 +302,15 @@ sigqueue_get(sigqueue_t *sq, int signo, if (!SIGISMEMBER(sq->sq_signals, signo)) return (0); + if (SIGISMEMBER(sq->sq_ptrace, signo)) { + count++; + SIGDELSET(sq->sq_ptrace, signo); + si->ksi_flags |= KSI_PTRACE; + } if (SIGISMEMBER(sq->sq_kill, signo)) { count++; - SIGDELSET(sq->sq_kill, signo); + if (count == 1) + SIGDELSET(sq->sq_kill, signo); } TAILQ_FOREACH_SAFE(ksi, >sq_list, ksi_link, next) { @@ -347,7 +354,8 @@ sigqueue_take(ksiginfo_t *ksi) if (kp->ksi_signo == ksi->ksi_signo) break; } - if (kp == NULL && !SIGISMEMBER(sq->sq_kill, ksi->ksi_signo)) + if (kp == NULL && !SIGISMEMBER(sq->sq_kill, ksi->ksi_signo) && + !SIGISMEMBER(sq->sq_ptrace, ksi->ksi_signo)) SIGDELSET(sq->sq_signals, ksi->ksi_signo); } @@ -360,6 +368,10 @@ sigqueue_add(sigqueue_t *sq, int signo, KASSERT(sq->sq_flags & SQ_INIT, ("sigqueue not inited")); + /* +* SIGKILL/SIGSTOP cannot be caught or masked, so take the fast path +* for these signals. +*/ if (signo == SIGKILL || signo == SIGSTOP || si == NULL) { SIGADDSET(sq->sq_kill, signo); goto out_set_bit; @@ -398,16 +410,19 @@ sigqueue_add(sigqueue_t *sq, int signo, ksi->ksi_sigq = sq; } - if ((si->ksi_flags & KSI_TRAP) != 0 || - (si->ksi_flags & KSI_SIGQ) == 0) { - if (ret != 0) + if (ret != 0) { + if ((si->ksi_flags & KSI_PTRACE) != 0) { + SIGADDSET(sq->sq_ptrace, signo); + ret = 0; + goto out_set_bit; + } else if ((si->ksi_flags & KSI_TRAP) != 0 || + (si->ksi_flags & KSI_SIGQ) == 0) { SIGADDSET(sq->sq_kill, signo); - ret = 0; -
svn commit: r313733 - head/sys/kern
Author: badger Date: Tue Feb 14 17:13:23 2017 New Revision: 313733 URL: https://svnweb.freebsd.org/changeset/base/313733 Log: sleepq_catch_signals: do thread suspension before signal check Since locks are dropped when a thread suspends, it's possible for another thread to deliver a signal to the suspended thread. If the thread awakens from suspension without checking for signals, it may go to sleep despite having a pending signal that should wake it up. Therefore the suspension check is done first, so any signals sent while suspended will be caught in the subsequent signal check. Reviewed by: kib Approved by: kib (mentor) MFC after:2 weeks Sponsored by: Dell EMC Differential Revision:https://reviews.freebsd.org/D9530 Modified: head/sys/kern/subr_sleepqueue.c Modified: head/sys/kern/subr_sleepqueue.c == --- head/sys/kern/subr_sleepqueue.c Tue Feb 14 16:49:32 2017 (r313732) +++ head/sys/kern/subr_sleepqueue.c Tue Feb 14 17:13:23 2017 (r313733) @@ -430,6 +430,7 @@ sleepq_catch_signals(void *wchan, int pr struct sigacts *ps; int sig, ret; + ret = 0; td = curthread; p = curproc; sc = SC_LOOKUP(wchan); @@ -443,53 +444,65 @@ sleepq_catch_signals(void *wchan, int pr } /* -* See if there are any pending signals for this thread. If not -* we can switch immediately. Otherwise do the signal processing -* directly. +* See if there are any pending signals or suspension requests for this +* thread. If not, we can switch immediately. */ thread_lock(td); - if ((td->td_flags & (TDF_NEEDSIGCHK | TDF_NEEDSUSPCHK)) == 0) { - sleepq_switch(wchan, pri); - return (0); - } - thread_unlock(td); - mtx_unlock_spin(>sc_lock); - CTR3(KTR_PROC, "sleepq catching signals: thread %p (pid %ld, %s)", - (void *)td, (long)p->p_pid, td->td_name); - PROC_LOCK(p); - ps = p->p_sigacts; - mtx_lock(>ps_mtx); - sig = cursig(td); - if (sig == -1) { - mtx_unlock(>ps_mtx); - KASSERT((td->td_flags & TDF_SBDRY) != 0, ("lost TDF_SBDRY")); - KASSERT(TD_SBDRY_INTR(td), - ("lost TDF_SERESTART of TDF_SEINTR")); - KASSERT((td->td_flags & (TDF_SEINTR | TDF_SERESTART)) != - (TDF_SEINTR | TDF_SERESTART), - ("both TDF_SEINTR and TDF_SERESTART")); - ret = TD_SBDRY_ERRNO(td); - } else if (sig == 0) { - mtx_unlock(>ps_mtx); - ret = thread_suspend_check(1); - MPASS(ret == 0 || ret == EINTR || ret == ERESTART); - } else { - if (SIGISMEMBER(ps->ps_sigintr, sig)) - ret = EINTR; - else - ret = ERESTART; - mtx_unlock(>ps_mtx); + if ((td->td_flags & (TDF_NEEDSIGCHK | TDF_NEEDSUSPCHK)) != 0) { + thread_unlock(td); + mtx_unlock_spin(>sc_lock); + CTR3(KTR_PROC, "sleepq catching signals: thread %p (pid %ld, %s)", + (void *)td, (long)p->p_pid, td->td_name); + PROC_LOCK(p); + /* +* Check for suspension first. Checking for signals and then +* suspending could result in a missed signal, since a signal +* can be delivered while this thread is suspended. +*/ + if ((td->td_flags & TDF_NEEDSUSPCHK) != 0) { + ret = thread_suspend_check(1); + MPASS(ret == 0 || ret == EINTR || ret == ERESTART); + if (ret != 0) { + PROC_UNLOCK(p); + mtx_lock_spin(>sc_lock); + thread_lock(td); + goto out; + } + } + if ((td->td_flags & TDF_NEEDSIGCHK) != 0) { + ps = p->p_sigacts; + mtx_lock(>ps_mtx); + sig = cursig(td); + if (sig == -1) { + mtx_unlock(>ps_mtx); + KASSERT((td->td_flags & TDF_SBDRY) != 0, + ("lost TDF_SBDRY")); + KASSERT(TD_SBDRY_INTR(td), + ("lost TDF_SERESTART of TDF_SEINTR")); + KASSERT((td->td_flags & + (TDF_SEINTR | TDF_SERESTART)) != + (TDF_SEINTR | TDF_SERESTART), + ("both TDF_SEINTR and TDF_SERESTART")); + ret = TD_SBDRY_ERRNO(td); +
svn commit: r305956 - head/lib/libc/sys
Author: badger Date: Mon Sep 19 02:25:30 2016 New Revision: 305956 URL: https://svnweb.freebsd.org/changeset/base/305956 Log: Add manpage for rctl_* system calls Reviewed by: trasz, wblock Approved by: kib (mentor) MFC after:3 days Sponsored by: Dell Technologies Differential Revision:https://reviews.freebsd.org/D7877 Added: head/lib/libc/sys/rctl_add_rule.2 (contents, props changed) Modified: head/lib/libc/sys/Makefile.inc Modified: head/lib/libc/sys/Makefile.inc == --- head/lib/libc/sys/Makefile.inc Sun Sep 18 22:03:26 2016 (r305955) +++ head/lib/libc/sys/Makefile.inc Mon Sep 19 02:25:30 2016 (r305956) @@ -260,6 +260,7 @@ MAN+= abort2.2 \ pselect.2 \ ptrace.2 \ quotactl.2 \ + rctl_add_rule.2 \ read.2 \ readlink.2 \ reboot.2 \ @@ -423,6 +424,10 @@ MLINKS+=pdfork.2 pdgetpid.2\ pdfork.2 pdwait4.2 MLINKS+=pipe.2 pipe2.2 MLINKS+=poll.2 ppoll.2 +MLINKS+=rctl_add_rule.2 rctl_get_limits.2 \ + rctl_add_rule.2 rctl_get_racct.2 \ + rctl_add_rule.2 rctl_get_rules.2 \ + rctl_add_rule.2 rctl_remove_rule.2 MLINKS+=read.2 pread.2 \ read.2 preadv.2 \ read.2 readv.2 Added: head/lib/libc/sys/rctl_add_rule.2 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/libc/sys/rctl_add_rule.2 Mon Sep 19 02:25:30 2016 (r305956) @@ -0,0 +1,220 @@ +.\" Copyright (c) 2016 Eric Badger +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\"notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\"notice, this list of conditions and the following disclaimer in the +.\"documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd September 14, 2016 +.Dt RCTL_ADD_RULE 2 +.Os +.Sh NAME +.Nm rctl_add_rule, +.Nm rctl_get_limits +.Nm rctl_get_racct, +.Nm rctl_get_rules, +.Nm rctl_remove_rule +.Nd manipulate and query the resource limits database +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/rctl.h +.Ft int +.Fo rctl_add_rule +.Fa "const char *inbufp" "size_t inbuflen" "char *outbufp" "size_t outbuflen" +.Fc +.Ft int +.Fo rctl_get_limits +.Fa "const char *inbufp" "size_t inbuflen" "char *outbufp" "size_t outbuflen" +.Fc +.Ft int +.Fo rctl_get_racct +.Fa "const char *inbufp" "size_t inbuflen" "char *outbufp" "size_t outbuflen" +.Fc +.Ft int +.Fo rctl_get_rules +.Fa "const char *inbufp" "size_t inbuflen" "char *outbufp" "size_t outbuflen" +.Fc +.Ft int +.Fo rctl_remove_rule +.Fa "const char *inbufp" "size_t inbuflen" "char *outbufp" "size_t outbuflen" +.Fc +.Sh DESCRIPTION +These system calls are used to manipulate and query the resource limits +database. +For all functions, +.Fa inbuflen +refers to the length of the buffer pointed to by +.Fa inbufp +and +.Fa outbuflen +refers to the length of the buffer pointed to by +.Fa outbufp . +.Pp +The +.Fn rctl_add_rule +function adds the rule pointed to by +.Fa inbufp +to the resource limits database. +The +.Fa outbufp +and +.Fa outbuflen +arguments are unused. +Rule format is as described in +.Xr rctl 8 , +with exceptions noted in the +.Sx RULES AND FILTERS +section. +.Pp +The +.Fn rctl_get_limits +function returns in +.Fa outbufp +a comma-separated list of rules that apply to the process that +matches the filter specified in +.Fa inbufp . +This includes rules with a subject of the process itself
svn commit: r304652 - head/sbin/resolvconf
Author: badger Date: Tue Aug 23 02:06:20 2016 New Revision: 304652 URL: https://svnweb.freebsd.org/changeset/base/304652 Log: Fix missing substitution of @SBINDIR@ in resolvconf scripts Certain features, such as resolv_conf_passthrough=NULL, do not work correctly due to this missing substitution. Also remove the @PREFIX@ substitution, which is no longer needed. Reviewed by: pfg Approved by: vangyzen (mentor) MFC after:1 week Sponsored by: Dell Inc. Differential Revision:https://reviews.freebsd.org/D7572 Modified: head/sbin/resolvconf/Makefile Modified: head/sbin/resolvconf/Makefile == --- head/sbin/resolvconf/Makefile Tue Aug 23 01:58:02 2016 (r304651) +++ head/sbin/resolvconf/Makefile Tue Aug 23 02:06:20 2016 (r304652) @@ -16,6 +16,7 @@ CLEANFILES= ${SCRIPTS} ${FILES} ${MAN} SYSCONFDIR=/etc RCDIR= ${SYSCONFDIR}/rc.d VARDIR=/var/run/resolvconf +SBINDIR= /sbin # We don't assume to restart the services in /sbin. So, though # our service(8) is in /usr/sbin, we can use it, here. @@ -28,13 +29,13 @@ RESTARTCMD= "/usr/sbin/service ${CMD1} \ .for f in ${SCRIPTS} ${FILES} ${MAN} ${f}: ${f}.in - sed -e 's:@PREFIX@::g' \ - -e 's:@SYSCONFDIR@:${SYSCONFDIR}:g' \ + sed -e 's:@SYSCONFDIR@:${SYSCONFDIR}:g' \ -e 's:@LIBEXECDIR@:${FILESDIR}:g' \ -e 's:@VARDIR@:${VARDIR}:g' \ -e 's:@RESTARTCMD \(.*\)@:${RESTARTCMD_WITH_ARG}:g' \ -e 's:@RESTARTCMD@:${RESTARTCMD}:g' \ -e 's:@RCDIR@:${RCDIR}:g' \ + -e 's:@SBINDIR@:${SBINDIR}:g' \ -e 's: vpn : ng[0-9]*&:g' \ ${DIST}/$@.in > $@ .endfor ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r304184 - head/sys/kern
Author: badger Date: Mon Aug 15 20:09:09 2016 New Revision: 304184 URL: https://svnweb.freebsd.org/changeset/base/304184 Log: sem_post(): wake up the sleeper only after adjusting has_waiters If the caller of sem_post() wakes up a thread sleeping via sem_wait() before it clears the has_waiters flag, the caller of sem_wait() has no way of knowing when it is safe to destroy the semaphore and reuse the memory. This is because the caller of sem_post() may be interrupted between the wake step and the clearing of has_waiters. It will then write into the has_waiters flag in userspace after being preempted for some unknown amount of time. Reviewed by: jhb, kib, vangyzen Approved by: kib (mentor), vangyzen (mentor) MFC after:2 weeks Sponsored by: Dell Inc. Differential Revision:https://reviews.freebsd.org/D7505 Modified: head/sys/kern/kern_umtx.c Modified: head/sys/kern/kern_umtx.c == --- head/sys/kern/kern_umtx.c Mon Aug 15 19:47:04 2016(r304183) +++ head/sys/kern/kern_umtx.c Mon Aug 15 20:09:09 2016(r304184) @@ -3123,7 +3123,6 @@ do_sem_wake(struct thread *td, struct _u umtxq_busy(); cnt = umtxq_count(); if (cnt > 0) { - umtxq_signal(, 1); /* * Check if count is greater than 0, this means the memory is * still being referenced by user code, so we can safely @@ -3136,6 +3135,7 @@ do_sem_wake(struct thread *td, struct _u if (error == -1) error = EFAULT; } + umtxq_signal(, 1); } umtxq_unbusy(); umtxq_unlock(); @@ -3235,8 +3235,6 @@ do_sem2_wake(struct thread *td, struct _ umtxq_busy(); cnt = umtxq_count(); if (cnt > 0) { - umtxq_signal(, 1); - /* * If this was the last sleeping thread, clear the waiters * flag in _count. @@ -3251,6 +3249,8 @@ do_sem2_wake(struct thread *td, struct _ error = EFAULT; umtxq_lock(); } + + umtxq_signal(, 1); } umtxq_unbusy(); umtxq_unlock(); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r302783 - in head/sys: amd64/amd64 i386/i386 kern sys x86/x86
Author: badger Date: Wed Jul 13 19:19:18 2016 New Revision: 302783 URL: https://svnweb.freebsd.org/changeset/base/302783 Log: Add explicit detection of KVM hypervisor Set vm_guest to a new enum value (VM_GUEST_KVM) when kvm is detected and use vm_guest in conditionals testing for KVM. Also, fix a conditional checking if we're running in a VM which caught only the generic VM case, but not more specific VMs (KVM, VMWare, etc.). (Spotted by: vangyzen). Differential revision:https://reviews.freebsd.org/D7172 Sponsored by: Dell Inc. Approved by: kib (mentor), vangyzen (mentor) Reviewed by: alc MFC after:4 weeks Modified: head/sys/amd64/amd64/pmap.c head/sys/i386/i386/pmap.c head/sys/kern/subr_param.c head/sys/sys/systm.h head/sys/x86/x86/identcpu.c head/sys/x86/x86/local_apic.c Modified: head/sys/amd64/amd64/pmap.c == --- head/sys/amd64/amd64/pmap.c Wed Jul 13 19:16:32 2016(r302782) +++ head/sys/amd64/amd64/pmap.c Wed Jul 13 19:19:18 2016(r302783) @@ -1224,7 +1224,7 @@ pmap_init(void) * include at least one feature that is only supported by older Intel * or newer AMD processors. */ - if (vm_guest == VM_GUEST_VM && (cpu_feature & CPUID_SS) == 0 && + if (vm_guest != VM_GUEST_NO && (cpu_feature & CPUID_SS) == 0 && (cpu_feature2 & (CPUID2_SSSE3 | CPUID2_SSE41 | CPUID2_AESNI | CPUID2_AVX | CPUID2_XSAVE)) == 0 && (amd_feature2 & (AMDID2_XOP | AMDID2_FMA4)) == 0) Modified: head/sys/i386/i386/pmap.c == --- head/sys/i386/i386/pmap.c Wed Jul 13 19:16:32 2016(r302782) +++ head/sys/i386/i386/pmap.c Wed Jul 13 19:19:18 2016(r302783) @@ -794,7 +794,7 @@ pmap_init(void) * include at least one feature that is only supported by older Intel * or newer AMD processors. */ - if (vm_guest == VM_GUEST_VM && (cpu_feature & CPUID_SS) == 0 && + if (vm_guest != VM_GUEST_NO && (cpu_feature & CPUID_SS) == 0 && (cpu_feature2 & (CPUID2_SSSE3 | CPUID2_SSE41 | CPUID2_AESNI | CPUID2_AVX | CPUID2_XSAVE)) == 0 && (amd_feature2 & (AMDID2_XOP | AMDID2_FMA4)) == 0) Modified: head/sys/kern/subr_param.c == --- head/sys/kern/subr_param.c Wed Jul 13 19:16:32 2016(r302782) +++ head/sys/kern/subr_param.c Wed Jul 13 19:19:18 2016(r302783) @@ -148,6 +148,7 @@ static const char *const vm_guest_sysctl "xen", "hv", "vmware", + "kvm", NULL }; CTASSERT(nitems(vm_guest_sysctl_names) - 1 == VM_LAST); Modified: head/sys/sys/systm.h == --- head/sys/sys/systm.hWed Jul 13 19:16:32 2016(r302782) +++ head/sys/sys/systm.hWed Jul 13 19:19:18 2016(r302783) @@ -74,7 +74,7 @@ extern int vm_guest; /* Running as virt * Keep in sync with vm_guest_sysctl_names[]. */ enum VM_GUEST { VM_GUEST_NO = 0, VM_GUEST_VM, VM_GUEST_XEN, VM_GUEST_HV, - VM_GUEST_VMWARE, VM_LAST }; + VM_GUEST_VMWARE, VM_GUEST_KVM, VM_LAST }; #if defined(WITNESS) || defined(INVARIANT_SUPPORT) void kassert_panic(const char *fmt, ...) __printflike(1, 2); Modified: head/sys/x86/x86/identcpu.c == --- head/sys/x86/x86/identcpu.c Wed Jul 13 19:16:32 2016(r302782) +++ head/sys/x86/x86/identcpu.c Wed Jul 13 19:19:18 2016(r302783) @@ -1300,6 +1300,8 @@ identify_hypervisor(void) vm_guest = VM_GUEST_VMWARE; else if (strcmp(hv_vendor, "Microsoft Hv") == 0) vm_guest = VM_GUEST_HV; + else if (strcmp(hv_vendor, "KVMKVMKVM") == 0) + vm_guest = VM_GUEST_KVM; } return; } Modified: head/sys/x86/x86/local_apic.c == --- head/sys/x86/x86/local_apic.c Wed Jul 13 19:16:32 2016 (r302782) +++ head/sys/x86/x86/local_apic.c Wed Jul 13 19:19:18 2016 (r302783) @@ -499,8 +499,7 @@ native_lapic_init(vm_paddr_t addr) ver = lapic_read32(LAPIC_VERSION); if ((ver & APIC_VER_EOI_SUPPRESSION) != 0) { lapic_eoi_suppression = 1; - if (vm_guest == VM_GUEST_VM && - !strcmp(hv_vendor, "KVMKVMKVM")) { + if (vm_guest == VM_GUEST_KVM) { if (bootverbose) printf( "KVM -- disabling lapic eoi suppression\n");
svn commit: r302361 - head/share/misc
Author: badger Date: Wed Jul 6 03:23:07 2016 New Revision: 302361 URL: https://svnweb.freebsd.org/changeset/base/302361 Log: Add myself to the src committers graph. Approved by: re (gjb), kib (mentor) Modified: head/share/misc/committers-src.dot Modified: head/share/misc/committers-src.dot == --- head/share/misc/committers-src.dot Wed Jul 6 00:02:04 2016 (r302360) +++ head/share/misc/committers-src.dot Wed Jul 6 03:23:07 2016 (r302361) @@ -120,6 +120,7 @@ arybchik [label="Andrew Rybchenko\narybc asomers [label="Alan Somers\nasom...@freebsd.org\n2013/04/24"] avg [label="Andriy Gapon\n...@freebsd.org\n2009/02/18"] avos [label="Andriy Voskoboinyk\na...@freebsd.org\n2015/09/24"] +badger [label="Eric Badger\nbad...@freebsd.org\n2016/07/01"] bapt [label="Baptiste Daroussin\nb...@freebsd.org\n2011/12/23"] bdrewery [label="Bryan Drewery\nbdrew...@freebsd.org\n2013/12/14"] benl [label="Ben Laurie\nb...@freebsd.org\n2011/05/18"] @@ -588,6 +589,7 @@ ken -> asomers ken -> slm kib -> ae +kib -> badger kib -> dchagin kib -> gjb kib -> jah @@ -767,6 +769,8 @@ ume -> jinmei ume -> suz ume -> tshiozak +vangyzen -> badger + wes -> scf wkoszek -> jceel ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"