Article View: muc.lists.freebsd.bugs
Article #796[Bug 301185] ng_netflow: ng_netflow_flow_show() bounds-checks hash_id as a signed int, so values with the high bit set index bef...
From: bugzilla-noreply
Date: Fri, 27 Nov 2026 13:33
Date: Fri, 27 Nov 2026 13:33
104 lines
6271 bytes
6271 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=301185
Bug ID: 301185
Summary: ng_netflow: ng_netflow_flow_show() bounds-checks
hash_id as a signed int, so values with the high bit
set index before the hash array and panic
Product: Base System
Version: CURRENT
Hardware: Any
OS: Any
Status: New
Severity: Affects Only Me
Priority: ---
Component: kern
Assignee: bugs@FreeBSD.org
Reporter: laamalif@proton.me
ng_netflow_flow_show() stores the show command's hash_id in a
signed int and rejects the index only when that int is greater
than NBUCKETS-1 (65535). hash_id is a uint32_t, so a value with
the high bit set passes that test and priv->hash + i points
before the 65536-entry array. mtx_trylock() on that address
page-faults.
At main 69141e71f3ee the test is:
i = req->hash_id;
if (i > NBUCKETS-1)
return (EINVAL);
i is declared int. Those three lines are already in ea7e16388267
(2011-07-05), which added this show message. The function text
matches on stable/15, stable/14, releng/15.1, and releng/14.4
except MTX_WAITERS versus MTX_CONTESTED. The node registers no
ASCII show command, so ngctl cannot name it. flowctl(8) sends
NGM_NETFLOW_SHOW with hash_id 0 and walks the reply. netflow_show
sends one show, version 4, with the hash_id from argv. Creating
the node needs PRIV_NETGRAPH_CONTROL.
On 16.0-CURRENT GENERIC-KASAN amd64 (main-6edecf52def6-dirty,
built Thu Nov 26 10:23:49 UTC 2026) I loaded the stock
/boot/kernel.kasan/ng_netflow.ko. An unprivileged run failed in
NgMkSockNode with "Operation not permitted". As root, at
2026-11-26T17:47:11Z:
cc -Wall -Wextra -Werror -o /tmp/netflow_show /tmp/netflow_show.c -lnetgraph
/tmp/netflow_show 0
show version=4 hash_id=0x0 -> reply version=4 nentries=0 next_hash=0x0
/tmp/netflow_show 65535
show version=4 hash_id=0xffff -> reply version=4 nentries=0 next_hash=0x0
/tmp/netflow_show 65536
show version=4 hash_id=0x10000 -> errno 22 (Invalid argument)
/tmp/netflow_show 0x7fffffff
show version=4 hash_id=0x7fffffff -> errno 22 (Invalid argument)
/tmp/netflow_show 0x80000000 did not print. The SSH session
dropped (connection timed out, then broken pipe).
/var/crash/vmcore.8, dumptime 2026-11-26 17:47:40 UTC, panic
string "page fault". core.txt.8:
#9 0xffffffff8128fa7e in _mtx_trylock_flags_int (m=0xfffffde9595b1000, opts=0,
file=0xffffffff847fd040 <str> "/usr/src/sys/netgraph/netflow/netflow.c",
line=949) at /usr/src/sys/kern/kern_mutex.c:453
#10 0xffffffff847f8aaf in ng_netflow_flow_show () from
/boot/kernel.kasan/ng_netflow.ko
#11 0xffffffff847f3750 in ng_netflow_rcvmsg () from
/boot/kernel.kasan/ng_netflow.ko
#12 0xffffffff84805a2e in ng_apply_item () from /boot/kernel.kasan/netgraph.ko
#13 0xffffffff84805143 in ng_snd_item () from /boot/kernel.kasan/netgraph.ko
#14 0xffffffff8481b550 in ngc_send () from /boot/kernel.kasan/ng_socket.ko
#21 sys_sendto (td=0xfffffe0145361780, uap=<optimized out>) at
/usr/src/sys/kern/uipc_syscalls.c:820
Line 949 in that tree is the mtx_trylock of hsh->mtx. The panic
string is "page fault", not a KASAN report.
The attached patch compares hash_id as unsigned against NBUCKETS
before assigning it to i. I built that as ng_netflow.ko (sha256
50e51d2ea3bc2f5d677f9d3364a7c7f99f7b42ab5fa77de3850aa86a1922c928)
against the same KASAN kernel and loaded it. The same netflow_show
binary (sha256
4dead1b6d7e3552aeb8baee6f904a25d2c5dcc297719a013ccda7469a50fc411)
then returned EINVAL for 0x80000000 and 0xffffffff, and the four
values above behaved the same way. The host stayed up.
I have not run the stock fault or the patched module on
15.1-RELEASE (that run is feasible and was not done for this
report) or on 14.4-RELEASE (no 14.4 system is available here
and its ng_netflow.ko cannot load on the 15.1 boxes, so the
14.4 claim is source-level only), and I have not sent the
message from a vnet jail.
--
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-301185-227@https.bugs.freebsd.org/bugzilla/>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!usenet.goja.nl.eu.org!3.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!srv.newsdeef.eu!newsfeed.bofh.team!usenet.goja.nl.eu.org!3.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 301185] ng_netflow: ng_netflow_flow_show() bounds-checks hash_id as a signed int, so values with the high bit set index before the hash array and panic Date: Fri, 27 Nov 2026 13:33:43 +0000 Organization: Newsgate at muc.de e.V. Approved: news-admin@muc.de Distribution: world Message-ID: <bug-301185-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="97671"; 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=1795786423; 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=48hJfgbCO3QLF4LeifbNAxSh0ct1X2wYez77ar6aQ4M=; b=G+O2P3YQvPmmMcFNzUyKgiE7tA7YZSk9LrB3hl+BFSZ3gZD/vOKdY04DOKKY+w4rJ8yyeB 4D58yPTZOzYnqZPNDQwCDjmJpuJrAt+QuC1hWgOb4I7gV4kLJXc1yunkp70ScGLOQ5xRPC WVzmVhP7GFFwK/jW/NjcLohdVsBqlft/BcgE2578yXQvtIqtXyY5Whb22N3MLifhmpr/a0 2XmorEujclBpcjHWOGXc64q87sZuCguE0pqz+SLX1vD7Td88mS3xbCKKAKfglx5RY5GVdX 9oVNejAoNL0rwZdfEbBQetJNETZSiMZeZLd+l1EUUi/1o1G/xpVbEUxHOcUtKg== 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