public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] openvswitch: validate MPLS set/set_masked payload length
@ 2026-03-19  8:02 Yang Yang
  2026-03-19 11:08 ` Ilya Maximets
  2026-03-21  1:40 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Yang Yang @ 2026-03-19  8:02 UTC (permalink / raw)
  To: aconole, echaudro, i.maximets
  Cc: davem, edumazet, kuba, pabeni, horms, pshelar, martin.varghese,
	netdev, dev, linux-kernel, yifanwucs, tomapufckgml, tanyuan98,
	bird, n05ec

validate_set() accepted OVS_KEY_ATTR_MPLS as variable-sized payload for
SET/SET_MASKED actions. In action handling, OVS expects fixed-size
MPLS key data (struct ovs_key_mpls).

Use the already normalized key_len (masked case included) and reject
non-matching MPLS action key sizes.

Reject invalid MPLS action payload lengths early.

Fixes: fbdcdd78da7c ("Change in Openvswitch to support MPLS label depth of 3 in ingress direction")
Reported-by: Yifan Wu <yifanwucs@gmail.com>
Reported-by: Juefei Pu <tomapufckgml@gmail.com>
Tested-by: Ao Zhou <n05ec@lzu.edu.cn>
Co-developed-by: Yuan Tan <tanyuan98@outlook.com>
Signed-off-by: Yuan Tan <tanyuan98@outlook.com>
Suggested-by: Xin Liu <bird@lzu.edu.cn>
Signed-off-by: Yang Yang <n05ec@lzu.edu.cn>
---

 net/openvswitch/flow_netlink.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/openvswitch/flow_netlink.c b/net/openvswitch/flow_netlink.c
index 67fbf6e48a301..45444b81e9b97 100644
--- a/net/openvswitch/flow_netlink.c
+++ b/net/openvswitch/flow_netlink.c
@@ -2953,6 +2953,8 @@ static int validate_set(const struct nlattr *a,
 	case OVS_KEY_ATTR_MPLS:
 		if (!eth_p_mpls(eth_type))
 			return -EINVAL;
+		if (key_len != sizeof(struct ovs_key_mpls))
+			return -EINVAL;
 		break;
 
 	case OVS_KEY_ATTR_SCTP:
-- 
2.43.0


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

* Re: [PATCH net] openvswitch: validate MPLS set/set_masked payload length
  2026-03-19  8:02 [PATCH net] openvswitch: validate MPLS set/set_masked payload length Yang Yang
@ 2026-03-19 11:08 ` Ilya Maximets
  2026-03-21  1:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Ilya Maximets @ 2026-03-19 11:08 UTC (permalink / raw)
  To: Yang Yang, aconole, echaudro
  Cc: i.maximets, davem, edumazet, kuba, pabeni, horms, pshelar,
	martin.varghese, netdev, dev, linux-kernel, yifanwucs,
	tomapufckgml, tanyuan98, bird

On 3/19/26 9:02 AM, Yang Yang wrote:
> validate_set() accepted OVS_KEY_ATTR_MPLS as variable-sized payload for
> SET/SET_MASKED actions. In action handling, OVS expects fixed-size
> MPLS key data (struct ovs_key_mpls).
> 
> Use the already normalized key_len (masked case included) and reject
> non-matching MPLS action key sizes.
> 
> Reject invalid MPLS action payload lengths early.
> 
> Fixes: fbdcdd78da7c ("Change in Openvswitch to support MPLS label depth of 3 in ingress direction")
> Reported-by: Yifan Wu <yifanwucs@gmail.com>
> Reported-by: Juefei Pu <tomapufckgml@gmail.com>
> Tested-by: Ao Zhou <n05ec@lzu.edu.cn>
> Co-developed-by: Yuan Tan <tanyuan98@outlook.com>
> Signed-off-by: Yuan Tan <tanyuan98@outlook.com>
> Suggested-by: Xin Liu <bird@lzu.edu.cn>
> Signed-off-by: Yang Yang <n05ec@lzu.edu.cn>
> ---
> 
>  net/openvswitch/flow_netlink.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/net/openvswitch/flow_netlink.c b/net/openvswitch/flow_netlink.c
> index 67fbf6e48a301..45444b81e9b97 100644
> --- a/net/openvswitch/flow_netlink.c
> +++ b/net/openvswitch/flow_netlink.c
> @@ -2953,6 +2953,8 @@ static int validate_set(const struct nlattr *a,
>  	case OVS_KEY_ATTR_MPLS:
>  		if (!eth_p_mpls(eth_type))
>  			return -EINVAL;
> +		if (key_len != sizeof(struct ovs_key_mpls))
> +			return -EINVAL;
>  		break;
>  
>  	case OVS_KEY_ATTR_SCTP:

Yeah, the check was not adjusted on the actions side when support for
multiple labels was added for the match.  Thanks for fixing this!
I ran OVS testsuite with this as well, and it works fine.

Reviewed-by: Ilya Maximets <i.maximets@ovn.org>

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

* Re: [PATCH net] openvswitch: validate MPLS set/set_masked payload length
  2026-03-19  8:02 [PATCH net] openvswitch: validate MPLS set/set_masked payload length Yang Yang
  2026-03-19 11:08 ` Ilya Maximets
@ 2026-03-21  1:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-03-21  1:40 UTC (permalink / raw)
  To: Yang Yang
  Cc: aconole, echaudro, i.maximets, davem, edumazet, kuba, pabeni,
	horms, pshelar, martin.varghese, netdev, dev, linux-kernel,
	yifanwucs, tomapufckgml, tanyuan98, bird

Hello:

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

On Thu, 19 Mar 2026 08:02:27 +0000 you wrote:
> validate_set() accepted OVS_KEY_ATTR_MPLS as variable-sized payload for
> SET/SET_MASKED actions. In action handling, OVS expects fixed-size
> MPLS key data (struct ovs_key_mpls).
> 
> Use the already normalized key_len (masked case included) and reject
> non-matching MPLS action key sizes.
> 
> [...]

Here is the summary with links:
  - [net] openvswitch: validate MPLS set/set_masked payload length
    https://git.kernel.org/netdev/net/c/546b68ac8935

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] 3+ messages in thread

end of thread, other threads:[~2026-03-21  1:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-19  8:02 [PATCH net] openvswitch: validate MPLS set/set_masked payload length Yang Yang
2026-03-19 11:08 ` Ilya Maximets
2026-03-21  1:40 ` 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