Re: [PATCH bpf 3/3] bpf: Unconditionally take socket references in lookup helpers
From: bot+bpf-ci
Date: Thu Jul 23 2026 - 11:37:35 EST
> diff --git a/net/core/filter.c b/net/core/filter.c
> index 403aba3ce891..4bc0b59668fa 100644
> --- a/net/core/filter.c
> +++ b/net/core/filter.c
> @@ -7027,6 +7027,13 @@ static struct sock *sk_lookup(struct net *net, struct bpf_sock_tuple *tuple,
> WARN_ONCE(1, "Found non-RCU, unreferenced socket!");
> sk = NULL;
> }
> +
> + /* Always take a reference, even if the lookup skipped one;
> + * bpf_sk_release() always puts one.
> + */
> + if (sk && !refcounted && !refcount_inc_not_zero(&sk->sk_refcnt))
> + sk = NULL;
> +
> return sk;
> }
The BPF subsystem guide specifies that multi-line comments under
net/core/filter.c should have the opening '/*' on its own line. Could these
comments follow that format?
[ ... ]
> @@ -7084,11 +7091,15 @@ bpf_sk_lookup_full_sk(struct sock *sk)
> */
> if (sk2 != sk) {
> sock_gen_put(sk);
> - /* Ensure there is no need to bump sk2 refcnt. */
> if (unlikely(sk2 && !sock_flag(sk2, SOCK_RCU_FREE))) {
> WARN_ONCE(1, "Found non-RCU, unreferenced socket!");
> return NULL;
> }
> + /* sk2 is RCU-free, but take a reference anyway;
> + * bpf_sk_release() puts.
> + */
> + if (sk2 && !refcount_inc_not_zero(&sk2->sk_refcnt))
> + sk2 = NULL;
> sk = sk2;
> }
The same multi-line comment style appears here as well.
[ ... ]
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/30016591832