mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Michal Luczaj <mhal@rbox.co>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Eduard Zingerman <eddyz87@gmail.com>,
	Kumar Kartikeya Dwivedi <memxor@gmail.com>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	Song Liu <song@kernel.org>,
	Yonghong Song <yonghong.song@linux.dev>,
	Jiri Olsa <jolsa@kernel.org>,
	Emil Tsalapatis <emil@etsalapatis.com>,
	Ihor Solodrai <ihor.solodrai@linux.dev>,
	Shuah Khan <shuah@kernel.org>,
	John Fastabend <john.fastabend@gmail.com>,
	Lorenz Bauer <lmb@cloudflare.com>
Cc: bpf@vger.kernel.org, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org, Sashiko <sashiko-bot@kernel.org>,
	Jakub Sitnicki <jakub@cloudflare.com>
Subject: Re: [PATCH bpf-next 2/3] bpf, sockmap: Restrict iter-context sockmap updates to iter/sockmap
Date: Wed, 21 Oct 2026 13:12:34 +0200	[thread overview]
Message-ID: <0bcebb4f-4b36-4f8e-a3cd-1eb0455081a8@rbox.co> (raw)
In-Reply-To: <DM92JCFA4X4U.30MTDH0KCPTJ@gmail.com>

On 10/19/26 21:40, Alexei Starovoitov wrote:
> On Mon, Oct 19, 2026 at 08:20 AM Michal Luczaj <mhal@rbox.co> wrote:
>> On 10/17/26 01:52, Alexei Starovoitov wrote:
>>> unix_state_lock() in bpf_iter_unix_seq_show() was added only for
>>> unix_stream_bpf_update_proto() called from the iter prog.
>>> iter/unix cannot get there anymore.
>>> can we drop it ? can be a follow up...
>>
>> So we don't care about having a stable socket state while iterating? Which
>> is the case for iter/sockmap, but is unlike iter/{tcp,udp}.
> 
> Not sure. Is there a value?

Isn't it (currently) necessary for iter/{unix,sockmap} dgram peer
disappearing on connect(AF_UNSPEC)?

But, if I understand correctly, the removal of plain PTR_TO_BTF_ID will
make pointers like `peer` inaccessible to helpers. And we just accept progs
have to deal with potentially stale data, e.g. the value of sk_shutdown.

>>> Should we restrict it to ctx->sk somehow?
>>
>> I recall a discussion about having BPF helpers accept only trusted
>> pointers:
>> https://lore.kernel.org/bpf/CAADnVQK_93g_KkNFYXSr8ZvA1fYh4hoFRJCJFPS-zs4ox0HhAA@mail.gmail.com/
>> Restricting only iter/unix seems better?
> 
> we just discussed at bpf sync meeting that it's time to
> finally remove plain PTR_TO_BTF_ID.
> Otherwise we keep hitting this bug everywhere.
> 
> in the meantime can we do it for this one arg ?
> Mark ctx->sk as PTR_TRUSTED in sock_map_iter_reg
> like iter/tcp and iter/udp do ?

Ah, sure. So the same bit for unix_reg_info left for later?

I've noticed commit 7cc639dc45c5 ("bpf: Don't take an extension for an
iterator program") got merged. Should I post v2 with the env->prog->type
check dropped or you guys don't want to restrict iters anymore?


  reply	other threads:[~2026-10-21 11:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-16 21:09 [PATCH bpf-next 0/3] bpf, sockmap: Restrict iter-context sockmap updates to sockmap iterators Michal Luczaj
2026-10-16 21:09 ` [PATCH bpf-next 1/3] selftests/bpf: Remove sockmap update from bpf_iter_unix Michal Luczaj
2026-10-16 21:09 ` [PATCH bpf-next 2/3] bpf, sockmap: Restrict iter-context sockmap updates to iter/sockmap Michal Luczaj
2026-10-16 23:52   ` Alexei Starovoitov
2026-10-19 15:20     ` Michal Luczaj
2026-10-19 19:40       ` Alexei Starovoitov
2026-10-21 11:12         ` Michal Luczaj [this message]
2026-10-19 11:16   ` Jakub Sitnicki
2026-10-19 15:20     ` Michal Luczaj
2026-10-16 21:09 ` [PATCH bpf-next 3/3] selftests/bpf: Add negative test for sockmap update from non-sockmap iter 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=0bcebb4f-4b36-4f8e-a3cd-1eb0455081a8@rbox.co \
    --to=mhal@rbox.co \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=emil@etsalapatis.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=jakub@cloudflare.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=lmb@cloudflare.com \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=sashiko-bot@kernel.org \
    --cc=shuah@kernel.org \
    --cc=song@kernel.org \
    --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®