Skip to content

Commit 4faedab

Browse files
jsitnickiKernel Patches Daemon
authored andcommitted
bpf: Return an error pointer for skb metadata when CONFIG_NET=n
Kernel Test Robot reported a compiler warning - a null pointer may be passed to memmove in __bpf_dynptr_{read,write} when building without networking support. The warning is correct from a static analysis standpoint, but not actually reachable. Without CONFIG_NET, creating dynptrs to skb metadata is impossible since the constructor kfunc is missing. Silence the false-postive diagnostic message by returning an error pointer from bpf_skb_meta_pointer stub when CONFIG_NET=n. Fixes: 6877cd3 ("bpf: Enable read/write access to skb metadata through a dynptr") Reported-by: kernel test robot <[email protected]> Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/ Suggested-by: Alexei Starovoitov <[email protected]> Signed-off-by: Jakub Sitnicki <[email protected]>
1 parent af15c58 commit 4faedab

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

include/linux/filter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1816,7 +1816,7 @@ static inline void bpf_xdp_copy_buf(struct xdp_buff *xdp, unsigned long off, voi
18161816

18171817
static inline void *bpf_skb_meta_pointer(struct sk_buff *skb, u32 offset)
18181818
{
1819-
return NULL;
1819+
return ERR_PTR(-EOPNOTSUPP);
18201820
}
18211821
#endif /* CONFIG_NET */
18221822

0 commit comments

Comments
 (0)