Skip to content

bpf: Fix NULL pointer dereference in bpf_skb_fib_lookup()#11873

Closed
kernel-patches-daemon-bpf[bot] wants to merge 1 commit into
bpf_basefrom
series/1082997=>bpf
Closed

bpf: Fix NULL pointer dereference in bpf_skb_fib_lookup()#11873
kernel-patches-daemon-bpf[bot] wants to merge 1 commit into
bpf_basefrom
series/1082997=>bpf

Conversation

@kernel-patches-daemon-bpf

Copy link
Copy Markdown

Pull request for series with
subject: bpf: Fix NULL pointer dereference in bpf_skb_fib_lookup()
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1082997

@kernel-patches-daemon-bpf

Copy link
Copy Markdown
Author

Upstream branch: eb5249b
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1082997
version: 1

@kernel-patches-daemon-bpf

Copy link
Copy Markdown
Author

Upstream branch: eb5249b
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1082997
version: 1

When tot_len is not provided by the user, bpf_skb_fib_lookup()
resolves the FIB result's output device via dev_get_by_index_rcu()
to check skb forwardability and fill in mtu_result. The returned
pointer is dereferenced without a NULL check. If the device is
concurrently unregistered, dev_get_by_index_rcu() returns NULL and
is_skb_forwardable() crashes at dev->flags:

 KASAN: null-ptr-deref in range
  [0x00000000000000b0-0x00000000000000b7]
 Call Trace:
  is_skb_forwardable (include/linux/netdevice.h:4365)
  bpf_skb_fib_lookup (net/core/filter.c:6446)
  bpf_prog_test_run_skb (net/bpf/test_run.c)
  __sys_bpf (kernel/bpf/syscall.c)

Add the missing NULL check, returning -ENODEV to be consistent
with how bpf_ipv4_fib_lookup() and bpf_ipv6_fib_lookup() handle
the same condition.

Fixes: e1850ea ("bpf: bpf_fib_lookup return MTU value as output when looked up")
Reported-by: Xiang Mei <xmei5@asu.edu>
Signed-off-by: Weiming Shi <bestswngs@gmail.com>
Acked-by: Paul Chaignon <paul.chaignon@gmail.com>
@kernel-patches-daemon-bpf

Copy link
Copy Markdown
Author

Upstream branch: cd0eb48
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1082997
version: 1

@kernel-patches-daemon-bpf kernel-patches-daemon-bpf Bot deleted the series/1082997=>bpf branch April 25, 2026 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant