bpf: use nla_ok() instead of checking nla_len directly
Subsystems (4)
Jakub Kicinski
maintainerPATCH 1/1 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.
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- net/core/filter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/filter.c +1 -1
@@ -203,7 +203,7 @@ BPF_CALL_3(bpf_skb_get_nlattr_nest, struct sk_buff *, skb, u32, a, u32, x)return 0 ; nla = (struct nlattr *) &skb->data[a]; -if (nla->nla_len > skb->len - a) +if (!nla_ok (nla, skb->len - a))return 0 ; nla =nla_find_nested (nla, x);
Signature · 1 line
2.43.0
Quoted 6 lines · Jakub Kicinski
nla_lenmay also be too short to be sane, in which case after recent changesnla_len()will return a wrapped value.Reported-by [email protected]Fixes 172db56d90d2 ("netlink: Return unsigned value for nla_len()")Signed-off-by Jakub Kicinski <[email protected]>
This patch was applied to bpf/bpf-next.git (master) by Daniel Borkmann <[email protected]>:
Hello:
This patch was applied to bpf/bpf-next.git (master) by Daniel Borkmann <[email protected]>:
Quoted 8 lines · On Mon, 18 Dec 2023 15:19:04 -0800 you wrote:
nla_lenmay also be too short to be sane, in which case after recent changesnla_len()will return a wrapped value.Reported-by [email protected]Fixes 172db56d90d2 ("netlink: Return unsigned value for nla_len()")Signed-off-by Jakub Kicinski <[email protected]>[...]
Here is the summary with links:
- [bpf-next] bpf: use nla_ok() instead of checking nla_len directly
https://git.kernel.org/bpf/bpf-next/c/2130c519a401
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html