When tcp_mtu_probe() creates a new MTU probe, it allocates a new skb with tcp_stream_alloc_skb() and clones payload to it with tcp_clone_payload(). However, it does not clone uarg nor propagate skb->unreadable. As a result, SO_EE_ORIGIN_ZEROCOPY notification could be sent too early while the new skb references the data, or devmem skb could be read wrongly (e.g. tcpdump), triggering the splat below. [0] Let's propagate uarg and skb->unreadable to MTU probe skb. [0]: Oops: general protection fault, maybe for address 0xff414336b9cc4098: 0000 [#1] SMP NOPTI CPU: 214 UID: 0 PID: 16013 Comm: repro_devmem_ud Tainted: G 7.4.0-smp RIP: 0010:memcpy (arch/x86/lib/memcpy_64.S:37) Code: cc cc cc cc cc cc cc cc cc cc cc cc cc cc 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 f3 0f 1e fa 66 90 48 89 f8 48 89 d1 a4 c3 cc cc cc cc 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 RSP: 0018:ff65efe9e57b74f8 EFLAGS: 00010206 RAX: ff414336b9cc4098 RBX: 0000000000000520 RCX: 00000000000004ca RDX: 00000000000004ca RSI: 17fbf35600000000 RDI: ff414336b9cc4098 RBP: 000000000000003c R08: 00000000000004ca R09: ff414336b9cc4098 R10: 0000000000000562 R11: ffffffffac579060 R12: 00000000000004ca R13: ff414336b9cc4098 R14: 0000000000000000 R15: 00000000000004ca FS: 000000001aca7400(0000) GS:ff414375c8af2000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000000001acab000 CR3: 0000004106058001 CR4: 0000000000f71ef0 PKRU: 55555554 Call Trace: skb_copy_bits (net/core/skbuff.c:3084) tpacket_rcv (net/packet/af_packet.c:2442) dev_queue_xmit_nit (net/core/dev.c:2680) dev_hard_start_xmit (net/core/dev.c:4066) sch_direct_xmit (net/sched/sch_generic.c:411) __dev_queue_xmit (net/core/dev.c:4421) ip6_finish_output2 (include/linux/netdevice.h:3485 include/net/neighbour.h:538 include/net/neighbour.h:552 net/ipv6/ip6_output.c:138) ip6_finish_output (net/ipv6/ip6_output.c:?) ip6_output (include/linux/netfilter.h:314) ip6_xmit (include/net/dst.h:472) inet6_csk_xmit (net/ipv6/inet6_connection_sock.c:121) __tcp_transmit_skb (net/ipv4/tcp_output.c:1773) tcp_write_xmit (net/ipv4/tcp_output.c:1790 net/ipv4/tcp_output.c:2863 net/ipv4/tcp_output.c:3048) __tcp_push_pending_frames (net/ipv4/tcp_output.c:3309) tcp_sendmsg_locked (net/ipv4/tcp.c:1430) tcp_sendmsg (net/ipv4/tcp.c:1467) __sock_sendmsg (net/socket.c:800) ____sys_sendmsg (net/socket.c:2713) ___sys_sendmsg (net/socket.c:2770) __x64_sys_sendmsg (net/socket.c:2802) do_syscall_64 (arch/x86/entry/syscall_64.c:61 arch/x86/entry/syscall_64.c:89) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121) RIP: 0033:0x44ce22 Code: 18 41 8b 93 08 03 00 00 59 5e 48 83 f8 fc 75 1a 83 e2 39 83 fa 08 75 12 e8 1b ff ff ff 0f 1f 00 49 89 ca 48 8b 44 24 20 0f 05 <48> 83 c4 18 c3 66 0f 1f 84 00 00 00 00 00 48 83 ec 10 ff 74 24 18 RSP: 002b:00007ffc4bc96850 EFLAGS: 00000202 ORIG_RAX: 000000000000002e RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 000000000044ce22 RDX: 0000000004000000 RSI: 00007ffc4bc96990 RDI: 0000000000000008 RBP: 00007ffc4bc96908 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000202 R12: 0000000000000008 R13: 0000000000000005 R14: 0000000000003908 R15: 0000000000000004 Fixes: bd61848900bf ("net: devmem: Implement TX path") Fixes: 736013292e3c ("tcp: let tcp_mtu_probe() build headless packets") Signed-off-by: Kuniyuki Iwashima --- Found by LLM w/ packetdrill. --- net/ipv4/tcp_output.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index cf3ddc055d48..c45cccad5ef7 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -2660,7 +2660,8 @@ static bool tcp_can_coalesce_send_queue_head(struct sock *sk, int len) if (len <= skb->len) break; - if (tcp_has_tx_tstamp(skb) || !tcp_skb_can_collapse(skb, next)) + if (tcp_has_tx_tstamp(skb) || !tcp_skb_can_collapse(skb, next) || + skb_zcopy(skb) != skb_zcopy(next)) return false; len -= skb->len; @@ -2826,6 +2827,8 @@ static int tcp_mtu_probe(struct sock *sk) sk_mem_charge(sk, nskb->truesize); skb = tcp_send_head(sk); + nskb->unreadable = skb->unreadable; + skb_zcopy_set(nskb, skb_zcopy(skb), NULL); skb_copy_decrypted(nskb, skb); mptcp_skb_ext_copy(nskb, skb); -- 2.56.1.839.g22a8290db9-goog