summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/busybox/busybox/CVE-2018-20679.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-core/busybox/busybox/CVE-2018-20679.patch')
-rw-r--r--meta/recipes-core/busybox/busybox/CVE-2018-20679.patch142
1 files changed, 142 insertions, 0 deletions
diff --git a/meta/recipes-core/busybox/busybox/CVE-2018-20679.patch b/meta/recipes-core/busybox/busybox/CVE-2018-20679.patch
new file mode 100644
index 0000000000..e4693768e0
--- /dev/null
+++ b/meta/recipes-core/busybox/busybox/CVE-2018-20679.patch
@@ -0,0 +1,142 @@
1From 6d3b4bb24da9a07c263f3c1acf8df85382ff562c Mon Sep 17 00:00:00 2001
2From: Denys Vlasenko <vda.linux@googlemail.com>
3Date: Mon, 17 Dec 2018 18:07:18 +0100
4Subject: [PATCH] udhcpc: check that 4-byte options are indeed 4-byte, closes
5 11506
6
7function old new delta
8udhcp_get_option32 - 27 +27
9udhcp_get_option 231 248 +17
10------------------------------------------------------------------------------
11(add/remove: 1/0 grow/shrink: 1/0 up/down: 44/0) Total: 44 bytes
12
13Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
14
15Upstream-Status: Backport
16CVE: CVE-2018-20679
17
18Affects < 1.30.0
19
20signed-off-by: Armin Kuster <akuster@mvista.com>
21
22---
23 networking/udhcp/common.c | 19 +++++++++++++++++++
24 networking/udhcp/common.h | 4 ++++
25 networking/udhcp/dhcpc.c | 6 +++---
26 networking/udhcp/dhcpd.c | 6 +++---
27 4 files changed, 29 insertions(+), 6 deletions(-)
28
29Index: busybox-1.29.3/networking/udhcp/common.c
30===================================================================
31--- busybox-1.29.3.orig/networking/udhcp/common.c
32+++ busybox-1.29.3/networking/udhcp/common.c
33@@ -270,6 +270,15 @@ uint8_t* FAST_FUNC udhcp_get_option(stru
34 goto complain; /* complain and return NULL */
35
36 if (optionptr[OPT_CODE] == code) {
37+ if (optionptr[OPT_LEN] == 0) {
38+ /* So far no valid option with length 0 known.
39+ * Having this check means that searching
40+ * for DHCP_MESSAGE_TYPE need not worry
41+ * that returned pointer might be unsafe
42+ * to dereference.
43+ */
44+ goto complain; /* complain and return NULL */
45+ }
46 log_option("option found", optionptr);
47 return optionptr + OPT_DATA;
48 }
49@@ -287,6 +296,16 @@ uint8_t* FAST_FUNC udhcp_get_option(stru
50 return NULL;
51 }
52
53+uint8_t* FAST_FUNC udhcp_get_option32(struct dhcp_packet *packet, int code)
54+{
55+ uint8_t *r = udhcp_get_option(packet, code);
56+ if (r) {
57+ if (r[-1] != 4)
58+ r = NULL;
59+ }
60+ return r;
61+}
62+
63 /* Return the position of the 'end' option (no bounds checking) */
64 int FAST_FUNC udhcp_end_option(uint8_t *optionptr)
65 {
66Index: busybox-1.29.3/networking/udhcp/common.h
67===================================================================
68--- busybox-1.29.3.orig/networking/udhcp/common.h
69+++ busybox-1.29.3/networking/udhcp/common.h
70@@ -204,6 +204,10 @@ extern const uint8_t dhcp_option_lengths
71 unsigned FAST_FUNC udhcp_option_idx(const char *name, const char *option_strings);
72
73 uint8_t *udhcp_get_option(struct dhcp_packet *packet, int code) FAST_FUNC;
74+/* Same as above + ensures that option length is 4 bytes
75+ * (returns NULL if size is different)
76+ */
77+uint8_t *udhcp_get_option32(struct dhcp_packet *packet, int code) FAST_FUNC;
78 int udhcp_end_option(uint8_t *optionptr) FAST_FUNC;
79 void udhcp_add_binary_option(struct dhcp_packet *packet, uint8_t *addopt) FAST_FUNC;
80 #if ENABLE_UDHCPC || ENABLE_UDHCPD
81Index: busybox-1.29.3/networking/udhcp/dhcpc.c
82===================================================================
83--- busybox-1.29.3.orig/networking/udhcp/dhcpc.c
84+++ busybox-1.29.3/networking/udhcp/dhcpc.c
85@@ -1694,7 +1694,7 @@ int udhcpc_main(int argc UNUSED_PARAM, c
86 * They say ISC DHCP client supports this case.
87 */
88 server_addr = 0;
89- temp = udhcp_get_option(&packet, DHCP_SERVER_ID);
90+ temp = udhcp_get_option32(&packet, DHCP_SERVER_ID);
91 if (!temp) {
92 bb_error_msg("no server ID, using 0.0.0.0");
93 } else {
94@@ -1721,7 +1721,7 @@ int udhcpc_main(int argc UNUSED_PARAM, c
95 struct in_addr temp_addr;
96 uint8_t *temp;
97
98- temp = udhcp_get_option(&packet, DHCP_LEASE_TIME);
99+ temp = udhcp_get_option32(&packet, DHCP_LEASE_TIME);
100 if (!temp) {
101 bb_error_msg("no lease time with ACK, using 1 hour lease");
102 lease_seconds = 60 * 60;
103@@ -1817,7 +1817,7 @@ int udhcpc_main(int argc UNUSED_PARAM, c
104 uint32_t svid;
105 uint8_t *temp;
106
107- temp = udhcp_get_option(&packet, DHCP_SERVER_ID);
108+ temp = udhcp_get_option32(&packet, DHCP_SERVER_ID);
109 if (!temp) {
110 non_matching_svid:
111 log1("received DHCP NAK with wrong"
112Index: busybox-1.29.3/networking/udhcp/dhcpd.c
113===================================================================
114--- busybox-1.29.3.orig/networking/udhcp/dhcpd.c
115+++ busybox-1.29.3/networking/udhcp/dhcpd.c
116@@ -640,7 +640,7 @@ static void add_server_options(struct dh
117 static uint32_t select_lease_time(struct dhcp_packet *packet)
118 {
119 uint32_t lease_time_sec = server_config.max_lease_sec;
120- uint8_t *lease_time_opt = udhcp_get_option(packet, DHCP_LEASE_TIME);
121+ uint8_t *lease_time_opt = udhcp_get_option32(packet, DHCP_LEASE_TIME);
122 if (lease_time_opt) {
123 move_from_unaligned32(lease_time_sec, lease_time_opt);
124 lease_time_sec = ntohl(lease_time_sec);
125@@ -987,7 +987,7 @@ int udhcpd_main(int argc UNUSED_PARAM, c
126 }
127
128 /* Get SERVER_ID if present */
129- server_id_opt = udhcp_get_option(&packet, DHCP_SERVER_ID);
130+ server_id_opt = udhcp_get_option32(&packet, DHCP_SERVER_ID);
131 if (server_id_opt) {
132 uint32_t server_id_network_order;
133 move_from_unaligned32(server_id_network_order, server_id_opt);
134@@ -1011,7 +1011,7 @@ int udhcpd_main(int argc UNUSED_PARAM, c
135 }
136
137 /* Get REQUESTED_IP if present */
138- requested_ip_opt = udhcp_get_option(&packet, DHCP_REQUESTED_IP);
139+ requested_ip_opt = udhcp_get_option32(&packet, DHCP_REQUESTED_IP);
140 if (requested_ip_opt) {
141 move_from_unaligned32(requested_nip, requested_ip_opt);
142 }