]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
samples/bpf: Set -fno-stack-protector when building BPF programs
authorToke Høiland-Jørgensen <toke@redhat.com>
Mon, 16 Dec 2019 10:38:19 +0000 (11:38 +0100)
committerPaolo Pisati <paolo.pisati@canonical.com>
Mon, 24 Feb 2020 15:19:43 +0000 (16:19 +0100)
BugLink: https://bugs.launchpad.net/bugs/1864488
[ Upstream commit 450278977acbf494a20367c22fbb38729772d1fc ]

It seems Clang can in some cases turn on stack protection by default, which
doesn't work with BPF. This was reported once before[0], but it seems the
flag to explicitly turn off the stack protector wasn't added to the
Makefile, so do that now.

The symptom of this is compile errors like the following:

error: <unknown>:0:0: in function bpf_prog1 i32 (%struct.__sk_buff*): A call to built-in function '__stack_chk_fail' is not supported.

[0] https://www.spinics.net/lists/netdev/msg556400.html

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20191216103819.359535-1-toke@redhat.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
samples/bpf/Makefile

index e7ad48c605e0faf3c40d5e2ef41e569b3528c083..6d1df7117e1170dddc347c1ffbfb024a4339cdc5 100644 (file)
@@ -219,6 +219,7 @@ BTF_LLVM_PROBE := $(shell echo "int main() { return 0; }" | \
                          readelf -S ./llvm_btf_verify.o | grep BTF; \
                          /bin/rm -f ./llvm_btf_verify.o)
 
+BPF_EXTRA_CFLAGS += -fno-stack-protector
 ifneq ($(BTF_LLVM_PROBE),)
        EXTRA_CFLAGS += -g
 else