BPF List
 help / color / mirror / Atom feed
From: Alan Maguire <alan.maguire@oracle.com>
To: Jiri Olsa <jolsa@kernel.org>, Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>
Cc: bpf@vger.kernel.org, Martin KaFai Lau <kafai@fb.com>,
	Song Liu <songliubraving@fb.com>, Yonghong Song <yhs@fb.com>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@chromium.org>,
	Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>,
	Oleg Nesterov <oleg@redhat.com>
Subject: Re: [RFC bpf-next 1/2] bpf: Fail uprobe multi link with negative offset
Date: Wed, 13 Dec 2023 17:51:20 +0000	[thread overview]
Message-ID: <c13eddee-f61d-b209-11c4-5ea5a9f389da@oracle.com> (raw)
In-Reply-To: <20231213141234.1210389-1-jolsa@kernel.org>

On 13/12/2023 14:12, Jiri Olsa wrote:
> Currently the __uprobe_register will return 0 (success) when called with
> negative offset. The reason is that the call to register_for_each_vma and
> then build_map_info won't return error for negative offset. They just won't
> do anything - no matching vma is found so there's no registered breakpoint
> for the uprobe.
> 
> I don't think we can change the behaviour of __uprobe_register and fail
> for negative uprobe offset, because apps might depend on that already.
> 

just my view, but since passing negative offsets never made sense, I
wouldn't be as worried about breaking existing consumers. Regardless of
what a user thought would happen passing a negative value, nothing did,
so that can't have been their intent.

> But I think we can still make the change and check for it on bpf multi
> link syscall level.
> 
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>

Reviewed-by: Alan Maguire <alan.maguire@oracle.com>
> ---
>  kernel/trace/bpf_trace.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
> index 774cf476a892..0dbf8d9b3ace 100644
> --- a/kernel/trace/bpf_trace.c
> +++ b/kernel/trace/bpf_trace.c
> @@ -3397,6 +3397,11 @@ int bpf_uprobe_multi_link_attach(const union bpf_attr *attr, struct bpf_prog *pr
>  			goto error_free;
>  		}
>  
> +		if (uprobes[i].offset < 0) {
> +			err = -EINVAL;
> +			goto error_free;
> +		}
> +
>  		uprobes[i].link = link;
>  
>  		if (flags & BPF_F_UPROBE_MULTI_RETURN)

  parent reply	other threads:[~2023-12-13 17:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-13 14:12 [RFC bpf-next 1/2] bpf: Fail uprobe multi link with negative offset Jiri Olsa
2023-12-13 14:12 ` [RFC bpf-next 2/2] selftests/bpf: Add uprobe multi fail test Jiri Olsa
2023-12-13 18:08   ` Alan Maguire
2023-12-14  9:15     ` Jiri Olsa
2023-12-13 17:51 ` Alan Maguire [this message]
2023-12-13 23:35 ` [RFC bpf-next 1/2] bpf: Fail uprobe multi link with negative offset Song Liu
2023-12-14  9:22   ` Jiri Olsa
2023-12-13 23:43 ` Andrii Nakryiko
2023-12-14  9:07   ` Jiri Olsa
2023-12-14 23:28     ` Andrii Nakryiko

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=c13eddee-f61d-b209-11c4-5ea5a9f389da@oracle.com \
    --to=alan.maguire@oracle.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kafai@fb.com \
    --cc=kpsingh@chromium.org \
    --cc=oleg@redhat.com \
    --cc=sdf@google.com \
    --cc=songliubraving@fb.com \
    --cc=yhs@fb.com \
    /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