From: Leon Hwang <leon.hwang@linux.dev>
To: Song Liu <song@kernel.org>
Cc: bpf@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
John Fastabend <john.fastabend@gmail.com>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <martin.lau@linux.dev>,
Eduard Zingerman <eddyz87@gmail.com>,
Kumar Kartikeya Dwivedi <memxor@gmail.com>,
Yonghong Song <yonghong.song@linux.dev>,
Jiri Olsa <jolsa@kernel.org>, Shuah Khan <shuah@kernel.org>,
Feng Yang <yangfeng@kylinos.cn>,
Toke Hoiland-Jorgensen <toke@redhat.com>,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
kernel-patches-bot@fb.com
Subject: Re: [PATCH bpf-next v2 1/2] bpf: Fix abuse of kprobe_write_ctx via freplace
Date: Mon, 30 Mar 2026 13:38:06 +0800 [thread overview]
Message-ID: <d19336f5-5373-483e-81e4-326aa9c7801a@linux.dev> (raw)
In-Reply-To: <CAPhsuW7vwp6pW5RntKC+Gbn5gTcVg3vsm6LVc-y2ssTeauZayA@mail.gmail.com>
On 28/3/26 05:39, Song Liu wrote:
> On Thu, Mar 26, 2026 at 7:17 AM Leon Hwang <leon.hwang@linux.dev> wrote:
[...]
>> @@ -3733,6 +3733,11 @@ static int bpf_tracing_prog_attach(struct bpf_prog *prog,
>> tr = prog->aux->dst_trampoline;
>> tgt_prog = prog->aux->dst_prog;
>> }
>> + if (prog->type == BPF_PROG_TYPE_EXT &&
>> + prog->aux->kprobe_write_ctx != tgt_prog->aux->kprobe_write_ctx) {
>> + err = -EINVAL;
>> + goto out_unlock;
>> + }
>
> This also blocks uprobe+freplace when prog and tgt_prog have different
> kprobe_write_ctx, right? Is this the expected behavior?
>
Intuitively, yes, this also blocks uprobe+freplace.
However, how can we distinguish uprobe/kprobe here?
At attach time, uprobe/kprobe is recognized by the target perf event
flags instead of BPF prog's expected_attach_type. Thus, we cannot infer
the use of prog by prog itself.
If we can distinguish them here, I'd like to do it.
Thanks,
Leon
next prev parent reply other threads:[~2026-03-30 5:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-26 14:17 [PATCH bpf-next v2 0/2] bpf: Fix abuse of kprobe_write_ctx via freplace Leon Hwang
2026-03-26 14:17 ` [PATCH bpf-next v2 1/2] " Leon Hwang
2026-03-27 21:39 ` Song Liu
2026-03-30 5:38 ` Leon Hwang [this message]
2026-03-30 9:28 ` Jiri Olsa
2026-03-26 14:17 ` [PATCH bpf-next v2 2/2] selftests/bpf: Add test to verify the fix of kprobe_write_ctx abuse Leon Hwang
2026-03-30 9:28 ` Jiri Olsa
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=d19336f5-5373-483e-81e4-326aa9c7801a@linux.dev \
--to=leon.hwang@linux.dev \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kernel-patches-bot@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=toke@redhat.com \
--cc=yangfeng@kylinos.cn \
--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