All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Junseo Lim" <zirajs7@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf v3 1/2] bpf, sockmap: settle sk_forward_alloc for strparser SK_PASS
Date: Mon, 17 Aug 2026 16:11:00 +0000	[thread overview]
Message-ID: <20260817161100.7A7391F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260817155009.232670-2-zirajs7@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

New issues:
- [Low] Multi-line comments added in the patch violate the BPF subsystem comment style.

Pre-existing issues:
- [High] Missing socket lock in sk_psock_skb_ingress() for cross-socket redirects causes sk_forward_alloc corruption.
--

--- Patch [1]: [PATCH bpf v3 1/2] bpf, sockmap: settle sk_forward_alloc for strparser SK_PASS ---
commit 74acfd67ff001cb4d8a5e9b0c6aaa8bfc595f145
Author: Junseo Lim <zirajs7@gmail.com>

bpf, sockmap: settle sk_forward_alloc for strparser SK_PASS

This commit addresses sk_forward_alloc deficits caused by strparser SK_PASS
queuing cloned skbs back to the same socket. It settles any deficit before
assigning receive ownership to unowned self-pass skbs.

> diff --git a/net/core/skmsg.c b/net/core/skmsg.c
> index 2521b643fa05d..347cb168f7491 100644
> --- a/net/core/skmsg.c
> +++ b/net/core/skmsg.c
[ ... ]
>  static int sk_psock_skb_ingress(struct sk_psock *psock, struct sk_buff *skb,
> -				u32 off, u32 len)
> +				u32 off, u32 len, bool settle_fwd_alloc)
>  {
>  	struct sock *sk = psock->sk;
>  	struct sk_msg *msg;
>  	int err;
>  
>  	if (unlikely(skb->sk == sk))
> -		return sk_psock_skb_ingress_self(psock, skb, off, len, true);
> +		return sk_psock_skb_ingress_self_backlog(psock, skb, off,
> +							 len, true,
> +							 settle_fwd_alloc);
>  	msg = sk_psock_create_ingress_msg(sk, skb);
>  	if (!msg)
>  		return -EAGAIN;

[Severity: High]
This is a pre-existing issue, but does this cross-socket redirect path modify
sk_forward_alloc without holding the socket lock?

When called asynchronously from the backlog workqueue:
sk_psock_backlog() -> sk_psock_handle_skb() -> sk_psock_skb_ingress()

If the skb is redirected to a different socket (where skb->sk does not match
the destination sk), it bypasses the self_backlog path which properly holds
lock_sock(sk). It then proceeds to call sk_psock_create_ingress_msg() and
skb_set_owner_r() without the target socket's lock. Since sk_forward_alloc
is updated via non-atomic operations, could concurrent updates to the target
socket corrupt sk_forward_alloc and cause page_counter underflows?

> @@ -618,34 +621,100 @@ static int sk_psock_skb_ingress(struct sk_psock *psock, struct sk_buff *skb,
[ ... ]
> +/* Puts an skb on the ingress queue for psock->sk.
> + *
> + * If the skb already has receive ownership for this socket, leave socket
> + * memory accounting untouched. Otherwise, before assigning receive ownership
> + * to an unowned strparser SK_PASS skb, settle any existing sk_forward_alloc
> + * deficit from earlier clone charges.
>   */
>  static int sk_psock_skb_ingress_self(struct sk_psock *psock, struct sk_buff *skb,

[Severity: Low]
This isn't a bug, but does this comment format follow the BPF subsystem
style?

The BPF subsystem uses the modern kernel multi-line comment style, which
requires the opening /* to be on its own line.

[ ... ]
> +	/* This is used in tcp_bpf_recvmsg_parser() to determine whether the
> +	 * data originates from the socket's own protocol stack. No need to
> +	 * refcount sk because msg's lifetime is bound to sk via the ingress_msg.
> +	 */
> +	msg->sk = sk;

[Severity: Low]
This isn't a bug, but should this multi-line comment also have its opening
/* on a separate line to match the subsystem conventions?

[ ... ]
> +static int sk_psock_skb_ingress_self_backlog(struct sk_psock *psock,
[ ... ]
> +	/* This is used in tcp_bpf_recvmsg_parser() to determine whether the
> +	 * data originates from the socket's own protocol stack. No need to
> +	 * refcount sk because msg's lifetime is bound to sk via the ingress_msg.
> +	 */
> +	msg->sk = sk;

[Severity: Low]
This isn't a bug, but is the opening /* on the same line missing the BPF
comment style requirement here as well?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260817155009.232670-1-zirajs7@gmail.com?part=1

  reply	other threads:[~2026-08-17 16:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-17 15:50 [PATCH bpf v3 0/2] bpf, sockmap: fix forward allocation accounting in strparser self-pass path Junseo Lim
2026-08-17 15:50 ` [PATCH bpf v3 1/2] bpf, sockmap: settle sk_forward_alloc for strparser SK_PASS Junseo Lim
2026-08-17 16:11   ` sashiko-bot [this message]
2026-08-17 17:13   ` bot+bpf-ci
2026-08-17 15:50 ` [PATCH bpf v3 2/2] selftests/bpf: Cover strparser self-pass forward allocation Junseo Lim
2026-08-17 16:52   ` bot+bpf-ci

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=20260817161100.7A7391F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=zirajs7@gmail.com \
    /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.