Netdev List
 help / color / mirror / Atom feed
* [PATCH net 0/2] bpf, sockmap: fix copied_seq after partial TCP read
@ 2026-07-02 14:09 Dong Chenchen
  2026-07-02 14:09 ` [PATCH net 1/2] bpf, sockmap: account only unread data in tcp_eat_skb Dong Chenchen
  2026-07-02 14:09 ` [PATCH net 2/2] selftests/bpf: cover sockmap drop after partial TCP read Dong Chenchen
  0 siblings, 2 replies; 3+ messages in thread
From: Dong Chenchen @ 2026-07-02 14:09 UTC (permalink / raw)
  To: daniel, edumazet, ncardwell, kuniyu, john.fastabend, jakub,
	jiayuan.chen
  Cc: davem, kuba, pabeni, horms, zhangchangzhong, netdev, bpf,
	Dong Chenchen

tcp_eat_skb() assumes that an skb dequeued by the sockmap verdict path
has not previously been consumed. However, a socket can be inserted
into a sockmap after userspace has partially read the skb at the head of
its receive queue.

When new data invokes the verdict path, tcp_eat_skb() advances
copied_seq by the full skb length. This counts the already-read prefix
twice, moves copied_seq beyond rcv_nxt, and makes later native TCP reads
fail. TCP_ZEROCOPY_RECEIVE then triggers the tcp_recvmsg_locked()
sequence warning reported by syzbot.

TCP recvmsg seq # bug 2: copied AA28C633, seq AA28C601, rcvnxt AA28C602
WARNING: net/ipv4/tcp.c:2745 at tcp_recvmsg_locked
RIP: 0010:tcp_recvmsg_locked (net/ipv4/tcp.c:2745)
Call Trace:
<TASK>
tcp_zerocopy_receive (net/ipv4/tcp.c:1995 net/ipv4/tcp.c:2227)
do_tcp_getsockopt (net/ipv4/tcp.c:4771)
tcp_getsockopt (net/ipv4/tcp.c:4869)
do_sock_getsockopt (net/socket.c:2487)
__sys_getsockopt (net/socket.c:2518)
__x64_sys_getsockopt (net/socket.c:2525 net/socket.c:2522)
do_syscall_64 (arch/x86/entry/syscall_64.c:63)
entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121)

Patch 1 advances copied_seq to the skb end sequence and accounts only
the unread sequence-space delta during receive-buffer cleanup.

Patch 2 adds a deterministic regression test which reproduces the
tcp_recvmsg_locked() warning on the unpatched kernel.

Dong Chenchen (2):
  bpf, sockmap: account only unread data in tcp_eat_skb
  selftests/bpf: cover sockmap drop after partial TCP read

 net/ipv4/tcp_bpf.c                            |  9 ++-
 .../selftests/bpf/prog_tests/sockmap_basic.c  | 73 +++++++++++++++++++
 2 files changed, 78 insertions(+), 4 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-07-02 14:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-02 14:09 [PATCH net 0/2] bpf, sockmap: fix copied_seq after partial TCP read Dong Chenchen
2026-07-02 14:09 ` [PATCH net 1/2] bpf, sockmap: account only unread data in tcp_eat_skb Dong Chenchen
2026-07-02 14:09 ` [PATCH net 2/2] selftests/bpf: cover sockmap drop after partial TCP read Dong Chenchen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox