mirror-linux/net
Gang Yan 443041deb5 mptcp: fix NULL pointer in can_accept_new_subflow
When testing valkey benchmark tool with MPTCP, the kernel panics in
'mptcp_can_accept_new_subflow' because subflow_req->msk is NULL.

Call trace:

  mptcp_can_accept_new_subflow (./net/mptcp/subflow.c:63 (discriminator 4)) (P)
  subflow_syn_recv_sock (./net/mptcp/subflow.c:854)
  tcp_check_req (./net/ipv4/tcp_minisocks.c:863)
  tcp_v4_rcv (./net/ipv4/tcp_ipv4.c:2268)
  ip_protocol_deliver_rcu (./net/ipv4/ip_input.c:207)
  ip_local_deliver_finish (./net/ipv4/ip_input.c:234)
  ip_local_deliver (./net/ipv4/ip_input.c:254)
  ip_rcv_finish (./net/ipv4/ip_input.c:449)
  ...

According to the debug log, the same req received two SYN-ACK in a very
short time, very likely because the client retransmits the syn ack due
to multiple reasons.

Even if the packets are transmitted with a relevant time interval, they
can be processed by the server on different CPUs concurrently). The
'subflow_req->msk' ownership is transferred to the subflow the first,
and there will be a risk of a null pointer dereference here.

This patch fixes this issue by moving the 'subflow_req->msk' under the
`own_req == true` conditional.

Note that the !msk check in subflow_hmac_valid() can be dropped, because
the same check already exists under the own_req mpj branch where the
code has been moved to.

Fixes: 9466a1cceb ("mptcp: enable JOIN requests even if cookies are in use")
Cc: stable@vger.kernel.org
Suggested-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Gang Yan <yangang@kylinos.cn>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Link: https://patch.msgid.link/20250328-net-mptcp-misc-fixes-6-15-v1-1-34161a482a7f@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2025-03-31 16:52:39 -07:00
..
6lowpan
9p
802 net: 802: LLC+SNAP OID:PID lookup on start of skb data 2025-01-04 08:06:24 -08:00
8021q net: vlan: don't propagate flags on open 2025-03-20 09:57:37 +01:00
appletalk net: appletalk: Drop aarp_send_probe_phase1() 2025-01-20 10:08:19 +00:00
atm atm: Fix NULL pointer dereference 2025-03-25 13:54:36 -07:00
ax25 ax25: Remove broken autobind 2025-03-24 10:26:53 +00:00
batman-adv Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2025-03-20 21:38:01 +01:00
bluetooth Bluetooth: MGMT: Add LL Privacy Setting 2025-03-25 15:22:49 -04:00
bpf bpf, test_run: Fix use-after-free issue in eth_skb_pkt_type() 2025-01-29 08:51:51 -08:00
bridge Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2025-03-26 09:32:10 -07:00
caif rtnetlink: Pack newlink() params into struct 2025-02-21 15:28:02 -08:00
can Networking changes for 6.15. 2025-03-26 21:48:21 -07:00
ceph
core net: fix use-after-free in the netdev_nl_sock_priv_destroy() 2025-03-31 16:44:49 -07:00
dcb
dccp tcp/dccp: remove icsk->icsk_ack.timeout 2025-03-25 10:34:33 -07:00
devlink devlink: fix xa_alloc_cyclic() error handling 2025-03-19 09:57:36 +00:00
dns_resolver
dsa net: move misc netdev_lock flavors to a separate header 2025-03-08 09:06:50 -08:00
ethernet
ethtool net-timestamp: COMPLETION timestamp on packet tx completion 2025-03-25 12:48:05 -04:00
handshake
hsr net: hsr: Add KUnit test for PRP 2025-03-13 10:04:22 +01:00
ieee802154 inet: frags: save a pair of atomic operations in reassembly 2025-03-18 13:18:36 +01:00
ife
ipv4 Networking changes for 6.15. 2025-03-26 21:48:21 -07:00
ipv6 tcp/dccp: remove icsk->icsk_timeout 2025-03-25 10:34:33 -07:00
iucv
kcm
key
l2tp net: move misc netdev_lock flavors to a separate header 2025-03-08 09:06:50 -08:00
l3mdev
lapb
llc llc: do not use skb_get() before dev_queue_xmit() 2025-03-03 14:00:04 +00:00
mac80211 More features for 6.15, major changes: 2025-03-25 08:04:13 -07:00
mac802154 mac802154: Switch to use hrtimer_setup() 2025-02-18 10:35:44 +01:00
mctp net: mctp: unshare packets when reassembling 2025-03-11 13:12:19 +01:00
mpls
mptcp mptcp: fix NULL pointer in can_accept_new_subflow 2025-03-31 16:52:39 -07:00
ncsi net/ncsi: use dev_set_mac_address() for Get MC MAC Address handling 2025-01-27 09:20:07 +00:00
netfilter netfilter pull request 25-03-23 2025-03-25 08:29:13 -07:00
netlabel net: corrections for security_secid_to_secctx returns 2025-01-04 22:11:22 -05:00
netlink Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2025-02-27 10:20:58 -08:00
netrom netrom: check buffer length before accessing it 2024-12-23 10:04:55 -08:00
nfc nfc: hci: Remove unused nfc_llc_unregister 2025-02-19 19:04:26 -08:00
nsh
openvswitch net: openvswitch: fix kernel-doc warnings in internal headers 2025-03-24 09:30:21 -07:00
packet net: initialize mark in sockcm_init 2025-02-18 18:27:19 -08:00
phonet
psample psample: adjust size if rate_as_probability is set 2024-12-18 19:23:04 -08:00
qrtr
rds Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2025-02-27 10:20:58 -08:00
rfkill net: rfkill: gpio: allow booting in blocked state 2025-02-11 11:55:55 +01:00
rose net: rose: lock the socket in rose_bind() 2025-02-04 14:03:58 -08:00
rxrpc afs: Use the per-peer app data provided by rxrpc 2025-03-10 09:47:15 +00:00
sched net: move replay logic to tc_modify_qdisc 2025-03-27 10:18:48 -07:00
sctp net: use sock_kmemdup for ip_options 2025-03-03 17:16:34 -08:00
shaper net: add netdev_lock() / netdev_unlock() helpers 2025-01-15 19:13:33 -08:00
smc net/smc: use the correct ndev to find pnetid by pnetid table 2025-03-14 12:54:40 +00:00
strparser strparser: Add read_sock callback 2025-01-29 13:32:08 -08:00
sunrpc Summary 2025-03-26 21:02:05 -07:00
switchdev net: switchdev: Convert blocking notification chain to a raw one 2025-03-11 11:30:28 +01:00
tipc tipc: Reduce scope for the variable “fdefq” in tipc_link_tnl_prepare() 2025-03-04 17:19:49 -08:00
tls tcp: move icsk_clean_acked to a better location 2025-03-24 09:55:18 -07:00
unix unix: fix up for "apparmor: add fine grained af_unix mediation" 2025-03-26 09:31:18 -07:00
vmw_vsock vsock/bpf: Warn on socket without transport 2025-02-18 12:00:01 +01:00
wireless wifi: nl80211: re-enable multi-link reconfiguration 2025-03-18 14:52:11 +01:00
x25
xdp Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2025-03-20 21:38:01 +01:00
xfrm Networking changes for 6.15. 2025-03-26 21:48:21 -07:00
Kconfig
Kconfig.debug
Makefile
compat.c
devres.c
socket.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2025-03-26 09:32:10 -07:00
sysctl_net.c