Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 890638

Summary: dev-util/bpftool: fails to build if clang has default-stack-clash-protection enabled
Product: Gentoo Linux Reporter: Holger Hoffstätte <holger>
Component: Current packagesAssignee: Jakov Smolić <jsmolic>
Status: RESOLVED FIXED    
Severity: normal CC: flow
Priority: Normal Keywords: PullRequest
Version: unspecified   
Hardware: All   
OS: Linux   
See Also: https://bugs.gentoo.org/show_bug.cgi?id=890004
https://bugs.gentoo.org/show_bug.cgi?id=889561
https://github.com/gentoo/gentoo/pull/29086
https://bugs.gentoo.org/show_bug.cgi?id=808165
https://bugs.gentoo.org/show_bug.cgi?id=889850
Whiteboard:
Package list:
Runtime testing required: ---

Description Holger Hoffstätte 2023-01-13 09:51:03 UTC
bpftool fails to build its bpf parts with clang if the toolchain has stack-protection enabled - which is the case in Gentoo.

Reproducible: Always

Steps to Reproduce:
1. use clang-15.0.6
2. build bpftool
3. error
Actual Results:  
clang \
	-I. \
	-I/tmp/portage/dev-util/bpftool-6.0.12/work/linux-6.0/tools/include/uapi/ \
	-I/tmp/portage/dev-util/bpftool-6.0.12/work/linux-6.0/tools/bpf/bpftool/bootstrap/libbpf/include \
	-g -O2 -Wall -target bpf -c skeleton/pid_iter.bpf.c -o pid_iter.bpf.o
clang \
	-I. \
	-I/tmp/portage/dev-util/bpftool-6.0.12/work/linux-6.0/tools/include/uapi/ \
	-I/tmp/portage/dev-util/bpftool-6.0.12/work/linux-6.0/tools/bpf/bpftool/bootstrap/libbpf/include \
	-g -O2 -Wall -target bpf -c skeleton/profiler.bpf.c -o profiler.bpf.o
skeleton/profiler.bpf.c:40:14: error: A call to built-in function '__stack_chk_fail' is not supported.
int BPF_PROG(fentry_XXX)
             ^
skeleton/profiler.bpf.c:94:14: error: A call to built-in function '__stack_chk_fail' is not supported.
int BPF_PROG(fexit_XXX)
             ^
2 errors generated.


Expected Results:  
Clean build
Comment 1 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-01-13 09:54:16 UTC
It should be okay (and upstreamable) to just jam a -fno-stack-protector into the Makefiles.
Comment 2 Holger Hoffstätte 2023-01-13 09:55:12 UTC
(In reply to Sam James from comment #1)
> It should be okay (and upstreamable) to just jam a -fno-stack-protector into
> the Makefiles.

That's exactly what I've done. :)
Comment 3 Larry the Git Cow gentoo-dev 2023-01-13 10:22:59 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e6371538947cff10c0d6dba0f36dd93af9b555f9

commit e6371538947cff10c0d6dba0f36dd93af9b555f9
Author:     Holger Hoffstätte <holger@applied-asynchrony.com>
AuthorDate: 2023-01-13 10:04:17 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2023-01-13 10:22:34 +0000

    dev-util/bftool: fix build with clang+ssp
    
    Closes: https://bugs.gentoo.org/890638
    Signed-off-by: Holger Hoffstätte <holger@applied-asynchrony.com>
    Closes: https://github.com/gentoo/gentoo/pull/29086
    Signed-off-by: Sam James <sam@gentoo.org>

 dev-util/bpftool/bpftool-5.19.12.ebuild                 |  1 +
 dev-util/bpftool/bpftool-6.0.12.ebuild                  |  5 +++++
 dev-util/bpftool/files/5.19.12-no-stack-protector.patch | 14 ++++++++++++++
 dev-util/bpftool/files/6.0.12-no-stack-protector.patch  | 14 ++++++++++++++
 4 files changed, 34 insertions(+)
Comment 4 Holger Hoffstätte 2023-01-13 16:32:44 UTC
Added upstream in:

https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/commit/?id=878625e1c7a10dfbb1fdaaaae2c4d2a58fbce627

Will probably land in 6.3.