Thread View: muc.lists.freebsd.bugs
4 messages
4 total messages
Started by bugzilla-noreply
Thu, 26 Nov 2026 21:05
[Bug 301166] ng_socket: ngc_send() accepts an arglen that does not match the sent message, so ngs_rcvmsg() copies kernel heap in...
Author: bugzilla-noreply
Date: Thu, 26 Nov 2026 21:05
Date: Thu, 26 Nov 2026 21:05
97 lines
5771 bytes
5771 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=301166
Bug ID: 301166
Summary: ng_socket: ngc_send() accepts an arglen that does not
match the sent message, so ngs_rcvmsg() copies kernel
heap into the caller's socket
Product: Base System
Version: 15.1-RELEASE
Hardware: Any
OS: Any
Status: New
Severity: Affects Only Me
Priority: ---
Component: kern
Assignee: bugs@FreeBSD.org
Reporter: laamalif@proton.me
A netgraph control message can claim a payload larger than
the bytes actually sent, and the reply path trusts the claim:
the sender reads kernel heap back through its own socket.
Host root and vnet-jail root can trigger it; a jailed root
receives host kernel heap.
To reproduce, load ng_socket, build the attached reproducer,
and run it twice as root: the control sends a well-formed
NGM_NODEINFO message, the trigger 8 bytes with arglen 4096 at
bytes 4 through 7, addressed to the node path ".". On
15.1-RELEASE-p7:
$ kldload ng_socket
$ ./ng_arglen_probe --cookie
caller: uid=0 euid=0 mode=control
sent 56 bytes (arglen field = 0)
read returned 128 bytes
header size 56, payload 72 bytes (arglen said 72)
non-zero non-sent payload bytes: 7 of 72
$ ./ng_arglen_probe
caller: uid=0 euid=0 mode=trigger
sent 8 bytes (arglen field = 4096)
read returned 4152 bytes
header size 56, payload 4096 bytes (arglen said 4096)
non-zero non-sent payload bytes: 816 of 4096
first 64 payload bytes:
00 00 00 00 00 00 00 00 72 74 73 6f 6c 64 00 6e 74 00 00 00 00 00 00 00 72 74
73 6f 6c 64 00 00
00 00 00 00 00 00 00 00 73 68 00 00 00 00 00 00 00 00 00 00 00 00 00 00 73 68
00 0c 00 f8 ff ff
The control's reply is the correct 128-byte node description
whose payload is the node name. The trigger's reply carries
kernel memory from past the 9-byte allocation: in the paste,
"rtsold" and "nt" from neighboring allocations, further bytes
resolving to 0xfffff800-range kernel pointers. On
16.0-CURRENT the same trigger returned repeated
0xffffffff8323a0e0 pointers and 0xdeadc0de values.
Under jail -c with vnet, the reproducer run as the jail's
root returned the same 4152-byte result; one run's payload
carried "tail" and "ntpd", another "sshd-session". The VIMAGE
privilege switch in sys/kern/kern_jail.c grants a vnet jail's
root PRIV_NETGRAPH_CONTROL, admitting it to the control
socket.
In sys/netgraph/ng_socket.c, ngc_send() allocates len + 1
bytes and validates only header.version, never comparing
header.arglen to len; the socket node's receive handler then
m_devget()s sizeof(struct ng_mesg) + arglen bytes from the
allocation into the sender's queue. The generic handlers
in ng_base.c that read the message argument check its length
first; the socket node's does not. A large
positive arglen would walk the copy toward unmapped memory, so
the missing check is also a crash risk.
The fix restores the invariant the NG_MKMESSAGE producers
already maintain, that arglen equals the bytes following the
header. Built into the module against the 15.1-RELEASE-p7
source and loaded, the trigger fails at sendto with EINVAL and
the control still returns the correct node description; a
vnet jail gets the same rejection, and the stock module
restored leaks again.
I did not run 14.4 or any other branch, the patched module on
CURRENT, or the crash variant, and ran everything on amd64
only. The reproducer exits 0 when it ran, 1 on a runtime error,
2 on usage; --cookie selects the control.
--
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 301166] ng_socket: ngc_send() accepts an arglen that does not match the sent message, so ngs_rcvmsg() copies kernel heap in...
Author: bugzilla-noreply
Date: Thu, 26 Nov 2026 21:05
Date: Thu, 26 Nov 2026 21:05
18 lines
2604 bytes
2604 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=301166 --- Comment #1 from laamalif@proton.me --- Created attachment 277765 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=277765&action=edit the strict-equality check in ngc_send: reject len < sizeof(header) or arglen != len - sizeof(header) -- 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 301166] ng_socket: ngc_send() accepts an arglen that does not match the sent message, so ngs_rcvmsg() copies kernel heap in...
Author: bugzilla-noreply
Date: Thu, 26 Nov 2026 21:05
Date: Thu, 26 Nov 2026 21:05
17 lines
2643 bytes
2643 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=301166 --- Comment #2 from laamalif@proton.me --- Created attachment 277766 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=277766&action=edit reproducer: sends a well-formed NGM_NODEINFO (control) or an 8-byte message with arglen 4096 (trigger); prints the reply sizes and payload bytes -- 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 301166] ng_socket: ngc_send() accepts an arglen that does not match the sent message, so ngs_rcvmsg() copies kernel heap in...
Author: bugzilla-noreply
Date: Thu, 26 Nov 2026 21:26
Date: Thu, 26 Nov 2026 21:26
16 lines
2587 bytes
2587 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=301166
Mark Linimon <linimon@FreeBSD.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
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