From 4816e25cb5b18caa68ad9f146dec4d4da35183b2 Mon Sep 17 00:00:00 2001 From: Andrea Righi Date: Wed, 1 May 2024 14:35:00 +0200 Subject: [PATCH] UBUNTU: SAUCE: fan: support vxlan strict length validation BugLink: https://bugs.launchpad.net/bugs/2064508 Make IFLA_VXLAN_FAN_MAP compatible with the strict length check validation enforced by vxlan_policy for attribute types >= IFLA_VXLAN_LOCALBYPASS. This allows to support new vxlan attribute types with kernels >= 6.8, without breaking the existent user-space tools relying on Ubuntu FAN. Signed-off-by: Andrea Righi Acked-by: Roxana Nicolescu Acked-by: Stefan Bader Signed-off-by: Stefan Bader --- drivers/net/vxlan/vxlan_core.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 175b1a88e38f..201f23165780 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -3531,6 +3531,22 @@ static void vxlan_raw_setup(struct net_device *dev) dev->netdev_ops = &vxlan_netdev_raw_ops; } +/* Validate Ubuntu FAN payload. + * + * This is required to bypass the strict length validation enforced for the + * attribute types >= IFLA_VXLAN_LOCALBYPASS in vxlan_policy. + * + * In this way we can continue to use the same allocated ID for + * IFLA_VXLAN_FAN_MAP, without breaking the existing user-space and also + * future kernel ABIs that may add new attribute types to vxlan_policy. + */ +static int fan_map_validate_entry(const struct nlattr *attr, + struct netlink_ext_ack *extack) +{ + /* Accept any payload for Ubuntu FAN */ + return 0; +} + static const struct nla_policy vxlan_policy[IFLA_VXLAN_MAX + 1] = { [IFLA_VXLAN_UNSPEC] = { .strict_start_type = IFLA_VXLAN_LOCALBYPASS }, [IFLA_VXLAN_ID] = { .type = NLA_U32 }, @@ -3565,6 +3581,9 @@ static const struct nla_policy vxlan_policy[IFLA_VXLAN_MAX + 1] = { [IFLA_VXLAN_VNIFILTER] = { .type = NLA_U8 }, [IFLA_VXLAN_LOCALBYPASS] = NLA_POLICY_MAX(NLA_U8, 1), [IFLA_VXLAN_LABEL_POLICY] = NLA_POLICY_MAX(NLA_U32, VXLAN_LABEL_MAX), + [IFLA_VXLAN_FAN_MAP] = NLA_POLICY_VALIDATE_FN(NLA_BINARY, + fan_map_validate_entry, + sizeof(struct ifla_fan_map) * 256), }; static int vxlan_validate(struct nlattr *tb[], struct nlattr *data[],