Skip to content

Commit

Permalink
net: openvswitch: fix nested key length validation in the set() action
Browse files Browse the repository at this point in the history
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: syzbot+b07a9da40df1576b8048@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=b07a9da40df1576b8048
Tested-by: syzbot+b07a9da40df1576b8048@syzkaller.appspotmail.com
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Reviewed-by: Eelco Chaudron <echaudro@redhat.com>
Acked-by: Aaron Conole <aconole@redhat.com>
Link: https://patch.msgid.link/20250412104052.2073688-1-i.maximets@ovn.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Ilya Maximets authored and Jakub Kicinski committed Apr 14, 2025
1 parent 186e588 commit 65d9119
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion net/openvswitch/flow_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -2876,7 +2876,8 @@ static int validate_set(const struct nlattr *a,
size_t key_len;

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

key_len = nla_len(ovs_key);
Expand Down

0 comments on commit 65d9119

Please sign in to comment.