Article View: muc.lists.freebsd.bugs
Article #498[Bug 300837] BPF zero-copy descriptor with no buffers panics in bpf_zerocopy_canwritebuf()
From: 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
Technical Details
Message-ID:
<bug-300837-227@https.bugs.freebsd.org/bugzilla/>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.muc.de!.POSTED.news.muc.de!not-for-mailShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.muc.de!.POSTED.news.muc.de!not-for-mail From: bugzilla-noreply@freebsd.org Newsgroups: muc.lists.freebsd.bugs Subject: [Bug 300837] BPF zero-copy descriptor with no buffers panics in bpf_zerocopy_canwritebuf() Date: Tue, 17 Nov 2026 13:53:19 +0000 Organization: Newsgate at muc.de e.V. Approved: news-admin@muc.de Distribution: world Message-ID: <bug-300837-227@https.bugs.freebsd.org/bugzilla/> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: news.muc.de; posting-host="news.muc.de:193.149.48.2"; logging-data="62139"; mail-complaints-to="news-admin@muc.de" X-Original-To: bugs@mlmmj.nyi.freebsd.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794923599; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=kg3jd1QO4FaDzA/0oBnaoncVmfGlZg422CzSva9gTVs=; b=nRQv8r2mMN6pyyxobeNqhQGOncab/6d78f3X8d76SPy2orqk9PVJRgqr+yoJnRHRS9++Lj j00GnzgmAcmApVTF9oRn1QJvQryCwcQVmmiqFdTaD/B7+fGlM6aiHY4K4sw14yTRHAX8c1 5nN3+kaFgI91qmj0MUn12aVsTGBa9StHSDe9Vxg54I7ZO4glV3WPzd4xB6edb/MYcnrbD8 CwvLUA3kJ0ZdlmpU9vC66f3yclCWIkZhbigk9vC0+jo9egn+igbwHaM+1ckh6rJIGBrzBs mdNZXPpI29KWk2c3SFrVxyAEwlX/MMgYcyxh23udpaXrtGsQ75NB0vwW9we9zg== X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f Auto-Submitted: auto-generated Precedence: list X-Newsgate-Id: f02c70b8849f+ X-No-Archive: Yes