git: 6805375783d0 - main - dummynet: copy only the user-visible scheduler in copy_obj()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 26 Nov 2026 15:40:52 UTC
The branch main has been updated by kp:
URL: https://cgit.FreeBSD.org/src/commit/?id=6805375783d0ab5ccd59ac07f84d89f2109400e5
commit 6805375783d0ab5ccd59ac07f84d89f2109400e5
Author: Osvaldo Janeri Filho <ojanerif@amd.com>
AuthorDate: 2026-11-26 13:23:27 +0000
Commit: Kristof Provost <kp@FreeBSD.org>
CommitDate: 2026-11-26 15:40:19 +0000
dummynet: copy only the user-visible scheduler in copy_obj()
For a DN_SCH object copy_obj() writes the whole struct dn_schk (192
bytes on amd64) into the listing buffer, but checks and advances by
o.len, which is sizeof(struct dn_sch) (92 bytes). The extra bytes,
kernel pointers included, overrun the buffer when the scheduler is
near its end. "ipfw pipe show" or "dnctl pipe show" is enough, from
the host or from a VNET jail; KASAN reports a 192-byte write in
copy_obj().
Keep only a struct dn_sch in the local copy, which is what the code
wrote before 0ac43d9728a7, and read siht from the struct dn_schk that
contains it. Add a test that lists pipes and schedulers from a VNET
jail.
PR: 224485
Reported by: david@catwhisker.org
Reviewed by: kp
Fixes: 0ac43d9728a7 ("In dummynet(4), random chunks of memory are casted to struct dn_*,")
Sponsored by: Advanced Micro Devices, Inc.
Signed-off-by: Osvaldo Janeri Filho <ojanerif@amd.com>
Differential Revision: https://reviews.freebsd.org/D61962
---
sys/netpfil/ipfw/ip_dummynet.c | 10 ++++++----
tests/sys/netpfil/common/dummynet.sh | 27 +++++++++++++++++++++++++++
2 files changed, 33 insertions(+), 4 deletions(-)
diff --git a/sys/netpfil/ipfw/ip_dummynet.c b/sys/netpfil/ipfw/ip_dummynet.c
index 346c48699c7c..aa1ca0edf095 100644
--- a/sys/netpfil/ipfw/ip_dummynet.c
+++ b/sys/netpfil/ipfw/ip_dummynet.c
@@ -958,7 +958,7 @@ copy_obj(char **start, char *end, void *_o, const char *msg, int i)
struct dn_id o;
union {
struct dn_link l;
- struct dn_schk s;
+ struct dn_sch s;
} dn;
int have = end - *start;
@@ -982,10 +982,12 @@ copy_obj(char **start, char *end, void *_o, const char *msg, int i)
dn.l.delay = dn.l.delay * 1000 / hz;
memcpy(*start, &dn.l, sizeof(dn.l));
} else if (o.type == DN_SCH) {
- /* Set dn.s.sch.oid.id to the number of instances */
+ struct dn_schk *s = __containerof(_o, struct dn_schk, sch);
+
+ /* Set dn.s.oid.id to the number of instances */
memcpy(&dn.s, _o, sizeof(dn.s));
- dn.s.sch.oid.id = (dn.s.sch.flags & DN_HAVE_MASK) ?
- dn_ht_entries(dn.s.siht) : (dn.s.siht ? 1 : 0);
+ dn.s.oid.id = (dn.s.flags & DN_HAVE_MASK) ?
+ dn_ht_entries(s->siht) : (s->siht ? 1 : 0);
memcpy(*start, &dn.s, sizeof(dn.s));
} else
memcpy(*start, _o, o.len);
diff --git a/tests/sys/netpfil/common/dummynet.sh b/tests/sys/netpfil/common/dummynet.sh
index 66736fbecdb7..da37060b0954 100644
--- a/tests/sys/netpfil/common/dummynet.sh
+++ b/tests/sys/netpfil/common/dummynet.sh
@@ -118,6 +118,30 @@ pipe_cleanup()
firewall_cleanup $1
}
+pipe_show_head()
+{
+ atf_set descr 'List pipes and schedulers'
+ atf_set require.user root
+}
+
+pipe_show_body()
+{
+ fw=$1
+ firewall_init $fw
+ dummynet_init $fw
+
+ vnet_mkjail alcatraz
+
+ jexec alcatraz dnctl pipe 1 config bw 1Mbit/s
+ atf_check -s exit:0 -o match:'^00001:' jexec alcatraz dnctl pipe show
+ atf_check -s exit:0 -o match:'^00001:' jexec alcatraz dnctl sched show
+}
+
+pipe_show_cleanup()
+{
+ firewall_cleanup $1
+}
+
pipe_v6_head()
{
atf_set descr 'Basic IPv6 pipe test'
@@ -617,6 +641,9 @@ setup_tests \
pipe \
ipfw \
pf \
+ pipe_show \
+ ipfw \
+ pf \
pipe_v6 \
ipfw \
pf \