mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Michal Luczaj <mhal@rbox.co>
To: bot+bpf-ci@kernel.org, ast@kernel.org, daniel@iogearbox.net,
	andrii@kernel.org, eddyz87@gmail.com, memxor@gmail.com,
	martin.lau@linux.dev, song@kernel.org, yonghong.song@linux.dev,
	jolsa@kernel.org, emil@etsalapatis.com, john.fastabend@gmail.com,
	sdf@fomichev.me, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
	kuniyu@google.com, willemb@google.com, jakub@cloudflare.com,
	jiayuan.chen@linux.dev, joe@wand.net.nz
Cc: bpf@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, martin.lau@kernel.org,
	clm@meta.com, ihor.solodrai@linux.dev
Subject: Re: [PATCH bpf v2 1/2] bpf: Extract shared reqsk-to-listener upgrade
Date: Mon, 3 Aug 2026 12:43:21 +0200	[thread overview]
Message-ID: <329fffdc-9e4b-4812-8140-e0bf947e4ac6@rbox.co> (raw)
In-Reply-To: <43cad9ddcd7b1c7541a179444b27cd6b40fdf32f7aabfff2080c12bfc945dc94@mail.kernel.org>

On 8/3/26 11:44, bot+bpf-ci@kernel.org wrote:
>> diff --git a/net/core/filter.c b/net/core/filter.c
>> index 11bb0d236822..fede810ef37f 100644
>> --- a/net/core/filter.c
>> +++ b/net/core/filter.c
>> @@ -7079,6 +7079,28 @@ __bpf_skc_lookup(struct sk_buff *skb, struct bpf_sock_tuple *tuple, u32 len,
>>  	return sk;
>>  }
>>
>> +static struct sock *
>> +bpf_sk_lookup_full_sk(struct sock *sk)
>> +{
> 
> This isn't a bug, but since this helper only converts a reqsk to its
> listener rather than performing a lookup, would a name outside the
> bpf_sk_lookup_* family - say sk_lookup_full_sk() or
> bpf_reqsk_to_listener() - read more clearly next to
> bpf_sk_lookup_tcp()/bpf_sk_lookup_udp() and struct bpf_sk_lookup?
> 
> The bpf_sk_lookup_ prefix in this file already denotes the BPF helper family
> (bpf_sk_lookup_tcp(), bpf_sk_lookup_udp(), bpf_sk_lookup_assign(),
> bpf_sk_lookup_enabled) and the UAPI context type struct bpf_sk_lookup /
> struct bpf_sk_lookup_kern. Sitting about 20 lines above bpf_sk_lookup()
> itself, the name reads like another lookup entry point rather than a
> reqsk-to-listener conversion.

I've meant it to be a bpf-lookup helper, not a bpf lookup-helper. So yeah,
I'm happy to change it to something more appropriate. sk_lookup_full_sk() then?

>> +	struct sock *sk2 = sk_to_full_sk(sk);
>> +
>> +	/*
>> +	 * sk_to_full_sk() may return sk->rsk_listener, make sure the original
>> +	 * sk sock refcnt is decremented to prevent a request_sock leak.
>> +	 */
>> +	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;
>> +		}
>> +		sk = sk2;
>> +	}
>> +
>> +	return sk;
>> +}
> 
> [ ... ]

  reply	other threads:[~2026-08-03 10:43 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-03  9:00 [PATCH bpf v2 0/2] bpf: Fix socket leaks around connect(AF_UNSPEC)+listen() Michal Luczaj
2026-08-03  9:00 ` [PATCH bpf v2 1/2] bpf: Extract shared reqsk-to-listener upgrade Michal Luczaj
2026-08-03  9:44   ` bot+bpf-ci
2026-08-03 10:43     ` Michal Luczaj [this message]
2026-08-04 10:07   ` Jakub Sitnicki
2026-08-03  9:00 ` [PATCH bpf v2 2/2] bpf: Unconditionally take socket references in lookup helpers Michal Luczaj
2026-08-04  1:58   ` Kuniyuki Iwashima
2026-08-05 15:00     ` Michal Luczaj
2026-08-18 11:56       ` Michal Luczaj
2026-08-04 10:14   ` Jakub Sitnicki
2026-08-05  4:01     ` Kuniyuki Iwashima
2026-08-05 14:56       ` Jakub Sitnicki
2026-08-13 12:49         ` Michal Luczaj
2026-08-05 15:00     ` Michal Luczaj
2026-08-05 18:27       ` Jakub Sitnicki

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=329fffdc-9e4b-4812-8140-e0bf947e4ac6@rbox.co \
    --to=mhal@rbox.co \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bot+bpf-ci@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=clm@meta.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=eddyz87@gmail.com \
    --cc=edumazet@google.com \
    --cc=emil@etsalapatis.com \
    --cc=horms@kernel.org \
    --cc=ihor.solodrai@linux.dev \
    --cc=jakub@cloudflare.com \
    --cc=jiayuan.chen@linux.dev \
    --cc=joe@wand.net.nz \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf@fomichev.me \
    --cc=song@kernel.org \
    --cc=willemb@google.com \
    --cc=yonghong.song@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®