Re: [PATCH bpf 3/3] bpf: Unconditionally take socket references in lookup helpers

From: Michal Luczaj

Date: Thu Jul 30 2026 - 08:35:51 EST


On 7/29/26 22:32, Emil Tsalapatis wrote:
> On Thu Jul 23, 2026 at 7:33 AM EDT, Michal Luczaj wrote:
>> Lookup helpers gate whether to acquire a socket reference on
>> sk_is_refcounted(), a check re-evaluated at release. An established socket
>> refcounted at acquire time can gain SOCK_RCU_FREE via
>> connect(AF_UNSPEC)+listen() before release runs; the release-side re-check
>> then reads sk_is_refcounted() == false and skips the put. The reference
>> leaks.
>>
>> Make acquire and release unconditional and symmetric: always take a
>> reference, always put it. Adapt sk_select_reuseport().
>
> Reviewed-by: Emil Tsalapatis <emil@xxxxxxxxxxxxxxx>

Thanks!

> The bot's concern about the comment style is obviously invalid here.

Are the prompts incorrect?
https://github.com/masoncl/review-prompts/blob/59469708305eca305cbd9eb94e5aa0ee3627529c/kernel/subsystem/bpf.md#bpf-comment-style

Michal