From owner-svn-src-all@freebsd.org Sat Jan 12 20:13:53 2019 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9BBAB149D569; Sat, 12 Jan 2019 20:13:53 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from smtp-out-no.shaw.ca (smtp-out-no.shaw.ca [64.59.134.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "Client", Issuer "CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 46AF66E15F; Sat, 12 Jan 2019 20:13:51 +0000 (UTC) (envelope-from cy.schubert@cschubert.com) Received: from spqr.komquats.com ([70.67.125.17]) by shaw.ca with ESMTPA id iPf7gON2bMRX3iPf9gUkgi; Sat, 12 Jan 2019 13:13:48 -0700 X-Authority-Analysis: v=2.3 cv=TL87tGta c=1 sm=1 tr=0 a=VFtTW3WuZNDh6VkGe7fA3g==:117 a=VFtTW3WuZNDh6VkGe7fA3g==:17 a=kj9zAlcOel0A:10 a=3JhidrIBZZsA:10 a=6I5d2MoRAAAA:8 a=nZOtpAppAAAA:20 a=pGLkceISAAAA:8 a=YxBL1-UpAAAA:8 a=BFii3V9eBqks62mI_OUA:9 a=q50BNmZ2_2ARdoOy:21 a=hiHaWYxBGi1EvSpd:21 a=CjuIK1q_8ugA:10 a=IjZwj45LgO3ly-622nXo:22 a=Ia-lj3WSrqcvXOmTRaiG:22 Received: from slippy.cwsent.com (slippy [10.1.1.91]) by spqr.komquats.com (Postfix) with ESMTPS id 9F7993425; Sat, 12 Jan 2019 12:13:48 -0800 (PST) Received: from slippy.cwsent.com (localhost [127.0.0.1]) by slippy.cwsent.com (8.15.2/8.15.2) with ESMTP id x0CKDivC064207; Sat, 12 Jan 2019 12:13:44 -0800 (PST) (envelope-from Cy.Schubert@cschubert.com) Received: from slippy (cy@localhost) by slippy.cwsent.com (8.15.2/8.15.2/Submit) with ESMTP id x0CKDhjA064204; Sat, 12 Jan 2019 12:13:43 -0800 (PST) (envelope-from Cy.Schubert@cschubert.com) Message-Id: <201901122013.x0CKDhjA064204@slippy.cwsent.com> X-Authentication-Warning: slippy.cwsent.com: cy owned process doing -bs X-Mailer: exmh version 2.8.0 04/21/2012 with nmh-1.7.1 Reply-to: Cy Schubert From: Cy Schubert X-os: FreeBSD X-Sender: cy@cwsent.com X-URL: http://www.cschubert.com/ To: Andrew Turner cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r342962 - in head: sys/amd64/conf sys/arm64/conf sys/conf sys/kern sys/sys tests/sys/kern In-Reply-To: Message from Andrew Turner of "Sat, 12 Jan 2019 11:21:28 +0000." <201901121121.x0CBLSiv058912@repo.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Sat, 12 Jan 2019 12:13:43 -0800 X-CMAE-Envelope: MS4wfB8s+Vo/U8CGkxnIOhtr2bo0dlIMpwGSpYJ3aoG6C7tmlQUvgOz7+pikUKVnySiv7eOhZvuyEGowPNtA0G2rwqOKArmphQq8KCJuOka9CXj6VoErn1DQ VYYb0CYzMew+G7240bwRcvxEMc70FW87+74CgRgVIEhg75//N8tbzEfD5sefLBalxtoVahSoYdlRvNtXINA/i09HLyXzka2MzfHsOzHXbmYlmVq6fQWQ2MvN 6RFRwyHIoHECAJA798nStoQ04A4Os5w1lJxlSQT6rbLagUGj8rwkXx2Em79SfOhi X-Rspamd-Queue-Id: 46AF66E15F X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-4.32 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_COUNT_FIVE(0.00)[5]; RECEIVED_SPAMHAUS_PBL(0.00)[17.125.67.70.zen.spamhaus.org : 127.0.0.11]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; MV_CASE(0.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; HAS_XAW(0.00)[]; HAS_REPLYTO(0.00)[Cy.Schubert@cschubert.com]; TO_DN_SOME(0.00)[]; REPLYTO_EQ_FROM(0.00)[]; IP_SCORE(-1.78)[ip: (-4.63), ipnet: 64.59.128.0/20(-2.34), asn: 6327(-1.85), country: CA(-0.09)]; MX_GOOD(-0.01)[spqr.komquats.com]; NEURAL_HAM_SHORT(-0.82)[-0.824,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; R_SPF_NA(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:6327, ipnet:64.59.128.0/20, country:CA]; RCVD_TLS_LAST(0.00)[]; RCVD_IN_DNSWL_LOW(-0.10)[9.134.59.64.list.dnswl.org : 127.0.5.1] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Jan 2019 20:13:54 -0000 In message <201901121121.x0CBLSiv058912@repo.freebsd.org>, Andrew Turner writes : > Author: andrew > Date: Sat Jan 12 11:21:28 2019 > New Revision: 342962 > URL: https://svnweb.freebsd.org/changeset/base/342962 > > Log: > Add support for the Clang Coverage Sanitizer in the kernel (KCOV). > > When building with KCOV enabled the compiler will insert function calls > to probes allowing us to trace the execution of the kernel from userspace. > These probes are on function entry (trace-pc) and on comparison operations > (trace-cmp). > > Userspace can enable the use of these probes on a single kernel thread with > an ioctl interface. It can allocate space for the probe with KIOSETBUFSIZE, > then mmap the allocated buffer and enable tracing with KIOENABLE, with the > trace mode being passed in as the int argument. When complete KIODISABLE > is used to disable tracing. > > The first item in the buffer is the number of trace event that have > happened. Userspace can write 0 to this to reset the tracing, and is > expected to do so on first use. > > The format of the buffer depends on the trace mode. When in PC tracing just > the return address of the probe is stored. Under comparison tracing the > comparison type, the two arguments, and the return address are traced. The > former method uses on entry per trace event, while the later uses 4. As > such they are incompatible so only a single mode may be enabled. > > KCOV is expected to help fuzzing the kernel, and while in development has > already found a number of issues. It is required for the syzkaller system > call fuzzer [1]. Other kernel fuzzers could also make use of it, either > with the current interface, or by extending it with new modes. > > A man page is currently being worked on and is expected to be committed > soon, however having the code in the kernel now is useful for other > developers to use. > > [1] https://github.com/google/syzkaller > > Submitted by: Mitchell Horne (Earlier version) > Reviewed by: kib > Testing by: tuexen > Sponsored by: DARPA, AFRL > Sponsored by: The FreeBSD Foundation (Mitchell Horne) > Differential Revision: https://reviews.freebsd.org/D14599 > > Added: > head/sys/kern/kern_kcov.c (contents, props changed) > head/sys/sys/kcov.h (contents, props changed) > head/tests/sys/kern/kcov.c (contents, props changed) > Modified: > head/sys/amd64/conf/GENERIC > head/sys/arm64/conf/GENERIC > head/sys/conf/files > head/sys/conf/kern.pre.mk > head/sys/conf/options > head/sys/kern/kern_thread.c > head/sys/sys/proc.h > head/tests/sys/kern/Makefile > [...] > Modified: head/sys/sys/proc.h > ============================================================================= > = > --- head/sys/sys/proc.h Sat Jan 12 11:14:59 2019 (r342961) > +++ head/sys/sys/proc.h Sat Jan 12 11:21:28 2019 (r342962) > @@ -175,6 +175,7 @@ struct filecaps; > struct filemon; > struct kaioinfo; > struct kaudit_record; > +struct kcov_info; > struct kdtrace_proc; > struct kdtrace_thread; > struct mqueue_notifier; > @@ -300,6 +301,7 @@ struct thread { > sbintime_t td_sleeptimo; /* (t) Sleep timeout. */ > int td_rtcgen; /* (s) rtc_generation of abs. sleep */ > size_t td_vslock_sz; /* (k) amount of vslock-ed space */ > + struct kcov_info *td_kcov_info; /* (*) Kernel code coverage data */ > #define td_endzero td_sigmask > > /* Copied during fork1() or create_thread(). */ > This breaks 32-bit builds (see jenkins email to recent committers from this morning). Inserting this here and calculating offsets for 64-bit platforms without taking into consideration 32-bit is the reason why. Maybe we should consider deorbit of 32-bit platforms sooner than later. -- Cheers, Cy Schubert FreeBSD UNIX: Web: http://www.FreeBSD.org The need of the many outweighs the greed of the few.