bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eduard Zingerman <eddyz87@gmail.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>,
	Arthur Fabre <afabre@cloudflare.com>
Cc: bpf <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>,
	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>,
	kernel-team	 <kernel-team@cloudflare.com>
Subject: Re: [PATCH bpf v2 2/2] selftests/bpf: Test r0 bounds after BPF to BPF call with abnormal return
Date: Mon, 16 Dec 2024 10:50:20 -0800	[thread overview]
Message-ID: <ed827bde40ab18be536add38c4237d949a752b2d.camel@gmail.com> (raw)
In-Reply-To: <CAADnVQ++HfXeobY2XoJfDWXZGrF4_kR5kOK7asFRpBN=qmXU8Q@mail.gmail.com>

On Mon, 2024-12-16 at 10:05 -0800, Alexei Starovoitov wrote:

[...]

> > Thanks for the review! Good point, I'll try to write them in C.
> > 
> > It might not be possible to do them both entirely: clang also doesn't
> > know that bpf_tail_call() can return, so it assumes the callee() will
> > return a constant r0. It sometimes optimizes branches / loads out
> > because of this.
>
> I wonder whether we should tell llvm that it's similar to longjmp()
> with __attribute__((noreturn)) or some other attribute.

GCC documents it as follows [1]:

  > The noreturn keyword tells the compiler to assume that fatal
  > cannot reaturn. It can then optimize without regard to what would
  > happen if fatal ever did return. This makes slightly better code.
  > More importantly, it helps avoid spurious warnings of
  > uninitialized variables.

But the bpf_tail_call could return if MAX_TAIL_CALL_CNT limit is exceeded,
or programs map index is out of bounds.

[1] https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/Common-Function-Attributes.html#index-noreturn-function-attribute




  reply	other threads:[~2024-12-16 18:50 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-13 21:27 [PATCH bpf v2 0/2] Don't trust r0 bounds after BPF to BPF calls with abnormal returns Arthur Fabre
2024-12-13 21:27 ` [PATCH bpf v2 1/2] bpf: " Arthur Fabre
2024-12-13 23:52   ` Eduard Zingerman
2024-12-13 21:27 ` [PATCH bpf v2 2/2] selftests/bpf: Test r0 bounds after BPF to BPF call with abnormal return Arthur Fabre
2024-12-13 23:55   ` Eduard Zingerman
2024-12-16 17:39     ` Arthur Fabre
2024-12-16 18:05       ` Alexei Starovoitov
2024-12-16 18:50         ` Eduard Zingerman [this message]
2024-12-16 19:47           ` Alexei Starovoitov
2024-12-16 20:45             ` Arthur Fabre
2024-12-16 18:50       ` Eduard Zingerman
2024-12-16 17:45 ` [PATCH bpf v2 0/2] Don't trust r0 bounds after BPF to BPF calls with abnormal returns Arthur Fabre
2024-12-16 18:03   ` Alexei Starovoitov

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=ed827bde40ab18be536add38c4237d949a752b2d.camel@gmail.com \
    --to=eddyz87@gmail.com \
    --cc=afabre@cloudflare.com \
    --cc=alexei.starovoitov@gmail.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=kernel-team@cloudflare.com \
    --cc=kpsingh@kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=sdf@fomichev.me \
    --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;
as well as URLs for NNTP newsgroup(s).