diff mbox series

[v4l-utils] keytable: Add -fno-stack-protector compilation option

Message ID 20230211221401.25715-1-laurent.pinchart@ideasonboard.com (mailing list archive)
State New, archived
Headers show
Series [v4l-utils] keytable: Add -fno-stack-protector compilation option | expand

Commit Message

Laurent Pinchart Feb. 11, 2023, 10:14 p.m. UTC
clang may come with stack protector enabled by default, which caused
compilation errors for BPF programs:

FAILED: utils/keytable/bpf_protocols/grundig.o
/usr/lib/llvm/15/bin/clang -idirafter /usr/lib/llvm/15/bin/../../../../lib/clang/15.0.6/include -idirafter /usr/local/include -idirafter /usr/include -D__linux__ -target bpf -O2 -c ../../utils/keytable/bpf_protocols/grundig.c -o utils/keytable/bpf_protocols/grundig.o
../../utils/keytable/bpf_protocols/grundig.c:50:5: error: A call to built-in function '__stack_chk_fail' is not supported.
int bpf_decoder(unsigned int *sample)
    ^
1 error generated.

Disable the stack protector to fix this, as recommended in [1].

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

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 utils/keytable/bpf_protocols/Makefile.am | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Sean Young Feb. 13, 2023, 10:16 a.m. UTC | #1
On Sun, Feb 12, 2023 at 12:14:01AM +0200, Laurent Pinchart wrote:
> clang may come with stack protector enabled by default, which caused
> compilation errors for BPF programs:
> 
> FAILED: utils/keytable/bpf_protocols/grundig.o
> /usr/lib/llvm/15/bin/clang -idirafter /usr/lib/llvm/15/bin/../../../../lib/clang/15.0.6/include -idirafter /usr/local/include -idirafter /usr/include -D__linux__ -target bpf -O2 -c ../../utils/keytable/bpf_protocols/grundig.c -o utils/keytable/bpf_protocols/grundig.o
> ../../utils/keytable/bpf_protocols/grundig.c:50:5: error: A call to built-in function '__stack_chk_fail' is not supported.
> int bpf_decoder(unsigned int *sample)
>     ^
> 1 error generated.
> 
> Disable the stack protector to fix this, as recommended in [1].
> 
> [1] https://www.spinics.net/lists/netdev/msg556400.html

Looks good, applied.

I could not reproduce the problem, but the -fno-stack-protector cli option
has been supported for a very long time, and stack protection does not make
sense in a BPF context.

Thanks,
Sean

> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  utils/keytable/bpf_protocols/Makefile.am | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/utils/keytable/bpf_protocols/Makefile.am b/utils/keytable/bpf_protocols/Makefile.am
> index 13be2794791b..6096c0de5813 100644
> --- a/utils/keytable/bpf_protocols/Makefile.am
> +++ b/utils/keytable/bpf_protocols/Makefile.am
> @@ -8,7 +8,7 @@ CLANG_SYS_INCLUDES := $(shell $(CLANG) -v -E - </dev/null 2>&1 \
>          | sed -n '/<...> search starts here:/,/End of search list./{ s| \(/.*\)|-idirafter \1|p }')
>  
>  %.o: %.c bpf_helpers.h
> -	$(CLANG) $(CLANG_SYS_INCLUDES) -D__linux__ -I$(top_srcdir)/include -target bpf -O2 -c $<
> +	$(CLANG) $(CLANG_SYS_INCLUDES) -D__linux__ -I$(top_srcdir)/include -target bpf -fno-stack-protector -O2 -c $<
>  
>  PROTOCOLS = grundig.o pulse_distance.o pulse_length.o rc_mm.o manchester.o xbox-dvd.o imon_rsc.o raw.o samsung36.o
>  
> -- 
> Regards,
> 
> Laurent Pinchart
diff mbox series

Patch

diff --git a/utils/keytable/bpf_protocols/Makefile.am b/utils/keytable/bpf_protocols/Makefile.am
index 13be2794791b..6096c0de5813 100644
--- a/utils/keytable/bpf_protocols/Makefile.am
+++ b/utils/keytable/bpf_protocols/Makefile.am
@@ -8,7 +8,7 @@  CLANG_SYS_INCLUDES := $(shell $(CLANG) -v -E - </dev/null 2>&1 \
         | sed -n '/<...> search starts here:/,/End of search list./{ s| \(/.*\)|-idirafter \1|p }')
 
 %.o: %.c bpf_helpers.h
-	$(CLANG) $(CLANG_SYS_INCLUDES) -D__linux__ -I$(top_srcdir)/include -target bpf -O2 -c $<
+	$(CLANG) $(CLANG_SYS_INCLUDES) -D__linux__ -I$(top_srcdir)/include -target bpf -fno-stack-protector -O2 -c $<
 
 PROTOCOLS = grundig.o pulse_distance.o pulse_length.o rc_mm.o manchester.o xbox-dvd.o imon_rsc.o raw.o samsung36.o