busybox/networking/udhcp
Russ Dill e265c8d4c0 udhcp: Avoid leaking uninitialized/stale data
I noticed a commit in connman:

"gdhcp: Avoid leaking stack data via unitiialized variable" [1]

Since gdhcp is just BusyBox udhcp with the serial numbers filed off, I
checked if BusyBox udhcp has a related issue.

The issue is that the get_option logic assumes any data within the
memory area of the buffer is "valid". This reduces the complexity of the
function at the cost of reading past the end of the actually received
data in the case of specially crafted packets. This is not a problem
for the udhcp_recv_kernel_packet data path as the entire memory
area is zeroed. However, d4/d6_recv_raw_packet does not zero the
memory.

Note that a related commit [2] is not required as we are zeroing
any data that can be read by the get_option function.

[1] https://git.kernel.org/pub/scm/network/connman/connman.git/commit/?id=a74524b3e3fad81b0fd1084ffdf9f2ea469cd9b1
[2] https://git.kernel.org/pub/scm/network/connman/connman.git/commit/?id=58d397ba74873384aee449690a9070bacd5676fa

function                                             old     new   delta
d4_recv_raw_packet                                   484     497     +13
d6_recv_raw_packet                                   216     228     +12
.rodata                                           105390  105381      -9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 25/-9)              Total: 16 bytes

Signed-off-by: Russ Dill <russ.dill@gmail.com>
Cc: Colin Wee <cwee@tesla.com>
Cc: Denys Vlasenko <vda.linux@googlemail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2023-10-04 16:46:35 +02:00
..
Config.src Update applet size estimates 2023-07-10 17:25:21 +02:00
Kbuild.src fix breakage found by mass one-applet builds 2016-12-23 02:42:26 +01:00
arpping.c udhcp: shrink arpping() 2021-06-03 11:32:40 +02:00
common.c udhcpd: optional BOOTP support 2023-06-12 13:22:47 +02:00
common.h udhcpd: optional BOOTP support 2023-06-12 13:22:47 +02:00
d6_common.h udhcpc6: add some comments 2022-12-14 00:36:59 +01:00
d6_dhcpc.c udhcp: Avoid leaking uninitialized/stale data 2023-10-04 16:46:35 +02:00
d6_packet.c udhcp: add a few comments, no code changes 2022-12-15 13:34:52 +01:00
d6_socket.c udhcpc6: fix binding to network aliases 2022-12-15 23:57:27 +01:00
dhcpc.c udhcp: Avoid leaking uninitialized/stale data 2023-10-04 16:46:35 +02:00
dhcpc.h udhcpc[6]: do not pass xid around, keep it in client_data.xid 2021-06-15 01:06:42 +02:00
dhcpd.c udhcpd: optional BOOTP support 2023-06-12 13:22:47 +02:00
dhcpd.h udhcp: rename server_config to server_data 2019-05-30 16:23:34 +02:00
dhcprelay.c dhcprelay: change two more variables to unsigned 2021-09-02 17:09:12 +02:00
domain_codec.c domain_codec: optimize dname_dec and convert_dname 2020-07-12 21:19:13 +02:00
dumpleases.c libbb: introduce and use fputs_stdout 2021-02-03 20:52:40 +01:00
packet.c udhcpd: optional BOOTP support 2023-06-12 13:22:47 +02:00
signalpipe.c fix gcc-11.0 warnings 2021-04-14 17:52:18 +02:00
socket.c udhcpc[6]: remove superfluous "created raw socket" log message 2021-06-02 20:23:43 +02:00