Thread View: muc.lists.freebsd.bugs
2 messages
2 total messages
Started by bugzilla-noreply
Tue, 17 Nov 2026 13:53
[Bug 300837] BPF zero-copy descriptor with no buffers panics in bpf_zerocopy_canwritebuf()
Author: bugzilla-noreply
Date: Tue, 17 Nov 2026 13:53
Date: Tue, 17 Nov 2026 13:53
163 lines
6639 bytes
6639 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=300837
Bug ID: 300837
Summary: BPF zero-copy descriptor with no buffers panics in
bpf_zerocopy_canwritebuf()
Product: Base System
Version: 15.1-RELEASE
Hardware: Any
OS: Any
Status: New
Severity: Affects Some People
Priority: ---
Component: kern
Assignee: bugs@FreeBSD.org
Reporter: yangyang20250212@163.com
Summary
=======
A BPF descriptor can be switched to BPF_BUFMODE_ZBUF before zero-copy
buffers have been installed with BIOCSETZBUF.
Issuing BIOCFLUSH in this state causes reset_d() to call
bpf_zerocopy_canwritebuf() with d->bd_sbuf == NULL.
On FreeBSD 15.1-RELEASE-p3 this causes a kernel page fault at address
0x14. On a recent FreeBSD main kernel with INVARIANTS it triggers:
panic: bpf_zerocopy_canwritebuf: bd_sbuf NULL
Affected versions tested
========================
1. FreeBSD 15.1-RELEASE-p3, amd64, SYZKALLER kernel
Source revision:
88e7371d9dc26f85dfc1b008cbe59ebc7e4a33da
2. FreeBSD 16.0-CURRENT, amd64
Official main source commit:
fe9c7137871ee0b5c48d4c38b87d80f72e73379e
The issue reproduced independently on both versions.
Required configuration
======================
The following sysctl must be enabled:
sysctl net.bpf.zerocopy_enable=1
In the tested installations, /dev/bpf was owned by root:wheel with mode
0600. Therefore the reproducer required root privileges under the tested
default device permissions.
Minimal reproducer
==================
The essential sequence is:
fd = open("/dev/bpf", O_RDWR);
mode = BPF_BUFMODE_ZBUF;
ioctl(fd, BIOCSETBUFMODE, &mode);
ioctl(fd, BIOCFLUSH, NULL);
BIOCSETZBUF is intentionally not issued.
A complete standalone C reproducer is attached.
Observed result on FreeBSD 15.1
==============================
Fatal trap 12: page fault while in kernel mode
fault virtual address = 0x14
fault code = supervisor read data, page not present
panic: page fault
reset_d+0x136
bpfioctl+0x18f8
devfs_ioctl+0x14b
vn_ioctl+0x28b
devfs_ioctl_f+0x47
kern_ioctl+0x378
sys_ioctl+0x1f9
The same signature was reproduced on two independent cold boots.
Observed result on FreeBSD main
===============================
panic: bpf_zerocopy_canwritebuf: bd_sbuf NULL
bpf_zerocopy_canwritebuf()
reset_d()
bpfioctl()
devfs_ioctl()
vn_ioctl()
kern_ioctl()
sys_ioctl()
Analysis
========
BIOCSETBUFMODE permits a BPF descriptor to enter
BPF_BUFMODE_ZBUF before BIOCSETZBUF has installed the zero-copy
buffers.
BIOCFLUSH subsequently calls reset_d(). The buffer-mode dispatch reaches
bpf_zerocopy_canwritebuf(), but d->bd_sbuf is still NULL.
On the 15.1 test kernel, accessing zb->zb_flags through that NULL pointer
produces the page fault at address 0x14. On the main kernel, an INVARIANTS
assertion detects the same invalid descriptor state.
Possible fix
============
Possible approaches include:
1. Rejecting BIOCFLUSH and other reset operations while a ZBUF descriptor
has no buffers installed.
2. Making bpf_zerocopy_canwritebuf() safely handle an unconfigured
descriptor.
3. Preventing BIOCSETBUFMODE from making the descriptor operational in
ZBUF mode until BIOCSETZBUF has installed both buffers.
Other reset_d() callers, including filter replacement paths, may need the
same state validation.
Impact
======
A process that can open /dev/bpf and use BPF zero-copy mode can panic the
kernel, resulting in local denial of service.
In the tested default configuration, /dev/bpf was mode 0600 root:wheel
and net.bpf.zerocopy_enable was disabled by default. No privilege
escalation, controlled memory corruption, or remote trigger has been
demonstrated.
Discovery
=========
The issue was discovered using targeted Syzkaller fuzzing of FreeBSD BPF
descriptor and zero-copy buffer lifecycle operations.
Attribution
===========
Preferred credit:
wangxueyang
--
You are receiving this mail because:
You are the assignee for the bug.
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
[Bug 300837] BPF zero-copy descriptor with no buffers panics in bpf_zerocopy_canwritebuf()
Author: bugzilla-noreply
Date: Tue, 17 Nov 2026 13:55
Date: Tue, 17 Nov 2026 13:55
17 lines
2610 bytes
2610 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=300837
Mark Linimon <linimon@FreeBSD.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |crash
Assignee|bugs@FreeBSD.org |net@FreeBSD.org
--
You are receiving this mail because:
You are the assignee for the bug.
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads