bpf: Verify flags in bpf_fib_lookup
authorDavid Ahern <dsahern@gmail.com>
Tue, 29 May 2018 18:59:13 +0000 (11:59 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 29 May 2018 19:48:43 +0000 (21:48 +0200)
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>
net/core/filter.c

index 0ce93edefb0ed8ccc09b042200a726c14ee6bc4c..81bd2e9fe8fc710054ef2726bdb70b38dfdc2576 100644 (file)
@@ -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: