Skip to content

Commit 2130c51

Browse files
kuba-mooborkmann
authored andcommitted
bpf: Use nla_ok() instead of checking nla_len directly
nla_len may also be too short to be sane, in which case after recent changes nla_len() will return a wrapped value. Fixes: 172db56 ("netlink: Return unsigned value for nla_len()") Reported-by: [email protected] Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent f7dd48e commit 2130c51

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/core/filter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ BPF_CALL_3(bpf_skb_get_nlattr_nest, struct sk_buff *, skb, u32, a, u32, x)
203203
return 0;
204204

205205
nla = (struct nlattr *) &skb->data[a];
206-
if (nla->nla_len > skb->len - a)
206+
if (!nla_ok(nla, skb->len - a))
207207
return 0;
208208

209209
nla = nla_find_nested(nla, x);

0 commit comments

Comments
 (0)