Skip to content

Commit

Permalink
bpf: Verify flags in bpf_fib_lookup
Browse files Browse the repository at this point in the history
Verify flags argument contains only known flags. Allows programs to probe
for support as more are added.

Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
  • Loading branch information
David Ahern authored and Daniel Borkmann committed May 29, 2018
1 parent fa898d7 commit 9ce64f1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions net/core/filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -4270,6 +4270,9 @@ BPF_CALL_4(bpf_xdp_fib_lookup, struct xdp_buff *, ctx,
if (plen < sizeof(*params))
return -EINVAL;

if (flags & ~(BPF_FIB_LOOKUP_DIRECT | BPF_FIB_LOOKUP_OUTPUT))
return -EINVAL;

switch (params->family) {
#if IS_ENABLED(CONFIG_INET)
case AF_INET:
Expand Down Expand Up @@ -4304,6 +4307,9 @@ BPF_CALL_4(bpf_skb_fib_lookup, struct sk_buff *, skb,
if (plen < sizeof(*params))
return -EINVAL;

if (flags & ~(BPF_FIB_LOOKUP_DIRECT | BPF_FIB_LOOKUP_OUTPUT))
return -EINVAL;

switch (params->family) {
#if IS_ENABLED(CONFIG_INET)
case AF_INET:
Expand Down

0 comments on commit 9ce64f1

Please sign in to comment.