All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Geliang Tang" <geliang@kernel.org>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH] bpf, sockmap: Fix self-redirect copied_seq double-counting
Date: Sat, 29 Aug 2026 02:15:12 +0000	[thread overview]
Message-ID: <20260829021513.5F3491F000E9@smtp.kernel.org> (raw)
In-Reply-To: <b840c35fdfdf36e9fddedfa645b12699bc51aa34.1787968065.git.tanggeliang@kylinos.cn>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Unconditionally skipping tcp_eat_skb() for all self-redirects leaks sequence accounting (copied_seq) for egress redirects, synchronous redirect errors, and psock detach drops.
--

commit 8f3d3d5b6b4f4a55b1a1c00df40c2762471ef372
Author: Geliang Tang <geliang@kernel.org>

bpf, sockmap: Fix self-redirect copied_seq double-counting

This commit attempts to fix a double-counting issue in copied_seq when a
BPF stream_verdict program redirects an skb back to the same socket with
BPF_F_INGRESS. It does so by skipping tcp_eat_skb() for self-redirects.

> diff --git a/net/core/skmsg.c b/net/core/skmsg.c
> index 2521b643fa05d..5fa7b9639eefe 100644
> --- a/net/core/skmsg.c
> +++ b/net/core/skmsg.c
> @@ -1039,10 +1039,14 @@ static int sk_psock_verdict_apply(struct sk_psock *psock, struct sk_buff *skb,
[ ... ]
> -	case __SK_REDIRECT:
> -		tcp_eat_skb(psock->sk, skb);
> +	case __SK_REDIRECT: {
> +		struct sock *dst = skb_bpf_redirect_fetch(skb);
> +
> +		if (dst != psock->sk)
> +			tcp_eat_skb(psock->sk, skb);
>  		err = sk_psock_skb_redirect(psock, skb);
>  		break;
> +	}
>  	case __SK_DROP:

[Severity: High]
Does conditionally skipping tcp_eat_skb() here leak sequence accounting
(copied_seq) if the self-redirect encounters an error or is an egress
redirect?

If a BPF program returns SK_REDIRECT to its own socket, tcp_eat_skb() is
bypassed. However, if this is an egress redirect (without BPF_F_INGRESS),
the packet is sent out via skb_send_sock() instead of being read by
tcp_bpf_recvmsg_parser().

Similarly, if sk_psock_skb_redirect() fails synchronously (for example, if
!sk_psock_test_state(psock_other, SK_PSOCK_TX_ENABLED)) and calls
sock_drop(), the packet is also lost.

In both cases, the packet is permanently removed from the ingress path
without advancing copied_seq. Could this cause a permanent sequence
desynchronization that stalls the receive window and triggers a kernel
warning in tcp_recvmsg_locked()?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/b840c35fdfdf36e9fddedfa645b12699bc51aa34.1787968065.git.tanggeliang@kylinos.cn?part=1

  reply	other threads:[~2026-08-29  2:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-29  2:00 [PATCH] bpf, sockmap: Fix self-redirect copied_seq double-counting Geliang Tang
2026-08-29  2:15 ` sashiko-bot [this message]
2026-09-01 11:38 ` Jakub Sitnicki
2026-09-01 13:00   ` Jiayuan Chen
2026-09-04 14:11     ` Geliang Tang
  -- strict thread matches above, loose matches on Subject: below --
2026-09-04  3:03 netdev-bot+sashiko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260829021513.5F3491F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=geliang@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.