public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Martin KaFai Lau <martin.lau@linux•dev>
To: Michal Luczaj <mhal@rbox•co>, Kuniyuki Iwashima <kuniyu@google•com>
Cc: John Fastabend <john.fastabend@gmail•com>,
	Jakub Sitnicki <jakub@cloudflare•com>,
	"David S. Miller" <davem@davemloft•net>,
	Eric Dumazet <edumazet@google•com>,
	Jakub Kicinski <kuba@kernel•org>, Paolo Abeni <pabeni@redhat•com>,
	Simon Horman <horms@kernel•org>,
	Daniel Borkmann <daniel@iogearbox•net>,
	Willem de Bruijn <willemb@google•com>,
	Cong Wang <cong.wang@bytedance•com>,
	Alexei Starovoitov <ast@kernel•org>, Yonghong Song <yhs@fb•com>,
	Andrii Nakryiko <andrii@kernel•org>,
	Eduard Zingerman <eddyz87@gmail•com>, Song Liu <song@kernel•org>,
	Yonghong Song <yonghong.song@linux•dev>,
	KP Singh <kpsingh@kernel•org>,
	Stanislav Fomichev <sdf@fomichev•me>, Hao Luo <haoluo@google•com>,
	Jiri Olsa <jolsa@kernel•org>, Shuah Khan <shuah@kernel•org>,
	netdev@vger•kernel.org, bpf@vger•kernel.org,
	linux-kernel@vger•kernel.org, linux-kselftest@vger•kernel.org
Subject: Re: [PATCH bpf v2 3/4] bpf, sockmap: Adapt for the af_unix-specific lock
Date: Mon, 9 Feb 2026 12:17:17 -0800	[thread overview]
Message-ID: <a2f2c260-38e8-4ba3-8655-cffbee046259@linux.dev> (raw)
In-Reply-To: <c4eaead1-ad69-42f0-9699-5f2d555a7693@rbox.co>



On 2/8/26 9:14 AM, Michal Luczaj wrote:
> On 2/7/26 23:00, Kuniyuki Iwashima wrote:
>> On Sat, Feb 7, 2026 at 6:35 AM Michal Luczaj <mhal@rbox•co> wrote:
>>> This patch also happens to fix a deadlock that may occur when
>>> bpf_iter_unix_seq_show()'s lock_sock_fast() takes the fast path and the
>>> iter prog attempts to update a sockmap. Which ends up spinning at
>>> sock_map_update_elem()'s bh_lock_sock():
>>
>> Hmm.. this seems to be a more general problem for
>> bpf iter vs sockmap.  bpf_iter_{tcp,udp}_seq_show() also
>> hold lock_sock(),  where this patch's solution does not help.
>> We need to resolve this regardless of socket family.
> 
> I don't see any deadlocks there. Note that I've mentioned lock_sock_fast()
> fast path was a problem, not lock_sock().

For the tcp/udp, I think the bpf_iter should be fine: lock_sock() in 
seq_show and bh_lock_sock() in map_update. It seems redundant though.

 From looking at may_update_sockmap(), other bpf progs (e.g., tc) can do 
map_update also. On those paths, I am not sure why 
sock_map_update_elem() does not need to check "!sock_owned_by_user(sk)". 
If it is indeed an issue, it probably needs to be addressed separately.

It should also be helpful to be consistent with tcp/udp iter and use 
lock_sock() instead of lock_sock_fast() in bpf_iter_unix_seq_show().




  reply	other threads:[~2026-02-09 20:17 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-07 14:34 [PATCH bpf v2 0/4] bpf, sockmap: Fix af_unix null-ptr-deref in proto update Michal Luczaj
2026-02-07 14:34 ` [PATCH bpf v2 1/4] bpf, sockmap: Annotate af_unix sock::sk_state data-races Michal Luczaj
2026-02-07 14:34 ` [PATCH bpf v2 2/4] bpf, sockmap: Use sock_map_sk_{acquire,release}() where open-coded Michal Luczaj
2026-02-07 14:34 ` [PATCH bpf v2 3/4] bpf, sockmap: Adapt for the af_unix-specific lock Michal Luczaj
2026-02-07 22:00   ` Kuniyuki Iwashima
2026-02-08 17:14     ` Michal Luczaj
2026-02-09 20:17       ` Martin KaFai Lau [this message]
2026-02-11 10:02         ` Michal Luczaj
2026-02-11 13:24           ` Michal Luczaj
2026-02-23 21:43           ` Martin KaFai Lau
2026-02-24 15:28             ` Michal Luczaj
2026-03-03  1:51               ` Martin KaFai Lau
2026-03-05 23:35                 ` Michal Luczaj
2026-02-07 14:34 ` [PATCH bpf v2 4/4] selftests/bpf: Extend bpf_iter_unix to attempt deadlocking Michal Luczaj

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=a2f2c260-38e8-4ba3-8655-cffbee046259@linux.dev \
    --to=martin.lau@linux$(echo .)dev \
    --cc=andrii@kernel$(echo .)org \
    --cc=ast@kernel$(echo .)org \
    --cc=bpf@vger$(echo .)kernel.org \
    --cc=cong.wang@bytedance$(echo .)com \
    --cc=daniel@iogearbox$(echo .)net \
    --cc=davem@davemloft$(echo .)net \
    --cc=eddyz87@gmail$(echo .)com \
    --cc=edumazet@google$(echo .)com \
    --cc=haoluo@google$(echo .)com \
    --cc=horms@kernel$(echo .)org \
    --cc=jakub@cloudflare$(echo .)com \
    --cc=john.fastabend@gmail$(echo .)com \
    --cc=jolsa@kernel$(echo .)org \
    --cc=kpsingh@kernel$(echo .)org \
    --cc=kuba@kernel$(echo .)org \
    --cc=kuniyu@google$(echo .)com \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=linux-kselftest@vger$(echo .)kernel.org \
    --cc=mhal@rbox$(echo .)co \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=pabeni@redhat$(echo .)com \
    --cc=sdf@fomichev$(echo .)me \
    --cc=shuah@kernel$(echo .)org \
    --cc=song@kernel$(echo .)org \
    --cc=willemb@google$(echo .)com \
    --cc=yhs@fb$(echo .)com \
    --cc=yonghong.song@linux$(echo .)dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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