OPNsense - FreeBSD source
Find a file
Mark Johnston a9184e99af kthread: Set *newtdp earlier in kthread_add1()
syzbot reported a single boot-time crash in g_event_procbody(), a page
fault when dereferencing g_event_td.  g_event_td is initialized by the
kproc_kthread_add() call which creates the GEOM event thread:

  kproc_kthread_add(g_event_procbody, NULL, &g_proc, &g_event_td,
      RFHIGHPID, 0, "geom", "g_event");

I believe that the caller of kproc_kthread_add() was preempted after
adding the new thread to the scheduler, and before setting *newtdp,
which is equal to g_event_td.  Thus, since the first action of the GEOM
event thread is to lock itself, it ended up dereferencing a NULL
pointer.

Fix the problem simply by initializing *newtdp earlier.  I see no harm
in that, and it matches kproc_create1().  The scheduler provides
sufficient synchronization to ensure that the store is visible to the
new thread, wherever it happens to run.

Reported by:	syzbot+5397f4d39219b85a9409@syzkaller.appspotmail.com
Reviewed by:	kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D42986

(cherry picked from commit ae77041e0714627f9ec8045ca9ee2b6ea563138e)
2023-12-17 21:20:13 -05:00
.cirrus-ci Cirrus-CI: add some timing info on pkg install failure 2021-08-04 15:02:00 -04:00
.github MAINTAINERS: Add myself to stand 2023-05-07 22:30:10 -06:00
bin ps: s/kern.max_pid/kern.pid_max/ in a comment 2023-12-13 23:08:50 +00:00
cddl zfs: merge openzfs/zfs@55dd24c4c (zfs-2.2-release) into stable/14 2023-11-22 12:43:59 +01:00
contrib telnet: remove locally added __FBSDID 2023-12-13 23:08:51 +00:00
crypto OpenSSL: update to 3.0.12 2023-10-25 16:20:31 -04:00
etc rtld: add a test for RTLD_DEEPBIND 2023-12-14 18:58:36 -06:00
gnu Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
include libc/libc/rpc: refactor some global variables 2023-11-29 20:16:16 -07:00
kerberos5 Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
lib strfmon.c: Use the restrict keyword directly 2023-12-16 06:17:51 +02:00
libexec rc.conf: correct $ntp_leapfile_sources 2023-12-16 10:31:41 +08:00
release pkgbase: propagate SRCRELDATE to the packages correctly 2023-12-07 08:48:00 +01:00
rescue zfs: merge openzfs/zfs@32949f256 (zfs-2.2-release) into stable/14 2023-09-03 09:15:24 +02:00
sbin ping: Simplify protocol selection. 2023-12-13 17:41:46 +01:00
secure OpenSSL: update to 3.0.12 2023-10-25 16:20:31 -04:00
share tcp: add PRR 6937bis heuristic and retire prr_conservative sysctl 2023-12-15 09:25:07 +01:00
stand stand: Rename LIBFDT to LIBSAFDT 2023-11-16 10:18:58 -05:00
sys kthread: Set *newtdp earlier in kthread_add1() 2023-12-17 21:20:13 -05:00
targets Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
tests bitstring: Support large bit strings. 2023-12-13 17:41:48 +01:00
tools sendmail: remove all m4 files with WITHOUT_SENDMAIL 2023-12-04 11:22:22 +01:00
usr.bin lockf: switch to strtonum() for parsing timeout 2023-12-14 18:58:33 -06:00
usr.sbin iostat.8: Better wording for some use cases 2023-12-17 15:51:53 +01:00
.arcconfig arcanist: use FreeBSD/git project repository instead of FreeBSD/svn 2022-08-23 14:16:41 +00:00
.arclint
.cirrus.yml Cirrus-CI: restore amd64-gcc12 build/test on main 2023-08-18 22:35:39 -04:00
.clang-format Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
.git-blame-ignore-revs git-blame-ignore-revs: OptionalObsoleteFiles.inc sorting commits 2023-12-02 00:56:40 +00:00
.gitattributes Add a basic clang-format configuration file 2019-06-07 15:23:52 +00:00
.gitignore Packaging: Auto-generate changelog during configure (#15528) 2023-11-16 14:23:03 -08:00
CONTRIBUTING.md CONTRIBUTING.md: reinsert double spaces 2023-07-10 12:24:24 -06:00
COPYRIGHT Happy New Year 2023! 2023-01-01 13:44:43 +08:00
LOCKS Remove $FreeBSD$: one-line bare tag 2023-08-16 11:55:20 -06:00
MAINTAINERS Remove $FreeBSD$: one-line bare tag 2023-08-16 11:55:20 -06:00
Makefile pkgbase: create source package 2023-12-07 08:47:16 +01:00
Makefile.inc1 pkgbase: propagate SRCRELDATE to the packages correctly 2023-12-07 08:48:00 +01:00
Makefile.libcompat build{libcompat}: Pass UNIVERSE_TOOLCHAIN_PATH to the _lc_build-tools submake 2023-08-21 21:00:45 -07:00
Makefile.sys.inc Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
ObsoleteFiles.inc net80211: remove ieee80211_unref_node() 2023-11-30 00:36:58 +00:00
README.md FreeBSD: Fix the build on FreeBSD 12 2023-11-28 15:19:07 -08:00
RELNOTES Fix typo in RELNOTES (objump -> objdump) 2023-09-24 09:18:21 -04:00
UPDATING pkgbase: Split out manpages by default 2023-10-20 13:16:47 +01:00

FreeBSD Source:

This is the top level of the FreeBSD source directory.

FreeBSD is an operating system used to power modern servers, desktops, and embedded platforms. A large community has continually developed it for more than thirty years. Its advanced networking, security, and storage features have made FreeBSD the platform of choice for many of the busiest web sites and most pervasive embedded networking and storage devices.

For copyright information, please see the file COPYRIGHT in this directory. Additional copyright information also exists for some sources in this tree - please see the specific source directories for more information.

The Makefile in this directory supports a number of targets for building components (or all) of the FreeBSD source tree. See build(7), config(8), FreeBSD handbook on building userland, and Handbook for kernels for more information, including setting make(1) variables.

For information on the CPU architectures and platforms supported by FreeBSD, see the FreeBSD website's Platforms page.

Source Roadmap:

Directory Description
bin System/user commands.
cddl Various commands and libraries under the Common Development and Distribution License.
contrib Packages contributed by 3rd parties.
crypto Cryptography stuff (see crypto/README).
etc Template files for /etc.
gnu Commands and libraries under the GNU General Public License (GPL) or Lesser General Public License (LGPL). Please see gnu/COPYING and gnu/COPYING.LIB for more information.
include System include files.
kerberos5 Kerberos5 (Heimdal) package.
lib System libraries.
libexec System daemons.
release Release building Makefile & associated tools.
rescue Build system for statically linked /rescue utilities.
sbin System commands.
secure Cryptographic libraries and commands.
share Shared resources.
stand Boot loader sources.
sys Kernel sources (see sys/README.md).
targets Support for experimental DIRDEPS_BUILD
tests Regression tests which can be run by Kyua. See tests/README for additional information.
tools Utilities for regression testing and miscellaneous tasks.
usr.bin User commands.
usr.sbin System administration commands.

For information on synchronizing your source tree with one or more of the FreeBSD Project's development branches, please see FreeBSD Handbook.