]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
openvswitch: validate MPLS set/set_masked payload length
authorYang Yang <n05ec@lzu.edu.cn>
Thu, 19 Mar 2026 08:02:27 +0000 (08:02 +0000)
committerJakub Kicinski <kuba@kernel.org>
Sat, 21 Mar 2026 01:37:31 +0000 (18:37 -0700)
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>
Reviewed-by: Ilya Maximets <i.maximets@ovn.org>
Link: https://patch.msgid.link/20260319080228.3423307-1-n05ec@lzu.edu.cn
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/openvswitch/flow_netlink.c

index 67fbf6e48a30101579519e919d5100b7a9a9ca5b..13052408a132f489954973d910d8430fca05e2ac 100644 (file)
@@ -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: