opnsense-src/sys
Mark Johnston 6b95cf5bde callout: Wait for the softclock thread to switch before rescheduling
When a softclock thread prepares to go off-CPU, the following happens in
the context of the thread:

1. callout state is locked
2. thread state is set to IWAIT
3. thread lock is switched from the tdq lock to the callout lock
4. tdq lock is released
5. sched_switch() sets td_lock to &blocked_lock
6. sched_switch() releases old td_lock (callout lock)
7. sched_switch() removes td from its runqueue
8. cpu_switch() sets td_lock back to the callout lock

Suppose a timer interrupt fires while the softclock thread is switching
off, and callout_process() schedules the softclock thread.  Then there
is a window between steps 5 and 8 where callout_process() can call
sched_add() while td_lock is &blocked_lock, but this is not correct
since the thread is not logically locked.

callout_process() thus needs to spin waiting for the softclock thread to
finish switching off (i.e., after step 8 completes) before rescheduling
it, since callout_process() does not acquire the thread lock directly.

Reported by:	syzbot+fb44dbf6734ff492c337@syzkaller.appspotmail.com
Fixes:		74cf7cae4d ("softclock: Use dedicated ithreads for running callouts.")
Reviewed by:	mav, kib, jhb
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33709
2021-12-31 17:01:39 -05:00
..
amd64 exec: Simplify sv_copyout_strings implementations a bit 2021-12-31 12:50:15 -05:00
arm vm_extern: use standard address checkers everywhere 2021-12-30 22:09:08 -06:00
arm64 exec: Simplify sv_copyout_strings implementations a bit 2021-12-31 12:50:15 -05:00
bsm Add fspacectl(2), vn_deallocate(9) and VOP_DEALLOCATE(9). 2021-08-05 23:20:42 +08:00
cam CAM: List few missed opcodes. 2021-12-31 11:48:03 -05:00
cddl dtrace: Use C99 fixed-width integer types. 2021-12-28 09:41:25 -08:00
compat exec: Simplify sv_copyout_strings implementations a bit 2021-12-31 12:50:15 -05:00
conf Add lio back to NOTES 2021-12-31 14:56:16 -07:00
contrib iwlwifi: import correct firmware versions for select Intel iwlwifi/mvm 2021-12-31 11:51:18 +00:00
crypto sys/crypto: Use C99 fixed-width integer types. 2021-12-28 09:41:38 -08:00
ddb sys/ddb: Use C99 fixed-width integer types. 2021-12-28 09:41:47 -08:00
dev iommu_gas: Rename a function missed earlier 2021-12-31 01:50:30 -06:00
dts add rk3328 overlay for enabling analog sound 2021-11-13 11:09:23 +02:00
fs Improve extents verification logic 2021-12-30 09:14:45 +03:00
gdb gdb: report specific stop reason for watchpoints 2021-03-30 11:36:41 -03:00
geom sys/geom: Use C99 fixed-width integer types. 2021-12-28 09:41:51 -08:00
gnu Remove the old dts imported tree. 2021-01-15 20:09:55 +01:00
i386 exec: Simplify sv_copyout_strings implementations a bit 2021-12-31 12:50:15 -05:00
isa sys/isa: Use C99 fixed-width integer types. 2021-12-28 09:41:57 -08:00
kern callout: Wait for the softclock thread to switch before rescheduling 2021-12-31 17:01:39 -05:00
kgssapi opencrypto: Introduce crypto_dispatch_async() 2021-02-08 09:19:19 -05:00
libkern sys/libkern: Use C99 fixed-width integer types. 2021-12-28 09:42:11 -08:00
modules iwlwifi: import correct firmware versions for select Intel iwlwifi/mvm 2021-12-31 11:51:18 +00:00
net Fix kernel build without INET6 2021-12-30 18:40:46 -05:00
net80211 net80211: adjust a printf to toeee80211_note 2021-12-26 17:26:58 +00:00
netgraph netgraph: Remove CTLFLAG_NEEDGIANT from sysctl. 2021-12-26 19:42:53 -05:00
netinet sctp: retire sctp_mtu_size_reset() 2021-12-30 15:30:11 +01:00
netinet6 sctp: improve sctp_pathmtu_adjustment() 2021-12-30 15:16:05 +01:00
netipsec crypto: Consistently use AES instead of Rijndael128 for the AES-CBC cipher. 2021-12-16 13:47:27 -08:00
netpfil ipfilter: Move kernel bits to netpfil 2021-12-20 06:16:33 -08:00
netsmb netsmb: Avoid a read-after-free in smb_t2_request_int() 2021-05-26 10:45:40 -04:00
nfs nfs: don't truncate directory cookies to 32-bits in the NFS server 2021-12-15 20:54:57 -07:00
nfsclient nfs: Cleanup dead files 2021-03-17 06:16:31 +11:00
nfsserver nfs: Cleanup dead files 2021-03-17 06:16:31 +11:00
nlm sys/nlm: Use C99 fixed-width integer types. 2021-12-28 09:42:42 -08:00
ofed sys/ofed: Use C99 fixed-width integer types. 2021-12-28 09:43:09 -08:00
opencrypto /dev/crypto: Store blocksize in cse rather than txform pointer. 2021-12-29 17:50:23 -08:00
powerpc vm_extern: use standard address checkers everywhere 2021-12-30 22:09:08 -06:00
riscv riscv-busdma: Balance parens. 2021-12-31 02:01:58 -06:00
rpc sys/rpc: Use C99 fixed-width integer types. 2021-12-28 09:43:15 -08:00
security Thread creation privilege for realtime group 2021-12-15 00:01:58 +02:00
sys sys/cpuset.h: fix macro definition 2021-12-31 14:09:44 +01:00
teken loader: implement framebuffer console 2021-01-02 21:41:36 +02:00
tests routing: add IPv6 fib validation procedure. 2021-08-16 23:04:01 +00:00
tools arm64: Don't rely on host readelf for u-boot booti image generation 2021-12-24 19:25:20 +00:00
ufs Change VOP_READDIR's cookies argument to a **uint64_t 2021-12-15 20:54:57 -07:00
vm vm_reserv: #include vm_extern.h explicitly, for arm. 2021-12-31 00:40:25 -06:00
x86 x86-busdma - Add missing paren 2021-12-31 02:33:54 -06:00
xdr sys/xdr: Use C99 fixed-width integer types. 2021-12-28 09:43:26 -08:00
xen Create wrapper for Giant taken for newbus 2021-12-09 17:04:45 -07:00
Makefile