Skip to contentSkip to conversation

bpf: Verify flags in bpf_fib_lookup

PATCH Applied [email protected] 2 participants 2 messages May 29, 2018

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bpf: Verify flags in bpf_fib_lookup

From: David Ahern <[email protected]>

Verify flags argument contains only known flags. Allows programs to probe for support as more are added.

---
 net/core/filter.c | 6 ++++++
 1 file changed, 6 insertions(+)
net/core/filter.c +6 -0
index 24e6ce8be567..4cff6d9cd724 100644
@@ -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:
Signature · 1 line
2.11.0