opnsense-src/etc
Kristof Provost dd49816b0d bpf: avoid panic on multiple readers
If we have multiple simultaneous readers on a single /dev/bpf fd it's possible
for the assertion after the bpf_uiomove() in bpfread() to fail.

Note that the bpf_uiomove() is done outside of the BPFD_LOCK, because uiomove
may sleep. As a result it's possible for another thread to have already
reclaimed toe bd_hbuf, thus causing us to fail the assertion.
Even without INVARIANTS this may provoke panics.

That results (with INVARIANTS) in a panic such as:

	login: panic: bpfread: lost bd_hbuf
	cpuid = 13
	time = 1740567635
	KDB: stack backtrace:
	db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe003972db10
	vpanic() at vpanic+0x136/frame 0xfffffe003972dc40
	panic() at panic+0x43/frame 0xfffffe003972dca0
	bpfread() at bpfread+0x2e8/frame 0xfffffe003972dce0
	devfs_read_f() at devfs_read_f+0xe4/frame 0xfffffe003972dd40
	dofileread() at dofileread+0x80/frame 0xfffffe003972dd90
	sys_read() at sys_read+0xb7/frame 0xfffffe003972de00
	amd64_syscall() at amd64_syscall+0x15a/frame 0xfffffe003972df30
	fast_syscall_common() at fast_syscall_common+0xf8/frame 0xfffffe003972df30
	--- syscall (3, FreeBSD ELF64, read), rip = 0x302787166afa, rsp = 0x302782638a78, rbp = 0x302782638aa0 ---

Also add a test case replicating the known trigger for this panic.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D49135
2025-04-09 09:39:01 +02:00
..
gss Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
mail mailer.conf for sendmail: remove duplicate word. 2024-08-07 17:03:12 +03:00
mtree bpf: avoid panic on multiple readers 2025-04-09 09:39:01 +02:00
root etc: remove leftover leading empty comments, blank lines 2023-08-22 13:03:28 -05:00
sendmail Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
termcap termcap.small: Include xterm-256color 2023-12-02 00:55:56 -05:00
group etc: remove leftover leading empty comments, blank lines 2023-08-22 13:03:28 -05:00
Makefile mtree: TESTSBASE directory always starts with a / 2025-01-24 23:10:05 +00:00
Makefile.depend Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
master.passwd etc: remove leftover leading empty comments, blank lines 2023-08-22 13:03:28 -05:00
shells etc: remove leftover leading empty comments, blank lines 2023-08-22 13:03:28 -05:00