netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: openvswitch: fix nested key length validation in the set() action
@ 2025-04-12 10:40 Ilya Maximets
  2025-04-14  7:03 ` Eelco Chaudron
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ilya Maximets @ 2025-04-12 10:40 UTC (permalink / raw)
  To: netdev
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman, dev, linux-kernel, Eelco Chaudron, Aaron Conole,
	Ilya Maximets, syzbot+b07a9da40df1576b8048

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: ccb1352e76cf ("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>
---
 net/openvswitch/flow_netlink.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/openvswitch/flow_netlink.c b/net/openvswitch/flow_netlink.c
index 95e0dd14dc1a..518be23e48ea 100644
--- a/net/openvswitch/flow_netlink.c
+++ b/net/openvswitch/flow_netlink.c
@@ -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);
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net] net: openvswitch: fix nested key length validation in the set() action
  2025-04-12 10:40 [PATCH net] net: openvswitch: fix nested key length validation in the set() action Ilya Maximets
@ 2025-04-14  7:03 ` Eelco Chaudron
  2025-04-14 13:05 ` Aaron Conole
  2025-04-14 23:20 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Eelco Chaudron @ 2025-04-14  7:03 UTC (permalink / raw)
  To: Ilya Maximets
  Cc: netdev, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Simon Horman, dev, linux-kernel, Aaron Conole,
	syzbot+b07a9da40df1576b8048



On 12 Apr 2025, at 12:40, Ilya Maximets wrote:

> 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: ccb1352e76cf ("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>

The patch looks good to me.

Reviewed-by:  Eelco Chaudron <echaudro@redhat.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net] net: openvswitch: fix nested key length validation in the set() action
  2025-04-12 10:40 [PATCH net] net: openvswitch: fix nested key length validation in the set() action Ilya Maximets
  2025-04-14  7:03 ` Eelco Chaudron
@ 2025-04-14 13:05 ` Aaron Conole
  2025-04-14 23:20 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Aaron Conole @ 2025-04-14 13:05 UTC (permalink / raw)
  To: Ilya Maximets
  Cc: netdev, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Simon Horman, dev, linux-kernel, Eelco Chaudron,
	syzbot+b07a9da40df1576b8048

Ilya Maximets <i.maximets@ovn.org> writes:

> 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: ccb1352e76cf ("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>
> ---

Acked-by: Aaron Conole <aconole@redhat.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net] net: openvswitch: fix nested key length validation in the set() action
  2025-04-12 10:40 [PATCH net] net: openvswitch: fix nested key length validation in the set() action Ilya Maximets
  2025-04-14  7:03 ` Eelco Chaudron
  2025-04-14 13:05 ` Aaron Conole
@ 2025-04-14 23:20 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-04-14 23:20 UTC (permalink / raw)
  To: Ilya Maximets
  Cc: netdev, davem, edumazet, kuba, pabeni, horms, dev, linux-kernel,
	echaudro, aconole, syzbot+b07a9da40df1576b8048

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Sat, 12 Apr 2025 12:40:18 +0200 you wrote:
> 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: ccb1352e76cf ("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>
> 
> [...]

Here is the summary with links:
  - [net] net: openvswitch: fix nested key length validation in the set() action
    https://git.kernel.org/netdev/net/c/65d91192aa66

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-04-14 23:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-12 10:40 [PATCH net] net: openvswitch: fix nested key length validation in the set() action Ilya Maximets
2025-04-14  7:03 ` Eelco Chaudron
2025-04-14 13:05 ` Aaron Conole
2025-04-14 23:20 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).