Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH 1/2] u-boot: fix CVE-2026-29007 and CVE-2026-29008
@ 2026-12-02  6:28 Prasanth R
  2026-12-02  6:28 ` [PATCH 2/2] u-boot-tools: ignore " Prasanth R
  0 siblings, 1 reply; 2+ messages in thread
From: Prasanth R @ 2026-12-02  6:28 UTC (permalink / raw)
  To: openembedded-core; +Cc: Fabio Estevam, Prasanth R

Backport my fixes for the legacy TCP stack from U-Boot main.

AI-Generated: Uses Claude
Signed-off-by: Prasanth R <prasanth.r@lineo.co.jp>
---
 .../u-boot/files/CVE-2026-29007.patch         | 94 +++++++++++++++++++
 .../u-boot/files/CVE-2026-29007_29008.patch   | 66 +++++++++++++
 meta/recipes-bsp/u-boot/u-boot_2026.10.bb     |  4 +
 3 files changed, 164 insertions(+)
 create mode 100644 meta/recipes-bsp/u-boot/files/CVE-2026-29007.patch
 create mode 100644 meta/recipes-bsp/u-boot/files/CVE-2026-29007_29008.patch

diff --git a/meta/recipes-bsp/u-boot/files/CVE-2026-29007.patch b/meta/recipes-bsp/u-boot/files/CVE-2026-29007.patch
new file mode 100644
index 0000000000..b58c300dd8
--- /dev/null
+++ b/meta/recipes-bsp/u-boot/files/CVE-2026-29007.patch
@@ -0,0 +1,94 @@
+From cf248526dbd1da6622b58483c307cb837fb76165 Mon Sep 17 00:00:00 2001
+From: Prasanth R <ragaprasanth@gmail.com>
+Date: Tue, 17 Nov 2026 17:56:45 +0900
+Subject: [PATCH] net: tcp: check option lengths in tcp_parse_options()
+
+tcp_parse_options() reads the length byte of an option without checking
+that it is inside the option area, and reads the window scale and
+timestamp values without checking the option length. A truncated or
+malformed option makes it read past the end of the options.
+
+Check that each option and its length byte fit in the remaining
+options, and only use the window scale and timestamp when the option
+has the expected size. Limit the window scale to 14 as RFC 7323 says,
+so the window shift in tcp_rx_state_machine() stays defined.
+
+Fixes: a3bf193bf4ea ("net: Add TCP protocol")
+
+CVE: CVE-2026-29007
+Upstream-Status: Backport [https://git.u-boot-project.org/u-boot/u-boot/-/commit/cf248526dbd1da6622b58483c307cb837fb76165]
+
+Signed-off-by: Prasanth R <prasanth.r@lineo.co.jp>
+---
+ net/tcp.c | 42 +++++++++++++++++++++++-------------------
+ 1 file changed, 23 insertions(+), 19 deletions(-)
+
+diff --git a/net/tcp.c b/net/tcp.c
+index 737a079ec5..cde3319bc4 100644
+--- a/net/tcp.c
++++ b/net/tcp.c
+@@ -776,38 +776,42 @@ void tcp_parse_options(struct tcp_stream *tcp, uchar *o, int o_len)
+ {
+ 	struct tcp_t_opt  *tsopt;
+ 	struct tcp_scale  *wsopt;
++	uchar *end = o + o_len;
+ 	uchar *p = o;
++	u8 len;
+ 
+-	/*
+-	 * NOPs are options with a zero length, and thus are special.
+-	 * All other options have length fields.
+-	 */
+-	for (p = o; p < (o + o_len); ) {
+-		if (!p[1])
+-			return; /* Finished processing options */
++	while (p < end) {
++		if (p[0] == TCP_O_END)
++			return;
++		if (p[0] == TCP_1_NOP) {
++			p++;
++			continue;
++		}
+ 
+-		switch (p[0]) {
+-		case TCP_O_END:
++		/* All other options have a length byte covering kind and len */
++		if (end - p < TCP_OPT_LEN_2)
+ 			return;
+-		case TCP_O_MSS:
+-		case TCP_P_SACK:
+-		case TCP_V_SACK:
+-			break;
++		len = p[1];
++		if (len < TCP_OPT_LEN_2 || len > end - p)
++			return;
++
++		switch (p[0]) {
+ 		case TCP_O_SCL:
++			if (len != TCP_OPT_LEN_3)
++				break;
+ 			wsopt = (struct tcp_scale *)p;
+-			tcp->rmt_win_scale = wsopt->scale;
++			/* RFC 7323: a shift count above 14 is treated as 14 */
++			tcp->rmt_win_scale = wsopt->scale > 14 ? 14 : wsopt->scale;
+ 			break;
+ 		case TCP_O_TS:
++			if (len != TCP_OPT_LEN_A)
++				break;
+ 			tsopt = (struct tcp_t_opt *)p;
+ 			tcp->rmt_timestamp = tsopt->t_snd;
+ 			break;
+ 		}
+ 
+-		/* Process optional NOPs */
+-		if (p[0] == TCP_1_NOP)
+-			p++;
+-		else
+-			p += p[1];
++		p += len;
+ 	}
+ }
+ 
+-- 
+2.43.0
+
diff --git a/meta/recipes-bsp/u-boot/files/CVE-2026-29007_29008.patch b/meta/recipes-bsp/u-boot/files/CVE-2026-29007_29008.patch
new file mode 100644
index 0000000000..90ad049c27
--- /dev/null
+++ b/meta/recipes-bsp/u-boot/files/CVE-2026-29007_29008.patch
@@ -0,0 +1,66 @@
+From a0e2935a4bdeb982e48a8f13fa257bbfc6d8e657 Mon Sep 17 00:00:00 2001
+From: Prasanth R <ragaprasanth@gmail.com>
+Date: Tue, 17 Nov 2026 17:56:44 +0900
+Subject: [PATCH] net: tcp: drop segments with an invalid data offset
+
+rxhand_tcp_f() trusts the data offset of a received segment.
+tcp_rx_state_machine() then passes tcp_hdr_len - TCP_HDR_SIZE bytes of
+options to tcp_parse_options() and computes payload_len as
+tcp_len - tcp_hdr_len, without checking that the header fits in the
+segment.
+
+A data offset larger than the segment makes tcp_parse_options() read
+past the end of the packet (CVE-2026-29007) and makes payload_len
+negative. In TCP_SYN_SENT the negative length reaches
+tcp_rx_user_data() and the receive handler, where it wraps to a huge
+memcpy() size (CVE-2026-29008).
+
+Drop segments that are shorter than a TCP header, or whose data offset
+is below the header size or beyond the segment. Also ignore the
+reserved bits when reading the data offset.
+
+Fixes: a3bf193bf4ea ("net: Add TCP protocol")
+
+CVE: CVE-2026-29007 CVE-2026-29008
+Upstream-Status: Backport [https://git.u-boot-project.org/u-boot/u-boot/-/commit/a0e2935a4bdeb982e48a8f13fa257bbfc6d8e657]
+
+Signed-off-by: Prasanth R <prasanth.r@lineo.co.jp>
+---
+ net/tcp.c | 14 +++++++++++++-
+ 1 file changed, 13 insertions(+), 1 deletion(-)
+
+diff --git a/net/tcp.c b/net/tcp.c
+index 8740150365..737a079ec5 100644
+--- a/net/tcp.c
++++ b/net/tcp.c
+@@ -58,7 +58,7 @@ static int (*tcp_stream_on_create)(struct tcp_stream *tcp);
+ #define ROUND_TCPHDR_LEN(x) (LEN_B_TO_DW((x) + 3))
+ #define ROUND_TCPHDR_BYTES(x) (((x) + 3) & ~3)
+ #define SHIFT_TO_TCPHDRLEN_FIELD(x) ((x) << 4)
+-#define GET_TCP_HDR_LEN_IN_BYTES(x) ((x) >> 2)
++#define GET_TCP_HDR_LEN_IN_BYTES(x) (((x) & 0xf0) >> 2)
+ 
+ #define RANDOM_PORT_START 1024
+ #define RANDOM_PORT_RANGE 0x4000
+@@ -1162,6 +1162,18 @@ void rxhand_tcp_f(union tcp_build_pkt *b, unsigned int pkt_len)
+ 	u16 tcp_rx_xsum = b->ip.hdr.ip_sum;
+ 	struct tcp_stream *tcp;
+ 	struct in_addr src;
++	int tcp_hdr_len;
++
++	/*
++	 * The data offset must cover the fixed TCP header and must not point
++	 * past the end of the segment. Otherwise the options parser reads
++	 * beyond the packet and the payload length becomes negative.
++	 */
++	if (tcp_len < (int)TCP_HDR_SIZE)
++		return;
++	tcp_hdr_len = GET_TCP_HDR_LEN_IN_BYTES(b->ip.hdr.tcp_hlen);
++	if (tcp_hdr_len < (int)TCP_HDR_SIZE || tcp_hdr_len > tcp_len)
++		return;
+ 
+ 	/* Verify IP header */
+ 	debug_cond(DEBUG_DEV_PKT,
+-- 
+2.43.0
+
diff --git a/meta/recipes-bsp/u-boot/u-boot_2026.10.bb b/meta/recipes-bsp/u-boot/u-boot_2026.10.bb
index eed5127004..5132a81b9b 100644
--- a/meta/recipes-bsp/u-boot/u-boot_2026.10.bb
+++ b/meta/recipes-bsp/u-boot/u-boot_2026.10.bb
@@ -3,6 +3,10 @@ require u-boot.inc
 
 DEPENDS += "bc-native dtc-native gnutls-native python3-pyelftools-native"
 
+SRC_URI += "file://CVE-2026-29007_29008.patch \
+            file://CVE-2026-29007.patch \
+"
+
 # workarounds for aarch64 kvm qemu boot regressions
 SRC_URI:append:qemuarm64 = " file://disable-CONFIG_BLOBLIST.cfg"
 SRC_URI:append:genericarm64 = " file://disable-CONFIG_BLOBLIST.cfg"
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH 2/2] u-boot-tools: ignore CVE-2026-29007 and CVE-2026-29008
  2026-12-02  6:28 [PATCH 1/2] u-boot: fix CVE-2026-29007 and CVE-2026-29008 Prasanth R
@ 2026-12-02  6:28 ` Prasanth R
  0 siblings, 0 replies; 2+ messages in thread
From: Prasanth R @ 2026-12-02  6:28 UTC (permalink / raw)
  To: openembedded-core; +Cc: Fabio Estevam, Prasanth R

tools-only_defconfig disables networking, so net/tcp.c is not built
into u-boot-tools. Same status as on wrynose.

AI-Generated: Uses Claude
Signed-off-by: Prasanth R <prasanth.r@lineo.co.jp>
---
 meta/recipes-bsp/u-boot/u-boot-tools_2026.10.bb | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/meta/recipes-bsp/u-boot/u-boot-tools_2026.10.bb b/meta/recipes-bsp/u-boot/u-boot-tools_2026.10.bb
index 9e7a178310..676d5b49f8 100644
--- a/meta/recipes-bsp/u-boot/u-boot-tools_2026.10.bb
+++ b/meta/recipes-bsp/u-boot/u-boot-tools_2026.10.bb
@@ -2,3 +2,6 @@ require u-boot-common.inc
 require u-boot-tools.inc
 
 SRC_URI += "file://0001-tools-mkeficapsule-Detect-GnuTLS-PKCS-11-support.patch"
+
+CVE_STATUS[CVE-2026-29007] = "not-applicable-config: tools-only_defconfig disables networking; net/tcp.c is not compiled into u-boot-tools."
+CVE_STATUS[CVE-2026-29008] = "not-applicable-config: tools-only_defconfig disables networking; net/tcp.c is not compiled into u-boot-tools."
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-02  6:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02  6:28 [PATCH 1/2] u-boot: fix CVE-2026-29007 and CVE-2026-29008 Prasanth R
2026-12-02  6:28 ` [PATCH 2/2] u-boot-tools: ignore " Prasanth R

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox