From: Eduard Zingerman <eddyz87@gmail.com>
To: Quentin Monnet <quentin@isovalent.com>,
Peter Foley <pefoley2@pefoley.com>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <martin.lau@linux.dev>,
Song Liu <song@kernel.org>, Yonghong Song <yhs@fb.com>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@kernel.org>,
Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>,
Jiri Olsa <jolsa@kernel.org>,
Nathan Chancellor <nathan@kernel.org>,
Nick Desaulniers <ndesaulniers@google.com>,
Tom Rix <trix@redhat.com>
Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev
Subject: Re: [PATCH] tools: bpf: Disable stack protector
Date: Mon, 16 Jan 2023 14:59:56 +0200 [thread overview]
Message-ID: <194f38f2dc7d521375e5a660baaf1be31536be9a.camel@gmail.com> (raw)
In-Reply-To: <cb03b745-26b8-706c-de40-80ae991e29fd@isovalent.com>
On Mon, 2023-01-16 at 10:30 +0000, Quentin Monnet wrote:
> 2023-01-14 18:00 UTC-0500 ~ Peter Foley <pefoley2@pefoley.com>
> > Avoid build errors on distros that force the stack protector on by
> > default.
> > e.g.
> > CLANG /home/peter/linux/work/tools/bpf/bpftool/pid_iter.bpf.o
> > skeleton/pid_iter.bpf.c:53:5: error: A call to built-in function '__stack_chk_fail' is not supported.
> > int iter(struct bpf_iter__task_file *ctx)
> > ^
> > 1 error generated.
> >
> > Signed-off-by: Peter Foley <pefoley2@pefoley.com>
> > ---
> > tools/bpf/bpftool/Makefile | 1 +
> > tools/bpf/runqslower/Makefile | 5 +++--
> > 2 files changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile
> > index f610e184ce02a..36ac0002e386f 100644
> > --- a/tools/bpf/bpftool/Makefile
> > +++ b/tools/bpf/bpftool/Makefile
> > @@ -215,6 +215,7 @@ $(OUTPUT)%.bpf.o: skeleton/%.bpf.c $(OUTPUT)vmlinux.h $(LIBBPF_BOOTSTRAP)
> > -I$(or $(OUTPUT),.) \
> > -I$(srctree)/tools/include/uapi/ \
> > -I$(LIBBPF_BOOTSTRAP_INCLUDE) \
> > + -fno-stack-protector \
> > -g -O2 -Wall -target bpf -c $< -o $@
> > $(Q)$(LLVM_STRIP) -g $@
> >
>
> For bpftool, a similar patch was already submitted and merged to the
> bpf-next tree last Friday: 878625e1c7a1 ("bpftool: Always disable stack
> protection for BPF objects").
>
> > diff --git a/tools/bpf/runqslower/Makefile b/tools/bpf/runqslower/Makefile
> > index 8b3d87b82b7a2..f7313cc966a04 100644
> > --- a/tools/bpf/runqslower/Makefile
> > +++ b/tools/bpf/runqslower/Makefile
> > @@ -60,8 +60,9 @@ $(OUTPUT)/%.skel.h: $(OUTPUT)/%.bpf.o | $(BPFTOOL)
> > $(QUIET_GEN)$(BPFTOOL) gen skeleton $< > $@
> >
> > $(OUTPUT)/%.bpf.o: %.bpf.c $(BPFOBJ) | $(OUTPUT)
> > - $(QUIET_GEN)$(CLANG) -g -O2 -target bpf $(INCLUDES) \
> > - -c $(filter %.c,$^) -o $@ && \
> > + $(QUIET_GEN)$(CLANG) -g -O2 -target bpf $(INCLUDES) \
> > + -fno-stack-protector \
> > + -c $(filter %.c,$^) -o $@ && \
> > $(LLVM_STRIP) -g $@
> >
> > $(OUTPUT)/%.o: %.c | $(OUTPUT)
>
> This one looks good, thanks!
>
> I note a few more places in the repository where we compile to BPF using
> clang. Given that there have been patches to add -fno-stack-protector at
> several locations already, have you checked if any of these also need
> the flag, by any chance, so we could fix this once and for all?
>
> $ git grep -l 'target bpf ' | egrep -v '(Documentation|bpftool)'
> kernel/bpf/preload/iterators/Makefile
> samples/bpf/Makefile
> samples/bpf/test_lwt_bpf.sh
> tools/bpf/runqslower/Makefile
> tools/build/feature/Makefile
> tools/perf/Makefile.perf
> tools/perf/util/llvm-utils.c
> tools/testing/selftests/bpf/Makefile
> tools/testing/selftests/net/bpf/Makefile
> tools/testing/selftests/tc-testing/Makefile
A bit tangential, but since BPF LLVM backend does not support the
stack protector (should it?) there is also an option to adjust LLVM
to avoid this instrumentation, WDYT?
next prev parent reply other threads:[~2023-01-16 12:59 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-14 23:00 [PATCH] tools: bpf: Disable stack protector Peter Foley
2023-01-16 10:30 ` Quentin Monnet
2023-01-16 12:59 ` Eduard Zingerman [this message]
2023-01-16 22:49 ` Peter Foley
2023-01-16 22:53 ` Eduard Zingerman
2023-01-17 7:05 ` Yonghong Song
2023-01-17 7:09 ` Peter Foley
2023-01-17 16:22 ` Yonghong Song
2023-01-17 13:23 ` Jose E. Marchesi
2023-01-17 16:31 ` Jose E. Marchesi
2023-01-17 17:14 ` Yonghong Song
2023-01-17 17:11 ` Yonghong Song
2023-01-18 19:28 ` Eduard Zingerman
2023-01-19 7:34 ` Yonghong Song
2023-01-23 4:28 ` Peter Foley
2023-01-23 5:22 ` Yonghong Song
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=194f38f2dc7d521375e5a660baaf1be31536be9a.camel@gmail.com \
--to=eddyz87@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=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=martin.lau@linux.dev \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=pefoley2@pefoley.com \
--cc=quentin@isovalent.com \
--cc=sdf@google.com \
--cc=song@kernel.org \
--cc=trix@redhat.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