Skip to contentSkip to conversation

KMSAN: uninit-value in mptcp_established_options

syzbot In review syzbot 5 participants 22 messages May 1 – May 29

Subsystems (4)
lore
Share & tools
lore

syzbot

author syzbot
#0 lore raw

Hello,

syzbot found the following issue on:

HEAD commit:    08d0d3466664 Merge tag 'net-7.1-rc2' of git://git.kernel.o..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=15f6976c580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=1c3f61154f3bb7e5
dashboard link: https://syzkaller.appspot.com/bug?extid=ff020673c5e3d94d9478
compiler:       Debian clang version 21.1.8 (++20251221033036+2078da43e25a-1~exp1~20251221153213.50), Debian LLD 21.1.8
userspace arch: i386

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/8688db3eb9ae/disk-08d0d346.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/72c570681077/vmlinux-08d0d346.xz
kernel image: https://storage.googleapis.com/syzbot-assets/21669c9bddcd/bzImage-08d0d346.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:

Reported-by [email protected]

=====================================================

BUG: KMSAN: uninit-value in mptcp_write_data_fin net/mptcp/options.c:542 [inline]
BUG: KMSAN: uninit-value in mptcp_established_options_dss net/mptcp/options.c:590 [inline]
BUG: KMSAN: uninit-value in mptcp_established_options+0x112f/0x3530 net/mptcp/options.c:874
 mptcp_write_data_fin net/mptcp/options.c:542 [inline]
 mptcp_established_options_dss net/mptcp/options.c:590 [inline]
 mptcp_established_options+0x112f/0x3530 net/mptcp/options.c:874
 tcp_established_options+0x312/0xcc0 net/ipv4/tcp_output.c:1192
 __tcp_transmit_skb+0x5dc/0x5fe0 net/ipv4/tcp_output.c:1575
 __tcp_send_ack+0x967/0xad0 net/ipv4/tcp_output.c:4499
 tcp_send_ack+0x3d/0x60 net/ipv4/tcp_output.c:4505
 mptcp_subflow_shutdown+0x164/0x690 net/mptcp/protocol.c:3137
 mptcp_check_send_data_fin+0x31b/0x3d0 net/mptcp/protocol.c:3218
 __mptcp_wr_shutdown net/mptcp/protocol.c:3234 [inline]
 __mptcp_close+0x860/0x1360 net/mptcp/protocol.c:3313
 mptcp_close+0x42/0x260 net/mptcp/protocol.c:3367
 inet_release+0x1ee/0x2a0 net/ipv4/af_inet.c:442
 __sock_release net/socket.c:722 [inline]
 sock_close+0xd6/0x2f0 net/socket.c:1514
 __fput+0x60e/0x1010 fs/file_table.c:510
 ____fput+0x25/0x30 fs/file_table.c:538
 task_work_run+0x208/0x2b0 kernel/task_work.c:233
 resume_user_mode_work include/linux/resume_user_mode.h:50 [inline]
 __exit_to_user_mode_loop kernel/entry/common.c:67 [inline]
 exit_to_user_mode_loop+0x306/0x1b60 kernel/entry/common.c:98
 __exit_to_user_mode_prepare include/linux/irq-entry-common.h:207 [inline]
 syscall_exit_to_user_mode_prepare include/linux/irq-entry-common.h:238 [inline]
 syscall_exit_to_user_mode include/linux/entry-common.h:318 [inline]
 __do_fast_syscall_32+0x2c7/0x460 arch/x86/entry/syscall_32.c:310
 do_fast_syscall_32+0x37/0x80 arch/x86/entry/syscall_32.c:332
 do_SYSENTER_32+0x1f/0x30 arch/x86/entry/syscall_32.c:370
 entry_SYSENTER_compat_after_hwframe+0x84/0x8e

Local variable opts created at:

 __tcp_transmit_skb+0x4d/0x5fe0 net/ipv4/tcp_output.c:1536
 __tcp_send_ack+0x967/0xad0 net/ipv4/tcp_output.c:4499

CPU: 0 UID: 0 PID: 24584 Comm: syz.4.6812 Tainted: G        W           syzkaller #0 PREEMPT(full) 
Tainted: [W]=WARN
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/18/2026
=====================================================

---
This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at [email protected].

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

author syzbot
#1 lore raw
syzbot has found a reproducer for the following issue on:

syzbot has found a reproducer for the following issue on:

HEAD commit:    66edb901bf87 Merge tag 'v7.1-p3' of git://git.kernel.org/p..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=1086da36580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=1c3f61154f3bb7e5
dashboard link: https://syzkaller.appspot.com/bug?extid=ff020673c5e3d94d9478
compiler:       Debian clang version 21.1.8 (++20251221033036+2078da43e25a-1~exp1~20251221153213.50), Debian LLD 21.1.8
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=1260fece580000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/9014c04fc561/disk-66edb901.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/a96b1e11a924/vmlinux-66edb901.xz
kernel image: https://storage.googleapis.com/syzbot-assets/680236de6331/bzImage-66edb901.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:

Reported-by [email protected]

=====================================================

BUG: KMSAN: uninit-value in mptcp_write_data_fin net/mptcp/options.c:542 [inline]
BUG: KMSAN: uninit-value in mptcp_established_options_dss net/mptcp/options.c:590 [inline]
BUG: KMSAN: uninit-value in mptcp_established_options+0x112f/0x3530 net/mptcp/options.c:874
 mptcp_write_data_fin net/mptcp/options.c:542 [inline]
 mptcp_established_options_dss net/mptcp/options.c:590 [inline]
 mptcp_established_options+0x112f/0x3530 net/mptcp/options.c:874
 tcp_established_options+0x312/0xcc0 net/ipv4/tcp_output.c:1192
 __tcp_transmit_skb+0x5dc/0x5fe0 net/ipv4/tcp_output.c:1575
 __tcp_send_ack+0x967/0xad0 net/ipv4/tcp_output.c:4499
 tcp_send_ack+0x3d/0x60 net/ipv4/tcp_output.c:4505
 mptcp_subflow_shutdown+0x164/0x690 net/mptcp/protocol.c:3137
 mptcp_check_send_data_fin+0x31b/0x3d0 net/mptcp/protocol.c:3218
 __mptcp_wr_shutdown net/mptcp/protocol.c:3234 [inline]
 __mptcp_close+0x860/0x1360 net/mptcp/protocol.c:3313
 mptcp_close+0x42/0x260 net/mptcp/protocol.c:3367
 inet_release+0x1ee/0x2a0 net/ipv4/af_inet.c:442
 __sock_release net/socket.c:722 [inline]
 sock_close+0xd6/0x2f0 net/socket.c:1514
 __fput+0x60e/0x1010 fs/file_table.c:510
 ____fput+0x25/0x30 fs/file_table.c:538
 task_work_run+0x208/0x2b0 kernel/task_work.c:233
 resume_user_mode_work include/linux/resume_user_mode.h:50 [inline]
 __exit_to_user_mode_loop kernel/entry/common.c:67 [inline]
 exit_to_user_mode_loop+0x306/0x1b60 kernel/entry/common.c:98
 __exit_to_user_mode_prepare include/linux/irq-entry-common.h:207 [inline]
 syscall_exit_to_user_mode_prepare include/linux/irq-entry-common.h:238 [inline]
 syscall_exit_to_user_mode include/linux/entry-common.h:318 [inline]
 do_syscall_64+0x236/0xf80 arch/x86/entry/syscall_64.c:100
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Local variable opts created at:

 __tcp_transmit_skb+0x4d/0x5fe0 net/ipv4/tcp_output.c:1536
 __tcp_send_ack+0x967/0xad0 net/ipv4/tcp_output.c:4499

CPU: 0 UID: 0 PID: 5905 Comm: syz.0.17 Not tainted syzkaller #0 PREEMPT(full) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/18/2026
=====================================================

---
If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

author syzbot
#2 lore raw

Forwarded: [PATCH] mptcp: zero opts->ext_copy on DATA_FIN-only path

In reply to syzbot
For archival purposes, forwarding an incoming command email to [email protected], [email protected].

For archival purposes, forwarding an incoming command email to [email protected], [email protected].

***

Subject: [PATCH] mptcp: zero opts->ext_copy on DATA_FIN-only path
Author: [email protected]

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

syzbot reported a KMSAN uninit-value in mptcp_write_data_fin() when sending a DATA_FIN on a pure-ACK path triggered by subflow shutdown:

  BUG: KMSAN: uninit-value in mptcp_write_data_fin net/mptcp/options.c:542
   mptcp_established_options_dss net/mptcp/options.c:590
   mptcp_established_options net/mptcp/options.c:874
   tcp_established_options net/ipv4/tcp_output.c:1192
   __tcp_transmit_skb net/ipv4/tcp_output.c:1575
   __tcp_send_ack net/ipv4/tcp_output.c:4499
   tcp_send_ack net/ipv4/tcp_output.c:4505
   mptcp_subflow_shutdown net/mptcp/protocol.c:3137
   mptcp_check_send_data_fin net/mptcp/protocol.c:3218
   __mptcp_close net/mptcp/protocol.c:3313

Local variable opts created at:
__tcp_transmit_skb net/ipv4/tcp_output.c:1536

mptcp_established_options_dss() copies an existing DSS mapping into opts->ext_copy only when the skb has an MPTCP extension attached:

	if (mpext) {
		...
		opts->ext_copy = *mpext;
	}

When called via tcp_send_ack() from the subflow shutdown path, the skb is a freshly allocated pure-ACK with no MPTCP extension, so mptcp_get_ext(skb) returns NULL and the assignment is skipped. mptcp_established_options_dss() still proceeds to call mptcp_write_data_fin(... &opts->ext_copy) when snd_data_fin_enable is set, and mptcp_write_data_fin() reads ext->use_map to decide whether to synthesize a 1-byte DATA_FIN mapping. opts is a stack local in __tcp_transmit_skb() and opts->mptcp is not part of the cleared sub-group, so ext_copy is uninitialized on this path.

Zero opts->ext_copy at the start of the DSS mapping block so the synthetic-mapping branch in mptcp_write_data_fin() runs on clean memory regardless of whether mpext is present.

---
 net/mptcp/options.c | 2 ++
 1 file changed, 2 insertions(+)
net/mptcp/options.c +2 -0
index 8a1c5698983c..6707f70024f2 100644
@@ -578,6 +578,8 @@ static bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb,
 	if (!skb || (mpext && mpext->use_map) || snd_data_fin_enable) {
 		unsigned int map_size = TCPOLEN_MPTCP_DSS_BASE + TCPOLEN_MPTCP_DSS_MAP64;
 
+		memset(&opts->ext_copy, 0, sizeof(opts->ext_copy));
+
 		if (mpext) {
 			if (opts->csum_reqd)
 				map_size += TCPOLEN_MPTCP_DSS_CHECKSUM;
Signature · 1 line
2.43.0
author syzbot
#3 lore raw

Forwarded: [PATCH] mptcp: zero opts->ext_copy in mptcp_established_options_dss()

In reply to syzbot
For archival purposes, forwarding an incoming command email to [email protected], [email protected].

For archival purposes, forwarding an incoming command email to [email protected], [email protected].

***

Subject: [PATCH] mptcp: zero opts->ext_copy in mptcp_established_options_dss()
Author: [email protected]

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

syzbot reported two related KMSAN uninit-value reports rooted in mptcp_established_options_dss():

1. mptcp_write_data_fin() reads ext->use_map on the subflow shutdown path (tcp_send_ack via mptcp_subflow_shutdown), where the skb has no MPTCP extension and the "opts->ext_copy = *mpext" assignment is skipped.

2. mptcp_write_options() reads mpext->use_ack on the data_fin acknowledgement path (tcp_send_ack via mptcp_send_ack from mptcp_check_data_fin), where the outer DSS-mapping block is skipped entirely (snd_data_fin_enable is false and mpext is NULL), yet bitfield RMW writes to opts->ext_copy.use_ack / .ack64 leave neighboring bits poisoned, which mptcp_write_options() then reads.

The root cause is the same in both cases: opts->ext_copy lives in a union inside opts->mptcp, which is a plain (non-cleared) member of the on-stack struct tcp_out_options declared in __tcp_transmit_skb(). Multiple code paths in mptcp_established_options_dss() write only some fields of ext_copy and rely on the rest being zero, but that precondition is never enforced.

Zero opts->ext_copy at the start of mptcp_established_options_dss() so all subsequent writes -- including bitfield RMWs -- operate on clean memory regardless of which path is taken.

---
 net/mptcp/options.c | 1 +
 1 file changed, 1 insertion(+)
net/mptcp/options.c +1 -0
index 8a1c5698983c..3fb914196987 100644
@@ -572,6 +572,7 @@ static bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb,
 	bool ret = false;
 	u64 ack_seq;
 
+	memset(&opts->ext_copy, 0, sizeof(opts->ext_copy));
 	opts->csum_reqd = READ_ONCE(msk->csum_enabled);
 	mpext = skb ? mptcp_get_ext(skb) : NULL;
 
Signature · 1 line
2.43.0
#4 lore raw

PATCH 1/1 mptcp: fix KMSAN: uninit-value in mptcp_established_options

In reply to syzbot

Just to let syzbot testing it.

See Paolo's suggestion from [1].

Fixes cfcceb7a39fc ("tcp: shrink per-packet memset in __tcp_transmit_skb()")
Reported-by [email protected]

---
Cc: Kuniyuki Iwashima <[email protected]>
Cc: [email protected]
Cc: [email protected]

---
 net/mptcp/options.c | 2 ++
 1 file changed, 2 insertions(+)
net/mptcp/options.c +2 -0
index 8a1c5698983c..24903a12a4e0 100644
@@ -583,6 +583,8 @@ static bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb,
 				map_size += TCPOLEN_MPTCP_DSS_CHECKSUM;
 
 			opts->ext_copy = *mpext;
+		} else {
+			opts->ext_copy.use_map = 0;
 		}
 
 		dss_size = map_size;
Signature · 1 line
2.53.0
maintainer
#5 lore raw

Re: [PATCH] mptcp: fix KMSAN: uninit-value in mptcp_established_options

Hello,

Quoted 1 line · On 04/05/2026 11:51, Matthieu Baerts (NGI0) wrote:

Just to let syzbot testing it.

Sorry for the noise: I forgot to add the syzbot instruction... (and I forgot to remove the MPTCP ML from the sendmail.to option).

Hopefully now the following is correct:
#syz test

net/mptcp/options.c +2 -0
index 8a1c5698983c..24903a12a4e0 100644
@@ -583,6 +583,8 @@ static bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb,
 				map_size += TCPOLEN_MPTCP_DSS_CHECKSUM;
 
 			opts->ext_copy = *mpext;
+		} else {
+			opts->ext_copy.use_map = 0;
 		}
 
 		dss_size = map_size;
#21 lore raw

Re: [PATCH] mptcp: fix KMSAN: uninit-value in mptcp_established_options

In reply to Matthieu Baerts (NGI0)

Hi Matthieu,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

- KVM Validation: normal (except selftest_mptcp_join): Success! ✅
- KVM Validation: normal (only selftest_mptcp_join): Success! ✅
- KVM Validation: debug (except selftest_mptcp_join): Unstable: 1 failed test(s): packetdrill_dss ⚠️
- KVM Validation: debug (only selftest_mptcp_join): Success! ✅
- KVM Validation: btf-normal (only bpftest_all): Success! ✅
- KVM Validation: btf-debug (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/25313209741

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/f5d0fa2e42ba
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=1089187

If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:

    $ cd [kernel source code]
    $ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
        --pull always mptcp/mptcp-upstream-virtme-docker:latest \
        auto-normal

For more details:

https://github.com/multipath-tcp/mptcp-upstream-virtme-docker

Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)

Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)

author syzbot
#6 lore raw
In reply to Matthieu Baerts
syzbot has tested the proposed patch but the reproducer is still triggering an issue: KMSAN: uninit-value in mptcp_write_options

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KMSAN: uninit-value in mptcp_write_options

=====================================================

BUG: KMSAN: uninit-value in mptcp_write_options+0x410/0x32e0 net/mptcp/options.c:1462
 mptcp_write_options+0x410/0x32e0 net/mptcp/options.c:1462
 mptcp_options_write net/ipv4/tcp_output.c:457 [inline]
 tcp_options_write+0x1399/0x1920 net/ipv4/tcp_output.c:833
 __tcp_transmit_skb+0x36fe/0x5fe0 net/ipv4/tcp_output.c:1656
 __tcp_send_ack+0x967/0xad0 net/ipv4/tcp_output.c:4499
 tcp_send_ack+0x3d/0x60 net/ipv4/tcp_output.c:4505
 __mptcp_subflow_send_ack net/mptcp/protocol.c:538 [inline]
 mptcp_subflow_send_ack net/mptcp/protocol.c:546 [inline]
 mptcp_send_ack net/mptcp/protocol.c:555 [inline]
 mptcp_check_data_fin+0xa61/0xf00 net/mptcp/protocol.c:643
 mptcp_worker+0xde4/0x1ea0 net/mptcp/protocol.c:2980
 process_one_work kernel/workqueue.c:3302 [inline]
 process_scheduled_works+0xb65/0x1e40 kernel/workqueue.c:3385
 worker_thread+0xee4/0x1590 kernel/workqueue.c:3466
 kthread+0x53f/0x600 kernel/kthread.c:436
 ret_from_fork+0x20f/0x8d0 arch/x86/kernel/process.c:158
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245

Uninit was stored to memory at:

 mptcp_established_options_dss net/mptcp/options.c:616 [inline]
 mptcp_established_options+0x2265/0x3580 net/mptcp/options.c:876
 tcp_established_options+0x312/0xcc0 net/ipv4/tcp_output.c:1192
 __tcp_transmit_skb+0x5dc/0x5fe0 net/ipv4/tcp_output.c:1575
 __tcp_send_ack+0x967/0xad0 net/ipv4/tcp_output.c:4499
 tcp_send_ack+0x3d/0x60 net/ipv4/tcp_output.c:4505
 __mptcp_subflow_send_ack net/mptcp/protocol.c:538 [inline]
 mptcp_subflow_send_ack net/mptcp/protocol.c:546 [inline]
 mptcp_send_ack net/mptcp/protocol.c:555 [inline]
 mptcp_check_data_fin+0xa61/0xf00 net/mptcp/protocol.c:643
 mptcp_worker+0xde4/0x1ea0 net/mptcp/protocol.c:2980
 process_one_work kernel/workqueue.c:3302 [inline]
 process_scheduled_works+0xb65/0x1e40 kernel/workqueue.c:3385
 worker_thread+0xee4/0x1590 kernel/workqueue.c:3466
 kthread+0x53f/0x600 kernel/kthread.c:436
 ret_from_fork+0x20f/0x8d0 arch/x86/kernel/process.c:158
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245

Local variable opts created at:

 __tcp_transmit_skb+0x4d/0x5fe0 net/ipv4/tcp_output.c:1536
 __tcp_send_ack+0x967/0xad0 net/ipv4/tcp_output.c:4499

CPU: 0 UID: 0 PID: 4890 Comm: kworker/0:2 Not tainted syzkaller #0 PREEMPT(full) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/18/2026
Workqueue: events mptcp_worker
=====================================================

Tested on:

commit:         6d35786d Merge tag 'for-linus' of git://git.kernel.org..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=123d6696580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=1c3f61154f3bb7e5
dashboard link: https://syzkaller.appspot.com/bug?extid=ff020673c5e3d94d9478
compiler:       Debian clang version 21.1.8 (++20251221033036+2078da43e25a-1~exp1~20251221153213.50), Debian LLD 21.1.8
patch:          https://syzkaller.appspot.com/x/patch.diff?x=1663f21f980000
maintainer
#7 lore raw

Re: [PATCH] mptcp: fix KMSAN: uninit-value in mptcp_established_options

In reply to Matthieu Baerts
Quoted 3 lines · Matthieu Baerts

Sorry for the noise: I forgot to add the syzbot instruction... (and I forgot to remove the MPTCP ML from the sendmail.to option).

I did not take in account all the possible corner cases.

Let's be a little more conservative.

#syz test
---

include/net/mptcp.h +5 -0
index f7263fe2a2e4..0763fd6f7758 100644
@@ -27,6 +27,9 @@ struct mptcp_ext {
 	u32		subflow_seq;
 	u16		data_len;
 	__sum16		csum;
+
+	struct_group(flags,
+
 	u8		use_map:1,
 			dsn64:1,
 			data_fin:1,
@@ -38,6 +41,8 @@ struct mptcp_ext {
 	u8		reset_reason:4,
 			csum_reqd:1,
 			infinite_map:1;
+
+	); /* end of flags group */
 };
 
 #define MPTCPOPT_HMAC_LEN	20
net/mptcp/options.c +0 -0
index 8a1c5698983c..3fd40dbff82b 100644
@@ -572,6 +572,11 @@ static bool mptcp_established_options_dss(struct

sock *sk, struct sk_buff *skb,
bool ret = false;
u64 ack_seq;

+ /* Zero can_ack and use_map flags with one shot. */
+ BUILD_BUG_ON(sizeof_field(struct mptcp_ext, flags) != sizeof(u16));
+ BUILD_BUG_ON(!IS_ALIGNED(offsetof(struct mptcp_ext, flags),
+ sizeof(u16)));
+ *(u16 *)&opts->ext_copy.flags = 0;
opts->csum_reqd = READ_ONCE(msk->csum_enabled); mpext = skb ? mptcp_get_ext(skb) : NULL;

@@ -595,7 +600,6 @@ static bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb,
/* passive sockets msk will set the 'can_ack' after accept(), even
* if the first subflow may have the already the remote key handy */
- opts->ext_copy.use_ack = 0;
if (!READ_ONCE(msk->can_ack)) {
*size = ALIGN(dss_size, 4);
return ret;

author syzbot
#8 lore raw
syzbot tried to test the proposed patch but the build/boot failed:

Hello,

syzbot tried to test the proposed patch but the build/boot failed:

failed to apply patch:
checking file include/net/mptcp.h
checking file net/mptcp/options.c
patch: **** unexpected end of file in patch

Tested on:

commit:         6d35786d Merge tag 'for-linus' of git://git.kernel.org..
git tree:       upstream
kernel config:  https://syzkaller.appspot.com/x/.config?x=1c3f61154f3bb7e5
dashboard link: https://syzkaller.appspot.com/bug?extid=ff020673c5e3d94d9478

compiler:
patch: https://syzkaller.appspot.com/x/patch.diff?x=12558ad2580000

maintainer
#9 lore raw

Re: [PATCH] mptcp: fix KMSAN: uninit-value in mptcp_established_options

In reply to Paolo Abeni
Quoted 8 lines · Paolo Abeni
Quoted 3 lines · Matthieu Baerts

Sorry for the noise: I forgot to add the syzbot instruction... (and I forgot to remove the MPTCP ML from the sendmail.to option).

I did not take in account all the possible corner cases.

Let's be a little more conservative.

Darn... the last upgrade here broke the line (un)wrap extension. Let me attach the patch. Sorry for the spam.

#syz test

include/net/mptcp.h +5 -0
index f7263fe2a2e4..0763fd6f7758 100644
@@ -27,6 +27,9 @@ struct mptcp_ext {
 	u32		subflow_seq;
 	u16		data_len;
 	__sum16		csum;
+
+	struct_group(flags,
+
 	u8		use_map:1,
 			dsn64:1,
 			data_fin:1,
@@ -38,6 +41,8 @@ struct mptcp_ext {
 	u8		reset_reason:4,
 			csum_reqd:1,
 			infinite_map:1;
+
+	); /* end of flags group */
 };
 
 #define MPTCPOPT_HMAC_LEN	20
net/mptcp/options.c +5 -1
index 8a1c5698983c..3fd40dbff82b 100644
@@ -572,6 +572,11 @@ static bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb,
 	bool ret = false;
 	u64 ack_seq;
 
+	/* Zero `can_ack` and `use_map` flags with one shot. */
+	BUILD_BUG_ON(sizeof_field(struct mptcp_ext, flags) != sizeof(u16));
+	BUILD_BUG_ON(!IS_ALIGNED(offsetof(struct mptcp_ext, flags),
+				 sizeof(u16)));
+	*(u16 *)&opts->ext_copy.flags = 0;
 	opts->csum_reqd = READ_ONCE(msk->csum_enabled);
 	mpext = skb ? mptcp_get_ext(skb) : NULL;
 
@@ -595,7 +600,6 @@ static bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb,
 	/* passive sockets msk will set the 'can_ack' after accept(), even
 	 * if the first subflow may have the already the remote key handy
 	 */
-	opts->ext_copy.use_ack = 0;
 	if (!READ_ONCE(msk->can_ack)) {
 		*size = ALIGN(dss_size, 4);
 		return ret;
author syzbot
#10 lore raw
syzbot has tested the proposed patch but the reproducer is still triggering an issue: KMSAN: uninit-value in irqentry_exit_to_kernel_mode_preempt

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KMSAN: uninit-value in irqentry_exit_to_kernel_mode_preempt

=====================================================

BUG: KMSAN: uninit-value in irqentry_exit_to_kernel_mode_preempt+0xb0/0xc0 include/linux/irq-entry-common.h:472
 irqentry_exit_to_kernel_mode_preempt+0xb0/0xc0 include/linux/irq-entry-common.h:472
 irqentry_exit_to_kernel_mode include/linux/irq-entry-common.h:547 [inline]
 irqentry_exit+0x7b/0x760 kernel/entry/common.c:164
 sysvec_apic_timer_interrupt+0x52/0x90 arch/x86/kernel/apic/apic.c:1061
 asm_sysvec_apic_timer_interrupt+0x1f/0x30 arch/x86/include/asm/idtentry.h:697
 kmsan_get_metadata+0x17/0x160 mm/kmsan/shadow.c:125
 kmsan_get_shadow_origin_ptr+0x4a/0xb0 mm/kmsan/shadow.c:102
 get_shadow_origin_ptr mm/kmsan/instrumentation.c:38 [inline]
 __msan_metadata_ptr_for_load_4+0x24/0x40 mm/kmsan/instrumentation.c:93
 tcp_data_queue+0xdc/0x7c90 net/ipv4/tcp_input.c:5589
 tcp_rcv_established+0x19bb/0x3200 net/ipv4/tcp_input.c:6656
 tcp_v4_do_rcv+0xc4b/0x1b10 net/ipv4/tcp_ipv4.c:1852
 sk_backlog_rcv include/net/sock.h:1190 [inline]
 __release_sock+0x360/0x7d0 net/core/sock.c:3216
 release_sock+0x22d/0x300 net/core/sock.c:3815
 mptcp_subflow_shutdown+0x358/0x690 net/mptcp/protocol.c:3144
 mptcp_check_send_data_fin+0x31b/0x3d0 net/mptcp/protocol.c:3218
 __mptcp_wr_shutdown net/mptcp/protocol.c:3234 [inline]
 __mptcp_close+0x860/0x1360 net/mptcp/protocol.c:3313
 mptcp_close+0x42/0x260 net/mptcp/protocol.c:3367
 inet_release+0x1ee/0x2a0 net/ipv4/af_inet.c:442
 __sock_release net/socket.c:722 [inline]
 sock_close+0xd6/0x2f0 net/socket.c:1514
 __fput+0x60e/0x1010 fs/file_table.c:510
 ____fput+0x25/0x30 fs/file_table.c:538
 task_work_run+0x208/0x2b0 kernel/task_work.c:233
 resume_user_mode_work include/linux/resume_user_mode.h:50 [inline]
 __exit_to_user_mode_loop kernel/entry/common.c:67 [inline]
 exit_to_user_mode_loop+0x306/0x1b60 kernel/entry/common.c:98
 __exit_to_user_mode_prepare include/linux/irq-entry-common.h:207 [inline]
 syscall_exit_to_user_mode_prepare include/linux/irq-entry-common.h:238 [inline]
 syscall_exit_to_user_mode include/linux/entry-common.h:318 [inline]
 do_syscall_64+0x236/0xf80 arch/x86/entry/syscall_64.c:100
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Local variable mp_opt created at:

 mptcp_incoming_options+0x11d/0x43b0 net/mptcp/options.c:1171
 tcp_data_queue+0x80/0x7c90 net/ipv4/tcp_input.c:5584

CPU: 1 UID: 0 PID: 8009 Comm: syz.0.635 Not tainted syzkaller #0 PREEMPT(full) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/18/2026
=====================================================

Tested on:

commit:         6d35786d Merge tag 'for-linus' of git://git.kernel.org..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=10070d06580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=1c3f61154f3bb7e5
dashboard link: https://syzkaller.appspot.com/bug?extid=ff020673c5e3d94d9478
compiler:       Debian clang version 21.1.8 (++20251221033036+2078da43e25a-1~exp1~20251221153213.50), Debian LLD 21.1.8
patch:          https://syzkaller.appspot.com/x/patch.diff?x=13d0b96a580000
maintainer
#11 lore raw

Hi Paolo, Kuniyuki,

Quoted 4 lines · syzbot

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KMSAN: uninit-value in irqentry_exit_to_kernel_mode_preempt

It looks like the issue is different now:

Quoted 15 lines

=====================================================

BUG: KMSAN: uninit-value in irqentry_exit_to_kernel_mode_preempt+0xb0/0xc0 include/linux/irq-entry-common.h:472
 irqentry_exit_to_kernel_mode_preempt+0xb0/0xc0 include/linux/irq-entry-common.h:472
 irqentry_exit_to_kernel_mode include/linux/irq-entry-common.h:547 [inline]
 irqentry_exit+0x7b/0x760 kernel/entry/common.c:164
 sysvec_apic_timer_interrupt+0x52/0x90 arch/x86/kernel/apic/apic.c:1061
 asm_sysvec_apic_timer_interrupt+0x1f/0x30 arch/x86/include/asm/idtentry.h:697
 kmsan_get_metadata+0x17/0x160 mm/kmsan/shadow.c:125
 kmsan_get_shadow_origin_ptr+0x4a/0xb0 mm/kmsan/shadow.c:102
 get_shadow_origin_ptr mm/kmsan/instrumentation.c:38 [inline]
 __msan_metadata_ptr_for_load_4+0x24/0x40 mm/kmsan/instrumentation.c:93
 tcp_data_queue+0xdc/0x7c90 net/ipv4/tcp_input.c:5589
 tcp_rcv_established+0x19bb/0x3200 net/ipv4/tcp_input.c:6656
 tcp_v4_do_rcv+0xc4b/0x1b10 net/ipv4/tcp_ipv4.c:1852
 sk_backlog_rcv include/net/sock.h:1190 [inline]

That's the input side.

Quoted 22 lines
 __release_sock+0x360/0x7d0 net/core/sock.c:3216
 release_sock+0x22d/0x300 net/core/sock.c:3815
 mptcp_subflow_shutdown+0x358/0x690 net/mptcp/protocol.c:3144
 mptcp_check_send_data_fin+0x31b/0x3d0 net/mptcp/protocol.c:3218
 __mptcp_wr_shutdown net/mptcp/protocol.c:3234 [inline]
 __mptcp_close+0x860/0x1360 net/mptcp/protocol.c:3313
 mptcp_close+0x42/0x260 net/mptcp/protocol.c:3367
 inet_release+0x1ee/0x2a0 net/ipv4/af_inet.c:442
 __sock_release net/socket.c:722 [inline]
 sock_close+0xd6/0x2f0 net/socket.c:1514
 __fput+0x60e/0x1010 fs/file_table.c:510
 ____fput+0x25/0x30 fs/file_table.c:538
 task_work_run+0x208/0x2b0 kernel/task_work.c:233
 resume_user_mode_work include/linux/resume_user_mode.h:50 [inline]
 __exit_to_user_mode_loop kernel/entry/common.c:67 [inline]
 exit_to_user_mode_loop+0x306/0x1b60 kernel/entry/common.c:98
 __exit_to_user_mode_prepare include/linux/irq-entry-common.h:207 [inline]
 syscall_exit_to_user_mode_prepare include/linux/irq-entry-common.h:238 [inline]
 syscall_exit_to_user_mode include/linux/entry-common.h:318 [inline]
 do_syscall_64+0x236/0xf80 arch/x86/entry/syscall_64.c:100
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
Quoted 2 lines

Local variable mp_opt created at:
mptcp_incoming_options+0x11d/0x43b0 net/mptcp/options.c:1171

Confirmed here. With "struct mptcp_options_received" while the original issue was with "struct mptcp_out_options".

Plus I'm not exactly sure to understand the issue here: mp_opt is defined and used only in mptcp_incoming_options(), and I don't see anything using it after the end of this function. Or did I miss something?

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
maintainer
#12 lore raw
Quoted 53 lines · Matthieu Baerts

Hi Paolo, Kuniyuki,

Quoted 4 lines · syzbot

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KMSAN: uninit-value in irqentry_exit_to_kernel_mode_preempt

It looks like the issue is different now:

Quoted 15 lines

=====================================================

BUG: KMSAN: uninit-value in irqentry_exit_to_kernel_mode_preempt+0xb0/0xc0 include/linux/irq-entry-common.h:472
 irqentry_exit_to_kernel_mode_preempt+0xb0/0xc0 include/linux/irq-entry-common.h:472
 irqentry_exit_to_kernel_mode include/linux/irq-entry-common.h:547 [inline]
 irqentry_exit+0x7b/0x760 kernel/entry/common.c:164
 sysvec_apic_timer_interrupt+0x52/0x90 arch/x86/kernel/apic/apic.c:1061
 asm_sysvec_apic_timer_interrupt+0x1f/0x30 arch/x86/include/asm/idtentry.h:697
 kmsan_get_metadata+0x17/0x160 mm/kmsan/shadow.c:125
 kmsan_get_shadow_origin_ptr+0x4a/0xb0 mm/kmsan/shadow.c:102
 get_shadow_origin_ptr mm/kmsan/instrumentation.c:38 [inline]
 __msan_metadata_ptr_for_load_4+0x24/0x40 mm/kmsan/instrumentation.c:93
 tcp_data_queue+0xdc/0x7c90 net/ipv4/tcp_input.c:5589
 tcp_rcv_established+0x19bb/0x3200 net/ipv4/tcp_input.c:6656
 tcp_v4_do_rcv+0xc4b/0x1b10 net/ipv4/tcp_ipv4.c:1852
 sk_backlog_rcv include/net/sock.h:1190 [inline]

That's the input side.

Quoted 22 lines
 __release_sock+0x360/0x7d0 net/core/sock.c:3216
 release_sock+0x22d/0x300 net/core/sock.c:3815
 mptcp_subflow_shutdown+0x358/0x690 net/mptcp/protocol.c:3144
 mptcp_check_send_data_fin+0x31b/0x3d0 net/mptcp/protocol.c:3218
 __mptcp_wr_shutdown net/mptcp/protocol.c:3234 [inline]
 __mptcp_close+0x860/0x1360 net/mptcp/protocol.c:3313
 mptcp_close+0x42/0x260 net/mptcp/protocol.c:3367
 inet_release+0x1ee/0x2a0 net/ipv4/af_inet.c:442
 __sock_release net/socket.c:722 [inline]
 sock_close+0xd6/0x2f0 net/socket.c:1514
 __fput+0x60e/0x1010 fs/file_table.c:510
 ____fput+0x25/0x30 fs/file_table.c:538
 task_work_run+0x208/0x2b0 kernel/task_work.c:233
 resume_user_mode_work include/linux/resume_user_mode.h:50 [inline]
 __exit_to_user_mode_loop kernel/entry/common.c:67 [inline]
 exit_to_user_mode_loop+0x306/0x1b60 kernel/entry/common.c:98
 __exit_to_user_mode_prepare include/linux/irq-entry-common.h:207 [inline]
 syscall_exit_to_user_mode_prepare include/linux/irq-entry-common.h:238 [inline]
 syscall_exit_to_user_mode include/linux/entry-common.h:318 [inline]
 do_syscall_64+0x236/0xf80 arch/x86/entry/syscall_64.c:100
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
Quoted 2 lines

Local variable mp_opt created at:
mptcp_incoming_options+0x11d/0x43b0 net/mptcp/options.c:1171

Quoted 6 lines

Confirmed here. With "struct mptcp_options_received" while the original issue was with "struct mptcp_out_options".

Plus I'm not exactly sure to understand the issue here: mp_opt is defined and used only in mptcp_incoming_options(), and I don't see anything using it after the end of this function. Or did I miss something?

I also had hard time understanding the backtrace, I think some frames are omitted/missing (it happens sometime, IDK why), specifically the one related to mptcp_options_received() - which would be useful to understand the issue.

/P

#13 lore raw
Quoted 58 lines · Paolo Abeni' via syzkaller-bugs
Quoted 56 lines · Matthieu Baerts

Hi Paolo, Kuniyuki,

Quoted 4 lines · syzbot

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KMSAN: uninit-value in irqentry_exit_to_kernel_mode_preempt

It looks like the issue is different now:

Quoted 15 lines

=====================================================

BUG: KMSAN: uninit-value in irqentry_exit_to_kernel_mode_preempt+0xb0/0xc0 include/linux/irq-entry-common.h:472
 irqentry_exit_to_kernel_mode_preempt+0xb0/0xc0 include/linux/irq-entry-common.h:472
 irqentry_exit_to_kernel_mode include/linux/irq-entry-common.h:547 [inline]
 irqentry_exit+0x7b/0x760 kernel/entry/common.c:164
 sysvec_apic_timer_interrupt+0x52/0x90 arch/x86/kernel/apic/apic.c:1061
 asm_sysvec_apic_timer_interrupt+0x1f/0x30 arch/x86/include/asm/idtentry.h:697
 kmsan_get_metadata+0x17/0x160 mm/kmsan/shadow.c:125
 kmsan_get_shadow_origin_ptr+0x4a/0xb0 mm/kmsan/shadow.c:102
 get_shadow_origin_ptr mm/kmsan/instrumentation.c:38 [inline]
 __msan_metadata_ptr_for_load_4+0x24/0x40 mm/kmsan/instrumentation.c:93
 tcp_data_queue+0xdc/0x7c90 net/ipv4/tcp_input.c:5589
 tcp_rcv_established+0x19bb/0x3200 net/ipv4/tcp_input.c:6656
 tcp_v4_do_rcv+0xc4b/0x1b10 net/ipv4/tcp_ipv4.c:1852
 sk_backlog_rcv include/net/sock.h:1190 [inline]

That's the input side.

Quoted 22 lines
 __release_sock+0x360/0x7d0 net/core/sock.c:3216
 release_sock+0x22d/0x300 net/core/sock.c:3815
 mptcp_subflow_shutdown+0x358/0x690 net/mptcp/protocol.c:3144
 mptcp_check_send_data_fin+0x31b/0x3d0 net/mptcp/protocol.c:3218
 __mptcp_wr_shutdown net/mptcp/protocol.c:3234 [inline]
 __mptcp_close+0x860/0x1360 net/mptcp/protocol.c:3313
 mptcp_close+0x42/0x260 net/mptcp/protocol.c:3367
 inet_release+0x1ee/0x2a0 net/ipv4/af_inet.c:442
 __sock_release net/socket.c:722 [inline]
 sock_close+0xd6/0x2f0 net/socket.c:1514
 __fput+0x60e/0x1010 fs/file_table.c:510
 ____fput+0x25/0x30 fs/file_table.c:538
 task_work_run+0x208/0x2b0 kernel/task_work.c:233
 resume_user_mode_work include/linux/resume_user_mode.h:50 [inline]
 __exit_to_user_mode_loop kernel/entry/common.c:67 [inline]
 exit_to_user_mode_loop+0x306/0x1b60 kernel/entry/common.c:98
 __exit_to_user_mode_prepare include/linux/irq-entry-common.h:207 [inline]
 syscall_exit_to_user_mode_prepare include/linux/irq-entry-common.h:238 [inline]
 syscall_exit_to_user_mode include/linux/entry-common.h:318 [inline]
 do_syscall_64+0x236/0xf80 arch/x86/entry/syscall_64.c:100
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
Quoted 2 lines

Local variable mp_opt created at:
mptcp_incoming_options+0x11d/0x43b0 net/mptcp/options.c:1171

Confirmed here. With "struct mptcp_options_received" while the original issue was with "struct mptcp_out_options".

Quoted 8 lines
Quoted 3 lines

Plus I'm not exactly sure to understand the issue here: mp_opt is defined and used only in mptcp_incoming_options(), and I don't see anything using it after the end of this function. Or did I miss something?

I also had hard time understanding the backtrace, I think some frames are omitted/missing (it happens sometime, IDK why), specifically the one related to mptcp_options_received() - which would be useful to understand the issue.

This is probably related to
https://lore.kernel.org/all/[email protected]/T/

Let me send the patch, perhaps this issue will also go away.

maintainer
#14 lore raw

Hi Alexander,

Thank you for your reply!

Quoted 64 lines · Alexander Potapenko
Quoted 62 lines · Paolo Abeni' via syzkaller-bugs
Quoted 59 lines · Matthieu Baerts

Hi Paolo, Kuniyuki,

Quoted 4 lines · syzbot

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KMSAN: uninit-value in irqentry_exit_to_kernel_mode_preempt

It looks like the issue is different now:

Quoted 15 lines

=====================================================

BUG: KMSAN: uninit-value in irqentry_exit_to_kernel_mode_preempt+0xb0/0xc0 include/linux/irq-entry-common.h:472
 irqentry_exit_to_kernel_mode_preempt+0xb0/0xc0 include/linux/irq-entry-common.h:472
 irqentry_exit_to_kernel_mode include/linux/irq-entry-common.h:547 [inline]
 irqentry_exit+0x7b/0x760 kernel/entry/common.c:164
 sysvec_apic_timer_interrupt+0x52/0x90 arch/x86/kernel/apic/apic.c:1061
 asm_sysvec_apic_timer_interrupt+0x1f/0x30 arch/x86/include/asm/idtentry.h:697
 kmsan_get_metadata+0x17/0x160 mm/kmsan/shadow.c:125
 kmsan_get_shadow_origin_ptr+0x4a/0xb0 mm/kmsan/shadow.c:102
 get_shadow_origin_ptr mm/kmsan/instrumentation.c:38 [inline]
 __msan_metadata_ptr_for_load_4+0x24/0x40 mm/kmsan/instrumentation.c:93
 tcp_data_queue+0xdc/0x7c90 net/ipv4/tcp_input.c:5589
 tcp_rcv_established+0x19bb/0x3200 net/ipv4/tcp_input.c:6656
 tcp_v4_do_rcv+0xc4b/0x1b10 net/ipv4/tcp_ipv4.c:1852
 sk_backlog_rcv include/net/sock.h:1190 [inline]

That's the input side.

Quoted 22 lines
 __release_sock+0x360/0x7d0 net/core/sock.c:3216
 release_sock+0x22d/0x300 net/core/sock.c:3815
 mptcp_subflow_shutdown+0x358/0x690 net/mptcp/protocol.c:3144
 mptcp_check_send_data_fin+0x31b/0x3d0 net/mptcp/protocol.c:3218
 __mptcp_wr_shutdown net/mptcp/protocol.c:3234 [inline]
 __mptcp_close+0x860/0x1360 net/mptcp/protocol.c:3313
 mptcp_close+0x42/0x260 net/mptcp/protocol.c:3367
 inet_release+0x1ee/0x2a0 net/ipv4/af_inet.c:442
 __sock_release net/socket.c:722 [inline]
 sock_close+0xd6/0x2f0 net/socket.c:1514
 __fput+0x60e/0x1010 fs/file_table.c:510
 ____fput+0x25/0x30 fs/file_table.c:538
 task_work_run+0x208/0x2b0 kernel/task_work.c:233
 resume_user_mode_work include/linux/resume_user_mode.h:50 [inline]
 __exit_to_user_mode_loop kernel/entry/common.c:67 [inline]
 exit_to_user_mode_loop+0x306/0x1b60 kernel/entry/common.c:98
 __exit_to_user_mode_prepare include/linux/irq-entry-common.h:207 [inline]
 syscall_exit_to_user_mode_prepare include/linux/irq-entry-common.h:238 [inline]
 syscall_exit_to_user_mode include/linux/entry-common.h:318 [inline]
 do_syscall_64+0x236/0xf80 arch/x86/entry/syscall_64.c:100
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
Quoted 2 lines

Local variable mp_opt created at:
mptcp_incoming_options+0x11d/0x43b0 net/mptcp/options.c:1171

Confirmed here. With "struct mptcp_options_received" while the original issue was with "struct mptcp_out_options".

Plus I'm not exactly sure to understand the issue here: mp_opt is defined and used only in mptcp_incoming_options(), and I don't see anything using it after the end of this function. Or did I miss something?

Quoted 7 lines
Quoted 4 lines

I also had hard time understanding the backtrace, I think some frames are omitted/missing (it happens sometime, IDK why), specifically the one related to mptcp_options_received() - which would be useful to understand the issue.

This is probably related to
https://lore.kernel.org/all/[email protected]/T/

Ah yes, it looks similar.

Quoted 1 line

Let me send the patch, perhaps this issue will also go away.

That would be great, thank you!

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
maintainer
#15 lore raw

Hi Alexander,

Quoted 74 lines · Matthieu Baerts

Hi Alexander,

Thank you for your reply!

Quoted 69 lines · Alexander Potapenko
Quoted 66 lines · Paolo Abeni' via syzkaller-bugs
Quoted 53 lines · Matthieu Baerts

Hi Paolo, Kuniyuki,

Quoted 4 lines · syzbot

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KMSAN: uninit-value in irqentry_exit_to_kernel_mode_preempt

It looks like the issue is different now:

Quoted 15 lines

=====================================================

BUG: KMSAN: uninit-value in irqentry_exit_to_kernel_mode_preempt+0xb0/0xc0 include/linux/irq-entry-common.h:472
 irqentry_exit_to_kernel_mode_preempt+0xb0/0xc0 include/linux/irq-entry-common.h:472
 irqentry_exit_to_kernel_mode include/linux/irq-entry-common.h:547 [inline]
 irqentry_exit+0x7b/0x760 kernel/entry/common.c:164
 sysvec_apic_timer_interrupt+0x52/0x90 arch/x86/kernel/apic/apic.c:1061
 asm_sysvec_apic_timer_interrupt+0x1f/0x30 arch/x86/include/asm/idtentry.h:697
 kmsan_get_metadata+0x17/0x160 mm/kmsan/shadow.c:125
 kmsan_get_shadow_origin_ptr+0x4a/0xb0 mm/kmsan/shadow.c:102
 get_shadow_origin_ptr mm/kmsan/instrumentation.c:38 [inline]
 __msan_metadata_ptr_for_load_4+0x24/0x40 mm/kmsan/instrumentation.c:93
 tcp_data_queue+0xdc/0x7c90 net/ipv4/tcp_input.c:5589
 tcp_rcv_established+0x19bb/0x3200 net/ipv4/tcp_input.c:6656
 tcp_v4_do_rcv+0xc4b/0x1b10 net/ipv4/tcp_ipv4.c:1852
 sk_backlog_rcv include/net/sock.h:1190 [inline]

That's the input side.

Quoted 22 lines
 __release_sock+0x360/0x7d0 net/core/sock.c:3216
 release_sock+0x22d/0x300 net/core/sock.c:3815
 mptcp_subflow_shutdown+0x358/0x690 net/mptcp/protocol.c:3144
 mptcp_check_send_data_fin+0x31b/0x3d0 net/mptcp/protocol.c:3218
 __mptcp_wr_shutdown net/mptcp/protocol.c:3234 [inline]
 __mptcp_close+0x860/0x1360 net/mptcp/protocol.c:3313
 mptcp_close+0x42/0x260 net/mptcp/protocol.c:3367
 inet_release+0x1ee/0x2a0 net/ipv4/af_inet.c:442
 __sock_release net/socket.c:722 [inline]
 sock_close+0xd6/0x2f0 net/socket.c:1514
 __fput+0x60e/0x1010 fs/file_table.c:510
 ____fput+0x25/0x30 fs/file_table.c:538
 task_work_run+0x208/0x2b0 kernel/task_work.c:233
 resume_user_mode_work include/linux/resume_user_mode.h:50 [inline]
 __exit_to_user_mode_loop kernel/entry/common.c:67 [inline]
 exit_to_user_mode_loop+0x306/0x1b60 kernel/entry/common.c:98
 __exit_to_user_mode_prepare include/linux/irq-entry-common.h:207 [inline]
 syscall_exit_to_user_mode_prepare include/linux/irq-entry-common.h:238 [inline]
 syscall_exit_to_user_mode include/linux/entry-common.h:318 [inline]
 do_syscall_64+0x236/0xf80 arch/x86/entry/syscall_64.c:100
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
Quoted 2 lines

Local variable mp_opt created at:
mptcp_incoming_options+0x11d/0x43b0 net/mptcp/options.c:1171

Quoted 6 lines

Confirmed here. With "struct mptcp_options_received" while the original issue was with "struct mptcp_out_options".

Plus I'm not exactly sure to understand the issue here: mp_opt is defined and used only in mptcp_incoming_options(), and I don't see anything using it after the end of this function. Or did I miss something?

I also had hard time understanding the backtrace, I think some frames are omitted/missing (it happens sometime, IDK why), specifically the one related to mptcp_options_received() - which would be useful to understand the issue.

Quoted 8 lines
Quoted 2 lines

This is probably related to
https://lore.kernel.org/all/[email protected]/T/

Ah yes, it looks similar.

Quoted 1 line

Let me send the patch, perhaps this issue will also go away.

That would be great, thank you!

Thank you for having sent your patch.

Here is one combining your modifications, and the ones from Paolo, for syzbot. If this one is OK, we can continue with Paolo's patch.

#syz test

Cheers,
Matt

include/linux/irq-entry-common.h +2 -0
index 167fba7dbf04..be47d430d521 100644
@@ -427,6 +427,7 @@ static __always_inline irqentry_state_t irqentry_enter_from_kernel_mode(struct p
 		ct_irq_enter();
 		instrumentation_begin();
 		kmsan_unpoison_entry_regs(regs);
+		kmsan_unpoison_memory(&ret, sizeof(ret));
 		trace_hardirqs_off_finish();
 		instrumentation_end();
 
@@ -443,6 +444,7 @@ static __always_inline irqentry_state_t irqentry_enter_from_kernel_mode(struct p
 	lockdep_hardirqs_off(CALLER_ADDR0);
 	instrumentation_begin();
 	kmsan_unpoison_entry_regs(regs);
+	kmsan_unpoison_memory(&ret, sizeof(ret));
 	rcu_irq_enter_check_tick();
 	trace_hardirqs_off_finish();
 	instrumentation_end();
include/net/mptcp.h +5 -0
index f7263fe2a2e4..0763fd6f7758 100644
@@ -27,6 +27,9 @@ struct mptcp_ext {
 	u32		subflow_seq;
 	u16		data_len;
 	__sum16		csum;
+
+	struct_group(flags,
+
 	u8		use_map:1,
 			dsn64:1,
 			data_fin:1,
@@ -38,6 +41,8 @@ struct mptcp_ext {
 	u8		reset_reason:4,
 			csum_reqd:1,
 			infinite_map:1;
+
+	); /* end of flags group */
 };
 
 #define MPTCPOPT_HMAC_LEN	20
kernel/entry/common.c +1 -0
index 19d2244a9fef..390364943f92 100644
@@ -177,6 +177,7 @@ irqentry_state_t noinstr irqentry_nmi_enter(struct pt_regs *regs)
 
 	instrumentation_begin();
 	kmsan_unpoison_entry_regs(regs);
+	kmsan_unpoison_memory(&irq_state, sizeof(irq_state));
 	trace_hardirqs_off_finish();
 	ftrace_nmi_enter();
 	instrumentation_end();
net/mptcp/options.c +5 -1
index 8a1c5698983c..3fd40dbff82b 100644
@@ -572,6 +572,11 @@ static bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb,
 	bool ret = false;
 	u64 ack_seq;
 
+	/* Zero `can_ack` and `use_map` flags with one shot. */
+	BUILD_BUG_ON(sizeof_field(struct mptcp_ext, flags) != sizeof(u16));
+	BUILD_BUG_ON(!IS_ALIGNED(offsetof(struct mptcp_ext, flags),
+				 sizeof(u16)));
+	*(u16 *)&opts->ext_copy.flags = 0;
 	opts->csum_reqd = READ_ONCE(msk->csum_enabled);
 	mpext = skb ? mptcp_get_ext(skb) : NULL;
 
@@ -595,7 +600,6 @@ static bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb,
 	/* passive sockets msk will set the 'can_ack' after accept(), even
 	 * if the first subflow may have the already the remote key handy
 	 */
-	opts->ext_copy.use_ack = 0;
 	if (!READ_ONCE(msk->can_ack)) {
 		*size = ALIGN(dss_size, 4);
 		return ret;
#16 lore raw
Quoted 14 lines
Quoted 14 lines
Quoted 11 lines
Quoted 8 lines
Quoted 3 lines

Plus I'm not exactly sure to understand the issue here: mp_opt is defined and used only in mptcp_incoming_options(), and I don't see anything using it after the end of this function. Or did I miss something?

I also had hard time understanding the backtrace, I think some frames are omitted/missing (it happens sometime, IDK why), specifically the one related to mptcp_options_received() - which would be useful to understand the issue.

This is probably related to
https://lore.kernel.org/all/[email protected]/T/

Ah yes, it looks similar.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Let me send the patch, perhaps this issue will also go away.

That would be great, thank you!

Thank you for having sent your patch.

Here is one combining your modifications, and the ones from Paolo, for syzbot. If this one is OK, we can continue with Paolo's patch.

Hi Matt,

Unfortunately my approach was wrong: see tglx's response there. Hope we'll figure something out (__no_kmsan_checks looks promising)

Alex

author syzbot
#18 lore raw
In reply to Matthieu Baerts
syzbot has tested the proposed patch but the reproducer is still triggering an issue: KMSAN: uninit-value in irqentry_exit_to_kernel_mode_preempt

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KMSAN: uninit-value in irqentry_exit_to_kernel_mode_preempt

=====================================================

BUG: KMSAN: uninit-value in irqentry_exit_to_kernel_mode_preempt+0xb0/0xc0 include/linux/irq-entry-common.h:474
 irqentry_exit_to_kernel_mode_preempt+0xb0/0xc0 include/linux/irq-entry-common.h:474
 irqentry_exit_to_kernel_mode include/linux/irq-entry-common.h:549 [inline]
 irqentry_exit+0x7b/0x820 kernel/entry/common.c:164
 sysvec_apic_timer_interrupt+0x52/0x90 arch/x86/kernel/apic/apic.c:1061
 asm_sysvec_apic_timer_interrupt+0x1f/0x30 arch/x86/include/asm/idtentry.h:697
 __msan_metadata_ptr_for_load_4+0x5/0x40 mm/kmsan/instrumentation.c:93
 tcp_rcv_established+0x19bb/0x3200 net/ipv4/tcp_input.c:6656
 tcp_v4_do_rcv+0xc5b/0x1b70 net/ipv4/tcp_ipv4.c:1851
 sk_backlog_rcv include/net/sock.h:1190 [inline]
 __release_sock+0x360/0x7d0 net/core/sock.c:3216
 release_sock+0x22d/0x300 net/core/sock.c:3815
 mptcp_subflow_shutdown+0x358/0x690 net/mptcp/protocol.c:3144
 mptcp_check_send_data_fin+0x31b/0x3d0 net/mptcp/protocol.c:3218
 __mptcp_wr_shutdown net/mptcp/protocol.c:3234 [inline]
 __mptcp_close+0x860/0x1360 net/mptcp/protocol.c:3313
 mptcp_close+0x42/0x260 net/mptcp/protocol.c:3367
 inet_release+0x1ee/0x2a0 net/ipv4/af_inet.c:442
 __sock_release net/socket.c:722 [inline]
 sock_close+0xd6/0x2f0 net/socket.c:1514
 __fput+0x60e/0x1010 fs/file_table.c:510
 ____fput+0x25/0x30 fs/file_table.c:538
 task_work_run+0x208/0x2b0 kernel/task_work.c:233
 resume_user_mode_work include/linux/resume_user_mode.h:50 [inline]
 __exit_to_user_mode_loop kernel/entry/common.c:67 [inline]
 exit_to_user_mode_loop+0x306/0x1ea0 kernel/entry/common.c:98
 __exit_to_user_mode_prepare include/linux/irq-entry-common.h:207 [inline]
 syscall_exit_to_user_mode_prepare include/linux/irq-entry-common.h:238 [inline]
 syscall_exit_to_user_mode include/linux/entry-common.h:318 [inline]
 do_syscall_64+0x236/0xf80 arch/x86/entry/syscall_64.c:100
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Local variable mp_opt created at:

 mptcp_incoming_options+0x11d/0x43b0 net/mptcp/options.c:1171
 tcp_data_queue+0x80/0x7c90 net/ipv4/tcp_input.c:5584

CPU: 0 UID: 0 PID: 10313 Comm: syz.0.1815 Not tainted syzkaller #0 PREEMPT(full) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/18/2026
=====================================================

Tested on:

commit:         50897c95 Merge tag 'linux_kselftest-kunit-fixes-7.1-rc..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=121c20c8580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=a9f364ffbbe4c1e9
dashboard link: https://syzkaller.appspot.com/bug?extid=ff020673c5e3d94d9478
compiler:       Debian clang version 21.1.8 (++20251221033036+2078da43e25a-1~exp1~20251221153213.50), Debian LLD 21.1.8
patch:          https://syzkaller.appspot.com/x/patch.diff?x=1555c7ce580000
maintainer
#17 lore raw
In reply to Alexander Potapenko

Hi Alexander,

Quoted 20 lines · Alexander Potapenko
Quoted 20 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 3 lines

Plus I'm not exactly sure to understand the issue here: mp_opt is defined and used only in mptcp_incoming_options(), and I don't see anything using it after the end of this function. Or did I miss something?

I also had hard time understanding the backtrace, I think some frames are omitted/missing (it happens sometime, IDK why), specifically the one related to mptcp_options_received() - which would be useful to understand the issue.

Quoted 8 lines
Quoted 2 lines

This is probably related to
https://lore.kernel.org/all/[email protected]/T/

Ah yes, it looks similar.

Quoted 1 line

Let me send the patch, perhaps this issue will also go away.

That would be great, thank you!

Thank you for having sent your patch.

Quoted 8 lines
Quoted 2 lines

Here is one combining your modifications, and the ones from Paolo, for syzbot. If this one is OK, we can continue with Paolo's patch.

Hi Matt,

Unfortunately my approach was wrong: see tglx's response there. Hope we'll figure something out (__no_kmsan_checks looks promising)

Thank you for your reply, I just found the email thread you mentioned:

https://lore.kernel.org/all/87v7cu876c.ffs@tglx

If a v2 is not expected "soon", I'm sure we can continue with Paolo's patch, and double-check later to see if it was enough.

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
maintainer
#19 lore raw
In reply to Paolo Abeni

Hi Paolo,

Quoted 10 lines · Paolo Abeni
Quoted 9 lines · Matthieu Baerts

Hi Paolo, Kuniyuki,

Quoted 4 lines · syzbot

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KMSAN: uninit-value in irqentry_exit_to_kernel_mode_preempt

It looks like the issue is different now:

(...)

Quoted 8 lines
Quoted 3 lines

Plus I'm not exactly sure to understand the issue here: mp_opt is defined and used only in mptcp_incoming_options(), and I don't see anything using it after the end of this function. Or did I miss something?

I also had hard time understanding the backtrace, I think some frames are omitted/missing (it happens sometime, IDK why), specifically the one related to mptcp_options_received() - which would be useful to understand the issue.

Because the other issue spot by syzbot seems to unrelated, do you plan to send your patch upstream? Or do you prefer if someone else does it?

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
maintainer
#20 lore raw
Quoted 18 lines · Matthieu Baerts
Quoted 10 lines · Paolo Abeni
Quoted 9 lines · Matthieu Baerts

Hi Paolo, Kuniyuki,

Quoted 4 lines · syzbot

Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KMSAN: uninit-value in irqentry_exit_to_kernel_mode_preempt

It looks like the issue is different now:

(...)

Quoted 4 lines
Quoted 3 lines

Plus I'm not exactly sure to understand the issue here: mp_opt is defined and used only in mptcp_incoming_options(), and I don't see anything using it after the end of this function. Or did I miss something?

Quoted 7 lines
Quoted 4 lines

I also had hard time understanding the backtrace, I think some frames are omitted/missing (it happens sometime, IDK why), specifically the one related to mptcp_options_received() - which would be useful to understand the issue.

Because the other issue spot by syzbot seems to unrelated, do you plan to send your patch upstream? Or do you prefer if someone else does it?

I'm sorry /me is losing track of multiple items. I can send a formal patch to the mptcp ML for:

https://lore.kernel.org/all/[email protected]/#t

/P