From 7beb9a0ea4861d3904e6869b7096b48f8b2272b1 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 4 Mar 2024 09:30:42 +0100 Subject: [PATCH] 5.15-stable patches added patches: mptcp-fix-possible-deadlock-in-subflow-diag.patch mptcp-fix-snd_wnd-initialization-for-passive-socket.patch mptcp-push-at-dss-boundaries.patch --- ...ix-possible-deadlock-in-subflow-diag.patch | 117 ++++++++++++++++++ ...nd-initialization-for-passive-socket.patch | 35 ++++++ queue-5.15/mptcp-push-at-dss-boundaries.patch | 41 ++++++ queue-5.15/series | 3 + 4 files changed, 196 insertions(+) create mode 100644 queue-5.15/mptcp-fix-possible-deadlock-in-subflow-diag.patch create mode 100644 queue-5.15/mptcp-fix-snd_wnd-initialization-for-passive-socket.patch create mode 100644 queue-5.15/mptcp-push-at-dss-boundaries.patch diff --git a/queue-5.15/mptcp-fix-possible-deadlock-in-subflow-diag.patch b/queue-5.15/mptcp-fix-possible-deadlock-in-subflow-diag.patch new file mode 100644 index 00000000000..5fcf43adf75 --- /dev/null +++ b/queue-5.15/mptcp-fix-possible-deadlock-in-subflow-diag.patch @@ -0,0 +1,117 @@ +From d6a9608af9a75d13243d217f6ce1e30e57d56ffe Mon Sep 17 00:00:00 2001 +From: Paolo Abeni +Date: Fri, 23 Feb 2024 17:14:19 +0100 +Subject: mptcp: fix possible deadlock in subflow diag + +From: Paolo Abeni + +commit d6a9608af9a75d13243d217f6ce1e30e57d56ffe upstream. + +Syzbot and Eric reported a lockdep splat in the subflow diag: + + WARNING: possible circular locking dependency detected + 6.8.0-rc4-syzkaller-00212-g40b9385dd8e6 #0 Not tainted + + syz-executor.2/24141 is trying to acquire lock: + ffff888045870130 (k-sk_lock-AF_INET6){+.+.}-{0:0}, at: + tcp_diag_put_ulp net/ipv4/tcp_diag.c:100 [inline] + ffff888045870130 (k-sk_lock-AF_INET6){+.+.}-{0:0}, at: + tcp_diag_get_aux+0x738/0x830 net/ipv4/tcp_diag.c:137 + + but task is already holding lock: + ffffc9000135e488 (&h->lhash2[i].lock){+.+.}-{2:2}, at: spin_lock + include/linux/spinlock.h:351 [inline] + ffffc9000135e488 (&h->lhash2[i].lock){+.+.}-{2:2}, at: + inet_diag_dump_icsk+0x39f/0x1f80 net/ipv4/inet_diag.c:1038 + + which lock already depends on the new lock. + + the existing dependency chain (in reverse order) is: + + -> #1 (&h->lhash2[i].lock){+.+.}-{2:2}: + lock_acquire+0x1e3/0x530 kernel/locking/lockdep.c:5754 + __raw_spin_lock include/linux/spinlock_api_smp.h:133 [inline] + _raw_spin_lock+0x2e/0x40 kernel/locking/spinlock.c:154 + spin_lock include/linux/spinlock.h:351 [inline] + __inet_hash+0x335/0xbe0 net/ipv4/inet_hashtables.c:743 + inet_csk_listen_start+0x23a/0x320 net/ipv4/inet_connection_sock.c:1261 + __inet_listen_sk+0x2a2/0x770 net/ipv4/af_inet.c:217 + inet_listen+0xa3/0x110 net/ipv4/af_inet.c:239 + rds_tcp_listen_init+0x3fd/0x5a0 net/rds/tcp_listen.c:316 + rds_tcp_init_net+0x141/0x320 net/rds/tcp.c:577 + ops_init+0x352/0x610 net/core/net_namespace.c:136 + __register_pernet_operations net/core/net_namespace.c:1214 [inline] + register_pernet_operations+0x2cb/0x660 net/core/net_namespace.c:1283 + register_pernet_device+0x33/0x80 net/core/net_namespace.c:1370 + rds_tcp_init+0x62/0xd0 net/rds/tcp.c:735 + do_one_initcall+0x238/0x830 init/main.c:1236 + do_initcall_level+0x157/0x210 init/main.c:1298 + do_initcalls+0x3f/0x80 init/main.c:1314 + kernel_init_freeable+0x42f/0x5d0 init/main.c:1551 + kernel_init+0x1d/0x2a0 init/main.c:1441 + ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147 + ret_from_fork_asm+0x1b/0x30 arch/x86/entry/entry_64.S:242 + + -> #0 (k-sk_lock-AF_INET6){+.+.}-{0:0}: + check_prev_add kernel/locking/lockdep.c:3134 [inline] + check_prevs_add kernel/locking/lockdep.c:3253 [inline] + validate_chain+0x18ca/0x58e0 kernel/locking/lockdep.c:3869 + __lock_acquire+0x1345/0x1fd0 kernel/locking/lockdep.c:5137 + lock_acquire+0x1e3/0x530 kernel/locking/lockdep.c:5754 + lock_sock_fast include/net/sock.h:1723 [inline] + subflow_get_info+0x166/0xd20 net/mptcp/diag.c:28 + tcp_diag_put_ulp net/ipv4/tcp_diag.c:100 [inline] + tcp_diag_get_aux+0x738/0x830 net/ipv4/tcp_diag.c:137 + inet_sk_diag_fill+0x10ed/0x1e00 net/ipv4/inet_diag.c:345 + inet_diag_dump_icsk+0x55b/0x1f80 net/ipv4/inet_diag.c:1061 + __inet_diag_dump+0x211/0x3a0 net/ipv4/inet_diag.c:1263 + inet_diag_dump_compat+0x1c1/0x2d0 net/ipv4/inet_diag.c:1371 + netlink_dump+0x59b/0xc80 net/netlink/af_netlink.c:2264 + __netlink_dump_start+0x5df/0x790 net/netlink/af_netlink.c:2370 + netlink_dump_start include/linux/netlink.h:338 [inline] + inet_diag_rcv_msg_compat+0x209/0x4c0 net/ipv4/inet_diag.c:1405 + sock_diag_rcv_msg+0xe7/0x410 + netlink_rcv_skb+0x1e3/0x430 net/netlink/af_netlink.c:2543 + sock_diag_rcv+0x2a/0x40 net/core/sock_diag.c:280 + netlink_unicast_kernel net/netlink/af_netlink.c:1341 [inline] + netlink_unicast+0x7ea/0x980 net/netlink/af_netlink.c:1367 + netlink_sendmsg+0xa3b/0xd70 net/netlink/af_netlink.c:1908 + sock_sendmsg_nosec net/socket.c:730 [inline] + __sock_sendmsg+0x221/0x270 net/socket.c:745 + ____sys_sendmsg+0x525/0x7d0 net/socket.c:2584 + ___sys_sendmsg net/socket.c:2638 [inline] + __sys_sendmsg+0x2b0/0x3a0 net/socket.c:2667 + do_syscall_64+0xf9/0x240 + entry_SYSCALL_64_after_hwframe+0x6f/0x77 + +As noted by Eric we can break the lock dependency chain avoid +dumping any extended info for the mptcp subflow listener: +nothing actually useful is presented there. + +Fixes: b8adb69a7d29 ("mptcp: fix lockless access in subflow ULP diag") +Cc: stable@vger.kernel.org +Reported-by: Eric Dumazet +Closes: https://lore.kernel.org/netdev/CANn89iJ=Oecw6OZDwmSYc9HJKQ_G32uN11L+oUcMu+TOD5Xiaw@mail.gmail.com/ +Suggested-by: Eric Dumazet +Signed-off-by: Paolo Abeni +Reviewed-by: Matthieu Baerts (NGI0) +Signed-off-by: Matthieu Baerts (NGI0) +Link: https://lore.kernel.org/r/20240223-upstream-net-20240223-misc-fixes-v1-9-162e87e48497@kernel.org +Signed-off-by: Jakub Kicinski +Signed-off-by: Greg Kroah-Hartman +--- + net/mptcp/diag.c | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/net/mptcp/diag.c ++++ b/net/mptcp/diag.c +@@ -21,6 +21,9 @@ static int subflow_get_info(struct sock + bool slow; + int err; + ++ if (inet_sk_state_load(sk) == TCP_LISTEN) ++ return 0; ++ + start = nla_nest_start_noflag(skb, INET_ULP_INFO_MPTCP); + if (!start) + return -EMSGSIZE; diff --git a/queue-5.15/mptcp-fix-snd_wnd-initialization-for-passive-socket.patch b/queue-5.15/mptcp-fix-snd_wnd-initialization-for-passive-socket.patch new file mode 100644 index 00000000000..e9e7fcd6e08 --- /dev/null +++ b/queue-5.15/mptcp-fix-snd_wnd-initialization-for-passive-socket.patch @@ -0,0 +1,35 @@ +From adf1bb78dab55e36d4d557aa2fb446ebcfe9e5ce Mon Sep 17 00:00:00 2001 +From: Paolo Abeni +Date: Fri, 23 Feb 2024 17:14:15 +0100 +Subject: mptcp: fix snd_wnd initialization for passive socket + +From: Paolo Abeni + +commit adf1bb78dab55e36d4d557aa2fb446ebcfe9e5ce upstream. + +Such value should be inherited from the first subflow, but +passive sockets always used 'rsk_rcv_wnd'. + +Fixes: 6f8a612a33e4 ("mptcp: keep track of advertised windows right edge") +Cc: stable@vger.kernel.org +Signed-off-by: Paolo Abeni +Reviewed-by: Mat Martineau +Signed-off-by: Matthieu Baerts (NGI0) +Link: https://lore.kernel.org/r/20240223-upstream-net-20240223-misc-fixes-v1-5-162e87e48497@kernel.org +Signed-off-by: Jakub Kicinski +Signed-off-by: Greg Kroah-Hartman +--- + net/mptcp/protocol.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/net/mptcp/protocol.c ++++ b/net/mptcp/protocol.c +@@ -2889,7 +2889,7 @@ struct sock *mptcp_sk_clone(const struct + msk->write_seq = subflow_req->idsn + 1; + msk->snd_nxt = msk->write_seq; + msk->snd_una = msk->write_seq; +- msk->wnd_end = msk->snd_nxt + req->rsk_rcv_wnd; ++ msk->wnd_end = msk->snd_nxt + tcp_sk(ssk)->snd_wnd; + msk->setsockopt_seq = mptcp_sk(sk)->setsockopt_seq; + + if (mp_opt->suboptions & OPTIONS_MPTCP_MPC) { diff --git a/queue-5.15/mptcp-push-at-dss-boundaries.patch b/queue-5.15/mptcp-push-at-dss-boundaries.patch new file mode 100644 index 00000000000..9c5b02cee9d --- /dev/null +++ b/queue-5.15/mptcp-push-at-dss-boundaries.patch @@ -0,0 +1,41 @@ +From b9cd26f640a308ea314ad23532de9a8592cd09d2 Mon Sep 17 00:00:00 2001 +From: Paolo Abeni +Date: Fri, 23 Feb 2024 17:14:14 +0100 +Subject: mptcp: push at DSS boundaries + +From: Paolo Abeni + +commit b9cd26f640a308ea314ad23532de9a8592cd09d2 upstream. + +when inserting not contiguous data in the subflow write queue, +the protocol creates a new skb and prevent the TCP stack from +merging it later with already queued skbs by setting the EOR marker. + +Still no push flag is explicitly set at the end of previous GSO +packet, making the aggregation on the receiver side sub-optimal - +and packetdrill self-tests less predictable. + +Explicitly mark the end of not contiguous DSS with the push flag. + +Fixes: 6d0060f600ad ("mptcp: Write MPTCP DSS headers to outgoing data packets") +Cc: stable@vger.kernel.org +Signed-off-by: Paolo Abeni +Reviewed-by: Mat Martineau +Signed-off-by: Matthieu Baerts (NGI0) +Link: https://lore.kernel.org/r/20240223-upstream-net-20240223-misc-fixes-v1-4-162e87e48497@kernel.org +Signed-off-by: Jakub Kicinski +Signed-off-by: Greg Kroah-Hartman +--- + net/mptcp/protocol.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/net/mptcp/protocol.c ++++ b/net/mptcp/protocol.c +@@ -1350,6 +1350,7 @@ static int mptcp_sendmsg_frag(struct soc + mpext = skb_ext_find(skb, SKB_EXT_MPTCP); + if (!mptcp_skb_can_collapse_to(data_seq, skb, mpext)) { + TCP_SKB_CB(skb)->eor = 1; ++ tcp_mark_push(tcp_sk(ssk), skb); + goto alloc_skb; + } + diff --git a/queue-5.15/series b/queue-5.15/series index 05ff16a30c7..3990b993b8a 100644 --- a/queue-5.15/series +++ b/queue-5.15/series @@ -66,3 +66,6 @@ selftests-mptcp-add-missing-kconfig-for-nf-filter.patch selftests-mptcp-add-missing-kconfig-for-nf-filter-in-v6.patch mptcp-clean-up-harmless-false-expressions.patch mptcp-add-needs_id-for-netlink-appending-addr.patch +mptcp-push-at-dss-boundaries.patch +mptcp-fix-snd_wnd-initialization-for-passive-socket.patch +mptcp-fix-possible-deadlock-in-subflow-diag.patch -- 2.47.3