Message ID | 20201207195539.609787-1-revest@chromium.org (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | BPF |
Headers | show |
Series | [bpf-next] bpf: Only call sock_from_file with CONFIG_NET | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for bpf-next |
netdev/subject_prefix | success | Link |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 33 this patch: 33 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 11 lines checked |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 33 this patch: 33 |
netdev/header_inline | success | Link |
netdev/stable | success | Stable not CCed |
On Mon, 2020-12-07 at 20:55 +0100, Florent Revest wrote: > This avoids > ld: kernel/trace/bpf_trace.o: in function `bpf_sock_from_file': > bpf_trace.c:(.text+0xe23): undefined reference to `sock_from_file' > When compiling a kernel with BPF and without NET. > > Reported-by: Randy Dunlap <rdunlap@infradead.org> > Signed-off-by: Florent Revest <revest@chromium.org> > --- > kernel/trace/bpf_trace.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c > index 0cf0a6331482..877123bae71f 100644 > --- a/kernel/trace/bpf_trace.c > +++ b/kernel/trace/bpf_trace.c > @@ -1272,7 +1272,11 @@ const struct bpf_func_proto > bpf_snprintf_btf_proto = { > > BPF_CALL_1(bpf_sock_from_file, struct file *, file) > { > +#ifdef CONFIG_NET > return (unsigned long) sock_from_file(file); > +#else > + return NULL; Ugh, and of course I messed up my fix... :) Now this causes a: ./include/linux/stddef.h:8:14: warning: returning ‘void *’ from a function with return type ‘u64’ {aka ‘long long unsigned int’} makes integer from pointer without a cast [-Wint-conversion] 8 | #define NULL ((void *)0) | ^ kernel/trace/bpf_trace.c:1278:9: note: in expansion of macro ‘NULL’ 1278 | return NULL; So I'm sending a v2!
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c index 0cf0a6331482..877123bae71f 100644 --- a/kernel/trace/bpf_trace.c +++ b/kernel/trace/bpf_trace.c @@ -1272,7 +1272,11 @@ const struct bpf_func_proto bpf_snprintf_btf_proto = { BPF_CALL_1(bpf_sock_from_file, struct file *, file) { +#ifdef CONFIG_NET return (unsigned long) sock_from_file(file); +#else + return NULL; +#endif } BTF_ID_LIST(bpf_sock_from_file_btf_ids)
This avoids ld: kernel/trace/bpf_trace.o: in function `bpf_sock_from_file': bpf_trace.c:(.text+0xe23): undefined reference to `sock_from_file' When compiling a kernel with BPF and without NET. Reported-by: Randy Dunlap <rdunlap@infradead.org> Signed-off-by: Florent Revest <revest@chromium.org> --- kernel/trace/bpf_trace.c | 4 ++++ 1 file changed, 4 insertions(+)