[PATCH 0/2] dhcp: Harden DNS search domain option handling
Lakshitha Perera reported a potential out-of-bounds write in
opt_set_dns_search() at revision f8df3f1, where an excessively long
DNS search domain list configured via --dhcp-search could overflow the
opts[119].s buffer.
The original root cause (slen initialised to -1 inflating the max_len
counter) was already eliminated by commit 64e69136ecbc ("dhcp: Add
option configuration tracking with enum opt_conf"). These two patches
address the remaining robustness concerns:
1/2: Change opts[].slen from int to unsigned int, now that negative
value is no longer used.
2/2: Add an explicit bounds check against sizeof(opts[119].s) before
the memcpy() in opt_set_dns_search().
Reported-by: Lakshitha Perera
Now that negative value (-1) is no longer used to do the
opts[].slen initialization (removed by commit 64e69136ecbc,
"dhcp: Add option configuration tracking with enum opt_conf"),
change slen from int to unsigned int. Hence, removed the
explicit (size_t) casts in comparisons.
Reported-by: Lakshitha Perera
Add an explicit check that the encoded DNS search domain data
does not exceed the capacity of opts[119].s before each memcpy()
in opt_set_dns_search().
Reported-by: Lakshitha Perera
On Tue, 17 Nov 2026 17:36:15 +0530
Anshu Kumari
Lakshitha Perera reported a potential out-of-bounds write in opt_set_dns_search() at revision f8df3f1, where an excessively long DNS search domain list configured via --dhcp-search could overflow the opts[119].s buffer.
For clarity: the original report needed a patched build to actually cause the out-of-bounds write (which was otherwise prevented), and could only be triggered via user configuration, with a particular (nonsensical) values for that option, resulting in a functional issue (clean abort on those values), nothing security relevant. -- Stefano
participants (2)
-
Anshu Kumari
-
Stefano Brivio