Skip to content

Commit 10e99da

Browse files
q2venintel-lab-lkp
authored andcommitted
mptcp: Clear mptcp_out_options in mptcp_{syn,synack,established}_options().
syzbot reported read of uninit-value in mptcp_write_data_fin(). Since the cited commit, struct mptcp_out_options is not cleared in __tcp_transmit_skb(). Let's clear it in mptcp_{syn,synack,established}_options(). Another option is to move struct mptcp_out_options to struct tcp_out_options.cleared, but this memset() is not needed for TCP. [0]: 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: 1 UID: 0 PID: 5855 Comm: syz.3.4 Not tainted syzkaller #0 PREEMPT(full) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/18/2026 Fixes: cfcceb7 ("tcp: shrink per-packet memset in __tcp_transmit_skb()") Reported-by: syzbot+ff020673c5e3d94d9478@syzkaller.appspotmail.com Closes: https://lore.kernel.org/mptcp/69f44505.050a0220.3cbe47.0008.GAE@google.com/ Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
1 parent 1eb8c5c commit 10e99da

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

net/mptcp/options.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,8 @@ bool mptcp_syn_options(struct sock *sk, const struct sk_buff *skb,
403403
{
404404
struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
405405

406+
memset(opts, 0, sizeof(*opts));
407+
406408
/* we will use snd_isn to detect first pkt [re]transmission
407409
* in mptcp_established_options_mp()
408410
*/
@@ -847,7 +849,7 @@ bool mptcp_established_options(struct sock *sk, struct sk_buff *skb,
847849
bool snd_data_fin;
848850
bool ret = false;
849851

850-
opts->suboptions = 0;
852+
memset(opts, 0, sizeof(*opts));
851853

852854
/* Force later mptcp_write_options(), but do not use any actual
853855
* option space.
@@ -916,6 +918,8 @@ bool mptcp_synack_options(const struct request_sock *req, unsigned int *size,
916918
{
917919
struct mptcp_subflow_request_sock *subflow_req = mptcp_subflow_rsk(req);
918920

921+
memset(opts, 0, sizeof(*opts));
922+
919923
if (subflow_req->mp_capable) {
920924
opts->suboptions = OPTION_MPTCP_MPC_SYNACK;
921925
opts->sndr_key = subflow_req->local_key;

0 commit comments

Comments
 (0)