summaryrefslogtreecommitdiffstats
path: root/net/core/filter.c
diff options
context:
space:
mode:
authorDavid Ahern2018-05-29 20:59:13 +0200
committerDaniel Borkmann2018-05-29 21:48:43 +0200
commit9ce64f192d161acff17c99ceec7d9ce3db9252fa (patch)
tree7f58b1c04639b92be5fa9ad82e91005c7df82a85 /net/core/filter.c
parentbpf: Drop mpls from bpf_fib_lookup (diff)
downloadkernel-qcow2-linux-9ce64f192d161acff17c99ceec7d9ce3db9252fa.tar.gz
kernel-qcow2-linux-9ce64f192d161acff17c99ceec7d9ce3db9252fa.tar.xz
kernel-qcow2-linux-9ce64f192d161acff17c99ceec7d9ce3db9252fa.zip
bpf: Verify flags in bpf_fib_lookup
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>
Diffstat (limited to 'net/core/filter.c')
-rw-r--r--net/core/filter.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/net/core/filter.c b/net/core/filter.c
index 0ce93edefb0e..81bd2e9fe8fc 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -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:
@@ -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: