Thread View: muc.lists.freebsd.bugs
4 messages
4 total messages
Started by bugzilla-noreply
Thu, 26 Nov 2026 21:43
[Bug 301167] rtsock: routing-socket announcements reach classic jails that cannot read the same routes through the query paths
Author: bugzilla-noreply
Date: Thu, 26 Nov 2026 21:43
Date: Thu, 26 Nov 2026 21:43
101 lines
5993 bytes
5993 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=301167
Bug ID: 301167
Summary: rtsock: routing-socket announcements reach classic
jails that cannot read the same routes through the
query paths
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 process inside a classic jail receives routing-socket
announcements for host routes and interface addresses that the
same jail cannot read through the NET_RT_DUMP sysctl. The
routing socket needs no privilege from a jail, so an
unprivileged jailed process sees host route changes as they
happen.
To reproduce, on a host running 15.1-RELEASE-p7, create a
classic jail with one IP address, and inside it build and run
rtsock_jail_probe.c. The probe first reads the route table
through the NET_RT_DUMP sysctl, then opens a PF_ROUTE socket
and prints each announcement. The jail used one address,
10.27.9.20. Run as the jail's root, the baseline and one
announcement were:
$ jexec rtsockdemo /bin/rtsock_jail_probe --inside
caller: uid=0 euid=0 inside=1
visible entry 1: type=RTM_GET
dst af=2 10.27.9.20
sa af=18 len=16
sa af=18 len=56
sa af=2 127.0.0.1
NET_RT_DUMP: 256 bytes, 1 route entries visible to this caller
PF_ROUTE socket open; listening for announcements (30s window)
announcement: type=RTM_ADD len=184
dst af=2 172.16.99.81
gw af=2 10.27.9.1
The sysctl shows the jail one route, its own address. The
host's route add of 172.16.99.81 produced the pasted
announcement, and its removal produced a matching RTM_DELETE
with the same sockaddrs. The same differential
reproduces on 16.0-CURRENT, which showed RTM_ADD and
RTM_DELETE pairs for a host route and a lo0 alias, and it
reproduces unprivileged on the 15.1 jail: run with
the probe's --inside-nobody mode, which drops to uid 65534
before opening the socket, the announcement for the next
route add arrived the same way:
caller: uid=65534 euid=65534 inside=1
NET_RT_DUMP: 256 bytes, 1 route entries visible to this caller
PF_ROUTE socket open; listening for announcements (30s window)
announcement: type=RTM_ADD len=184
dst af=2 172.16.99.82
gw af=2 10.27.9.1
The intent to hide these routes from a jail is old and
explicit. Since January 2009, commit 813dd6ae5e04, the query
paths have filtered jailed callers: RTM_GET refuses non-host
routes and host routes outside the jail, and sysctl_dumpentry
does the same (the check became rt_is_exportable() in 2023).
The announcement writers in sys/net/rtsock.c have no such
filter. They pass their messages to rts_input(), which selects
receiving sockets by address family and FIB only.
prison_check_af() permits AF_ROUTE inside a jail, and
rts_attach() requires no privilege, so any process in the jail
receives what the host's routing changes produce.
The fix applies the same policy at the announcement boundary:
in rts_input(), at fanout, announce to each socket only what
rt_is_exportable() and prison_if() would export to that
socket's credentials, skipping a jailed socket for host
routes it could not query. The non-route messages, RTM_IFINFO
and RTM_IFANNOUNCE, need the same per-recipient decision. I
have not written a patch, so no patched 15.1 kernel was
built or run.
No RTM_IFINFO or RTM_IFANNOUNCE message appeared in any
recorded run, and I did not test the vnet case or the IPv6
family. The probe exits 0 when its listening window closes;
a failed sysctl read prints an error and the program still
exits 0.
--inside selects the jailed mode; --inside-nobody the
unprivileged form.
--
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 301167] rtsock: routing-socket announcements reach classic jails that cannot read the same routes through the query paths
Author: bugzilla-noreply
Date: Thu, 26 Nov 2026 21:43
Date: Thu, 26 Nov 2026 21:43
18 lines
2594 bytes
2594 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=301167 --- Comment #1 from laamalif@proton.me --- Created attachment 277768 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=277768&action=edit reproducer: --inside prints the NET_RT_DUMP baseline then listens on PF_ROUTE; --inside-nobody drops to uid 65534 first -- 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 301167] rtsock: routing-socket announcements reach classic jails that cannot read the same routes through the query paths
Author: bugzilla-noreply
Date: Fri, 27 Nov 2026 07:20
Date: Fri, 27 Nov 2026 07:20
55 lines
4520 bytes
4520 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=301167 --- Comment #2 from laamalif@proton.me --- I built the fanout filter and booted it on 15.1-RELEASE-p7. The tree was a pristine archive of releng/15.1 bb03631fe3b7. sys/net/rtsock.c after the patch is sha256 21c16d04ba39c88c6e8d92cf96413a31fa2dbfe032f7c9b0e338efd112acd38e. The kernel is sha256 d0f9c8842b86fee3352535b0d287e92222e04828c195249c59c555cbd5753f0e, booted as /boot/kernel.rtsock86/kernel. Stock if_ena.ko loaded from that directory. The patch also applies to main; I have not booted it there, and I have not built it on 14.4. A classic jail with ip4.addr=10.27.9.20 still has a one-entry NET_RT_DUMP (dst 10.27.9.20). While it listened, and while a host PF_ROUTE socket listened, the host ran route add/delete -host 172.16.99.81 10.27.9.1 and ifconfig ena0 alias 172.16.99.90/32 before that address was on the jail's list. The host socket received both. The jail received neither. Same result as uid 65534. After jail -m added 172.16.99.90 to the jail, ifconfig ena0 -alias and alias of that address produced RTM_DELADDR, RTM_DELETE, RTM_NEWADDR, and RTM_ADD on the jail socket, root and uid 65534. ifconfig lo0 mtu 16383 and back to 16384 produced two RTM_IFINFO messages on the jail socket and on the host socket. SIOCSIFFLAGS does not call rt_ifmsg, so a promisc toggle is not a test of that path. route -n get 10.27.9.20 in the jail prints the host route. route -n get 1.2.3.4 returns "route: route has not been found" and does not block. RTM_IFINFO and RTM_IFANNOUNCE are delivered. NET_RT_IFLIST already emits IFINFO for every interface, and SIOCGIFCONF already returns every name. RTM_IEEE80211 and RTM_IPFWLOG are dropped for a jailed_without_vnet socket. I did not generate either of those, and I did not test a vnet jail or IPv6. The patch also applies to current main b29084ae698f, to stable/15, and to releng/14.4; I built and booted it on 15.1-RELEASE-p7 only. The lock order the fanout adds (rtsock_mtx then the prison mtx via prison_if()) has no reverse path in the source, but the booted kernel had no WITNESS, so the order is source-checked and not witness-tested. The patch is rtsock-jail-filter.patch, sys/net/rtsock.c only. -- 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 301167] rtsock: routing-socket announcements reach classic jails that cannot read the same routes through the query paths
Author: bugzilla-noreply
Date: Fri, 27 Nov 2026 07:20
Date: Fri, 27 Nov 2026 07:20
17 lines
2603 bytes
2603 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=301167 --- Comment #3 from laamalif@proton.me --- Created attachment 277784 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=277784&action=edit the rts_input() fanout filter: per-recipient jail policy matching rt_is_exportable()/prison_if(); boot-verified on 15.1-RELEASE-p7 -- 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