Skip to contentSkip to conversation

Add test for CVE 2026-53362

PATCH Applied Martin Doucha 4 participants 8 messages Jul 21 – Jul 31

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add test for CVE 2026-53362

Add test for memory corruption due to miscalculation of socket buffer size for fragmented packets with gaps.

---

Bug reproducibility verified on affected kernels v6.4 and v6.12.

 runtest/cve                                   |   1 +
 runtest/syscalls                              |   1 +
 .../kernel/syscalls/setsockopt/.gitignore     |   1 +
 .../kernel/syscalls/setsockopt/setsockopt11.c | 171 ++++++++++++++++++
 4 files changed, 174 insertions(+)
 create mode 100644 testcases/kernel/syscalls/setsockopt/setsockopt11.c
runtest/cve +1 -0
index 3bbcfd6a2..99d84270b 100644
@@ -88,6 +88,7 @@ cve-2023-1829 tcindex01
 cve-2023-0461 setsockopt10
 cve-2023-31248 nft02
 cve-2023-52879 fanotify25
+cve-2026-53362 setsockopt11
 # Tests below may cause kernel memory leak
 cve-2020-25704 perf_event_open03
 cve-2022-0185 fsconfig03
runtest/syscalls +1 -0
index c84c32a6f..949ad7622 100644
@@ -1524,6 +1524,7 @@ setsockopt07 setsockopt07
 setsockopt08 setsockopt08
 setsockopt09 setsockopt09
 setsockopt10 setsockopt10
+setsockopt11 setsockopt11
 
 settimeofday01 settimeofday01
 settimeofday02 settimeofday02
testcases/kernel/syscalls/setsockopt/.gitignore +1 -0
index 5c05290a5..58cc82d9c 100644
@@ -8,3 +8,4 @@
 /setsockopt08
 /setsockopt09
 /setsockopt10
+/setsockopt11
testcases/kernel/syscalls/setsockopt/setsockopt11.c new file +171 -0

171 lines not on this page · raw message

Signature · 5 lines
2.54.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Hi Martin,

Quoted 12 lines · Martin Doucha

Add test for CVE 2026-53362

+/*
+ * CVE 2026-53362
+ *
+ * Test for vulnerability in socket buffer size calculation for fragmented
+ * UDP packets with gaps. Reproducer based on:
+ * https://github.com/sgkdev/ipv6_frag_escape
+ *
+ * Memory corruption fixed in kernel v7.2:
+ * 736b380e28d0 ("ipv6: account for fraggap on the paged allocation path")
+ */

This high-level description block opens with a plain /* instead of /*\. setsockopt10.c (and the rest of the test suite) uses /*\ for this block, since it gets exported into the RST-based test catalog.

As written, this stays a regular comment and will not show up in the generated documentation. Could this be changed to /*\?

testcases/kernel/syscalls/setsockopt/setsockopt11.c line 102

Quoted 7 lines
testcases/kernel/syscalls/setsockopt/setsockopt11.c new file +7 -0
+	/* Splice input pipe buffer page into socket */
+	memset(buf, 0, TEST_MSGSIZE);
+	buf[TEST_MSGSIZE - 6] = 1;
+	SAFE_WRITE(SAFE_WRITE_ALL, pipefds[1][1], buf, TEST_MSGSIZE);
+	splice(pipefds[1][0], NULL, sockfd, NULL, TEST_MSGSIZE, SPLICE_F_MORE);
+	tee(pipefds[0][0], pipefds[1][1], PATTERN_SIZE, 0);
+	splice(pipefds[1][0], NULL, sockfd, NULL, PATTERN_SIZE, SPLICE_F_MORE);

The file already includes "lapi/splice.h", which provides SAFE_SPLICE(). Both splice() calls here use the bare syscall instead, so their return value is discarded. If either call fails or returns short, the reproduction sequence silently doesn't happen and the iteration would just report TPASS without having exercised anything. Would SAFE_SPLICE() be preferable here?

testcases/kernel/syscalls/setsockopt/setsockopt11.c line 112

Quoted 4 lines
testcases/kernel/syscalls/setsockopt/setsockopt11.c new file +4 -0
+	for (i = 0; i < PIPE_COUNT; i++) {
+		SAFE_CLOSE(pipefds[i][0]);
+		SAFE_CLOSE(pipefds[i][1]);
+	}

pipefds[][] (and sockfd, closed a few lines above) are not reset to -1 after being closed here; only setup() initializes them to -1, once. cleanup() decides whether a descriptor needs closing with a >= 0 check.

Since leak_pipe() runs in a loop (up to 64 times), if SAFE_PIPE() or SAFE_SOCKET() at the start of a later iteration fails (pipe(2)/ socket(2) can fail with EMFILE/ENFILE/ENOMEM) before refreshing a given slot, cleanup() would see the stale, already-closed descriptor number from the previous iteration as still open and try to close it again. Would it make sense to reset the relevant slot to -1 right after each close?

Verdict - Needs revision

---
Note:

The agent can sometimes produce false positives although often its findings are genuine. If you find issues with the review, please comment this email or ignore the suggestions.

Regards,
LTP AI Reviewer

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw

Hi Martin,

Quoted 6 lines

This high-level description block opens with a plain /* instead of /*\. setsockopt10.c (and the rest of the test suite) uses /*\ for this block, since it gets exported into the RST-based test catalog.

As written, this stays a regular comment and will not show up in the generated documentation. Could this be changed to /*\?

This is correct.

Quoted 15 lines

testcases/kernel/syscalls/setsockopt/setsockopt11.c line 102

Quoted 8 lines
testcases/kernel/syscalls/setsockopt/setsockopt11.c new file +7 -0
+	/* Splice input pipe buffer page into socket */
+	memset(buf, 0, TEST_MSGSIZE);
+	buf[TEST_MSGSIZE - 6] = 1;
+	SAFE_WRITE(SAFE_WRITE_ALL, pipefds[1][1], buf, TEST_MSGSIZE);
+	splice(pipefds[1][0], NULL, sockfd, NULL, TEST_MSGSIZE, SPLICE_F_MORE);
+	tee(pipefds[0][0], pipefds[1][1], PATTERN_SIZE, 0);
+	splice(pipefds[1][0], NULL, sockfd, NULL, PATTERN_SIZE, SPLICE_F_MORE);

The file already includes "lapi/splice.h", which provides SAFE_SPLICE(). Both splice() calls here use the bare syscall instead, so their return value is discarded. If either call fails or returns short, the reproduction sequence silently doesn't happen and the iteration would just report TPASS without having exercised anything. Would SAFE_SPLICE() be preferable here?

mmmh is this the case where splice() is supposed to fail but triggering the CVE into the kernel? if so, we probably need to add a short comment so we know that SAFE_SPLICE() is not a good choice.

Quoted 11 lines

testcases/kernel/syscalls/setsockopt/setsockopt11.c line 112

Quoted 5 lines
testcases/kernel/syscalls/setsockopt/setsockopt11.c new file +4 -0
+	for (i = 0; i < PIPE_COUNT; i++) {
+		SAFE_CLOSE(pipefds[i][0]);
+		SAFE_CLOSE(pipefds[i][1]);
+	}

pipefds[][] (and sockfd, closed a few lines above) are not reset to -1 after being closed here; only setup() initializes them to -1, once. cleanup() decides whether a descriptor needs closing with a >= 0 check.

Quoted 7 lines

Since leak_pipe() runs in a loop (up to 64 times), if SAFE_PIPE() or SAFE_SOCKET() at the start of a later iteration fails (pipe(2)/ socket(2) can fail with EMFILE/ENFILE/ENOMEM) before refreshing a given slot, cleanup() would see the stale, already-closed descriptor number from the previous iteration as still open and try to close it again. Would it make sense to reset the relevant slot to -1 right after each close?

Again, I updated the agent but it's still asking for this. Please ignore it, I will need to update the agent in a proper way. There's probably some logic flaw in the rules at the moment.

Thanks,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#3 lore raw
Quoted 15 lines · Andrea Cervesato
Quoted 6 lines
Quoted 6 lines
testcases/kernel/syscalls/setsockopt/setsockopt11.c new file +6 -0
+	/* Splice input pipe buffer page into socket */
+	memset(buf, 0, TEST_MSGSIZE);
+	buf[TEST_MSGSIZE - 6] = 1;
+	SAFE_WRITE(SAFE_WRITE_ALL, pipefds[1][1], buf, TEST_MSGSIZE);
+	splice(pipefds[1][0], NULL, sockfd, NULL, TEST_MSGSIZE, SPLICE_F_MORE);
+	tee(pipefds[0][0], pipefds[1][1], PATTERN_SIZE, 0);
Quoted 8 lines

testcases/kernel/syscalls/setsockopt/setsockopt11.c line 102

Quoted 1 line
testcases/kernel/syscalls/setsockopt/setsockopt11.c new file +1 -0
+	splice(pipefds[1][0], NULL, sockfd, NULL, PATTERN_SIZE, SPLICE_F_MORE);

The file already includes "lapi/splice.h", which provides SAFE_SPLICE(). Both splice() calls here use the bare syscall instead, so their return value is discarded. If either call fails or returns short, the reproduction sequence silently doesn't happen and the iteration would just report TPASS without having exercised anything. Would SAFE_SPLICE() be preferable here?

Quoted 3 lines

mmmh is this the case where splice() is supposed to fail but triggering the CVE into the kernel? if so, we probably need to add a short comment so we know that SAFE_SPLICE() is not a good choice.

Both splice() calls are supposed to succeed but it doesn't really matter if they fail a few times during the test run. Yes, if they fail all the time, the bug will not get triggered. So if you want to be extra careful, feel free to change the splice()s to SAFE_SPLICE() during merge.

Signature · 10 lines
Martin Doucha   [email protected]
SW Quality Engineer
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#4 lore raw
In reply to Martin Doucha
Quoted 60 lines

Add test for memory corruption due to miscalculation of socket buffer size for fragmented packets with gaps.

---

Bug reproducibility verified on affected kernels v6.4 and v6.12.

 runtest/cve                                   |   1 +
 runtest/syscalls                              |   1 +
 .../kernel/syscalls/setsockopt/.gitignore     |   1 +
 .../kernel/syscalls/setsockopt/setsockopt11.c | 171 ++++++++++++++++++
 4 files changed, 174 insertions(+)
 create mode 100644 testcases/kernel/syscalls/setsockopt/setsockopt11.c
runtest/cve +1 -0
index 3bbcfd6a2..99d84270b 100644
@@ -88,6 +88,7 @@ cve-2023-1829 tcindex01
 cve-2023-0461 setsockopt10
 cve-2023-31248 nft02
 cve-2023-52879 fanotify25
+cve-2026-53362 setsockopt11
 # Tests below may cause kernel memory leak
 cve-2020-25704 perf_event_open03
 cve-2022-0185 fsconfig03
runtest/syscalls +1 -0
index c84c32a6f..949ad7622 100644
@@ -1524,6 +1524,7 @@ setsockopt07 setsockopt07
 setsockopt08 setsockopt08
 setsockopt09 setsockopt09
 setsockopt10 setsockopt10
+setsockopt11 setsockopt11
 
 settimeofday01 settimeofday01
 settimeofday02 settimeofday02
testcases/kernel/syscalls/setsockopt/.gitignore +1 -0
index 5c05290a5..58cc82d9c 100644
@@ -8,3 +8,4 @@
 /setsockopt08
 /setsockopt09
 /setsockopt10
+/setsockopt11
testcases/kernel/syscalls/setsockopt/setsockopt11.c new file +6 -0
new file mode 100644
index 000000000..5f09291b3
@@ -0,0 +1,171 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2026 SUSE LLC
+ * Original reproducer by Massimiliano Oldani
+ * Simplified LTP port: Martin Doucha <[email protected]>
+ */

testcases/kernel/syscalls/setsockopt/setsockopt11.c line 16

Quoted 10 lines
testcases/kernel/syscalls/setsockopt/setsockopt11.c new file +10 -0
+
+/*
+ * CVE 2026-53362
+ *
+ * Test for vulnerability in socket buffer size calculation for fragmented
+ * UDP packets with gaps. Reproducer based on:
+ * https://github.com/sgkdev/ipv6_frag_escape
+ *
+ * Memory corruption fixed in kernel v7.2:
+ * 736b380e28d0 ("ipv6: account for fraggap on the paged allocation path")

We can add an Algorithm section to make the test easier to read.

* [Algorithm]
*
* - Fill pipe[0] with a known pattern (0x42) ("canary" page).
* - Splice pages into a corked socket so the skb references pipe[0]'s page.
* - Close the socket -> the corruption causes the page refcount to drop
* too low -> the page appears free while pipe[0] still owns it.
* - Pollute all free memory with 0xBD (inverse of 0x42).
* - Read pipe[0] back. If any byte changed, the page was reallocated
* while the pipe still held it -> the bug is confirmed.

testcases/kernel/syscalls/setsockopt/setsockopt11.c line 100

Quoted 5 lines
testcases/kernel/syscalls/setsockopt/setsockopt11.c new file +5 -0
+	/* Splice input pipe buffer page into socket */
+	memset(buf, 0, TEST_MSGSIZE);
+	buf[TEST_MSGSIZE - 6] = 1;
+	SAFE_WRITE(SAFE_WRITE_ALL, pipefds[1][1], buf, TEST_MSGSIZE);
+	splice(pipefds[1][0], NULL, sockfd, NULL, TEST_MSGSIZE, SPLICE_F_MORE);

SAFE_SPLICE() here.

testcases/kernel/syscalls/setsockopt/setsockopt11.c line 149

Quoted 6 lines
testcases/kernel/syscalls/setsockopt/setsockopt11.c new file +6 -0
+static void cleanup(void)
+{
+	int i;
+
+	for (i = 0; i < PIPE_COUNT; i++) {
+		if (pipefds[i][0] >= 0) {

This should be != -1 according to static definition and the SAFE_CLOSE() bahavior in the test (it sets to -1).

testcases/kernel/syscalls/setsockopt/setsockopt11.c line 155

Quoted 6 lines
testcases/kernel/syscalls/setsockopt/setsockopt11.c new file +6 -0
+			SAFE_CLOSE(pipefds[i][0]);
+			SAFE_CLOSE(pipefds[i][1]);
+		}
+	}
+
+	if (sockfd >= 0)

And here as well.

The rest looks good to me.

--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#6 lore raw

Hi Andrea, Martin,

Quoted 3 lines

Merged, Thanks!

With suggested changes

FYI Andrea by accident added unrelated testcases/cve/cve-2026-43499.md and testcases/cve/refluxfs (binary file!) which obviously weren't part of Martin's patch [1]. I removed that in 2a002a2c7b [2].

Kind regards,
Petr

[1] https://lore.kernel.org/ltp/[email protected]/
[2] https://github.com/linux-test-project/ltp/commit/2a002a2c7b0a5433f22d2684c50a60ed12ccff70

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#7 lore raw

Hi Petr,

Quoted 3 lines

FYI Andrea by accident added unrelated testcases/cve/cve-2026-43499.md and testcases/cve/refluxfs (binary file!) which obviously weren't part of Martin's patch [1]. I removed that in 2a002a2c7b [2].

I'm sorry for that...that was clearly a git add . mistake. Will be more careful with this. Thanks for fixing it.

Regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp