Skip to content

Commit 65d9119

Browse files
igsilyakuba-moo
authored andcommitted
net: openvswitch: fix nested key length validation in the set() action
It's not safe to access nla_len(ovs_key) if the data is smaller than the netlink header. Check that the attribute is OK first. Fixes: ccb1352 ("net: Add Open vSwitch kernel components.") Reported-by: [email protected] Closes: https://syzkaller.appspot.com/bug?extid=b07a9da40df1576b8048 Tested-by: [email protected] Signed-off-by: Ilya Maximets <[email protected]> Reviewed-by: Eelco Chaudron <[email protected]> Acked-by: Aaron Conole <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 186e588 commit 65d9119

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

net/openvswitch/flow_netlink.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2876,7 +2876,8 @@ static int validate_set(const struct nlattr *a,
28762876
size_t key_len;
28772877

28782878
/* There can be only one key in a action */
2879-
if (nla_total_size(nla_len(ovs_key)) != nla_len(a))
2879+
if (!nla_ok(ovs_key, nla_len(a)) ||
2880+
nla_total_size(nla_len(ovs_key)) != nla_len(a))
28802881
return -EINVAL;
28812882

28822883
key_len = nla_len(ovs_key);

0 commit comments

Comments
 (0)