Re: [PATCH net] tcp: avoid NULL skb dereference in zerocopy receive with sockmap

From: Junyoung Jang

Date: Wed Nov 25 2026 - 05:03:29 EST


Thank you for the review and for pointing out the other paths affected
by a stale copied_seq.

I agree that this should be fixed on the sockmap side. I will look into
e5c6de5fa025 later today and prepare a v2. In the meantime, if the
sockmap maintainers have a preferred approach in mind, please let me
know.

On Wed, Nov 25, 2026 at 8:28 AM Alexei Starovoitov
<alexei.starovoitov@xxxxxxxxx> wrote:
>
> On Tue, Nov 24, 2026 at 03:02 PM Junyoung Jang <graypanda.inzag@xxxxxxxxx> wrote:
> > Check tcp_recv_skb() before using its result in both paths. Also stop
> > before advancing beyond the last skb in sk_receive_queue. Neither
> > check consumes data in the sockmap ingress queue.
>
> This should be fixed on bpf side. Other readers trust copied_seq too:
>
> reader with stale copied_seq
> --------------------------------- ----------------------------
> tcp_recvmsg_locked() WARN "TCP recvmsg seq # bug"
> tcp_read_sock() frees new skbs
> tcp_collapse() BUG_ON(offset < 0)
> tls_strp_load_anchor_with_queue() WARN_ON_ONCE(!first)
>
>
> pw-bot: cr