diff options
| author | Nikolay Aleksandrov <[email protected]> | 2015-10-12 12:31:01 +0000 |
|---|---|---|
| committer | David S. Miller <[email protected]> | 2015-10-13 11:43:24 +0000 |
| commit | 87aaf2caed8496404d3809edc30d38d4a4a5d273 (patch) | |
| tree | ed9ac3f950aca975ce8fc23c8b8fa047d41d05c6 /net/switchdev/switchdev.c | |
| parent | Merge branch 'be2net-fixes' (diff) | |
| download | kernel-87aaf2caed8496404d3809edc30d38d4a4a5d273.tar.gz kernel-87aaf2caed8496404d3809edc30d38d4a4a5d273.zip | |
switchdev: check if the vlan id is in the proper vlan range
VLANs 0 and 4095 are reserved and shouldn't be used, add checks to
switchdev similar to the bridge. Also make sure ids above 4095 cannot
be passed either.
Fixes: 47f8328bb1a4 ("switchdev: add new switchdev bridge setlink")
Signed-off-by: Nikolay Aleksandrov <[email protected]>
Acked-by: Scott Feldman <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
Diffstat (limited to 'net/switchdev/switchdev.c')
| -rw-r--r-- | net/switchdev/switchdev.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c index fda38f830a10..77f5d17e2612 100644 --- a/net/switchdev/switchdev.c +++ b/net/switchdev/switchdev.c @@ -16,6 +16,7 @@ #include <linux/notifier.h> #include <linux/netdevice.h> #include <linux/if_bridge.h> +#include <linux/if_vlan.h> #include <net/ip_fib.h> #include <net/switchdev.h> @@ -634,6 +635,8 @@ static int switchdev_port_br_afspec(struct net_device *dev, if (nla_len(attr) != sizeof(struct bridge_vlan_info)) return -EINVAL; vinfo = nla_data(attr); + if (!vinfo->vid || vinfo->vid >= VLAN_VID_MASK) + return -EINVAL; vlan->flags = vinfo->flags; if (vinfo->flags & BRIDGE_VLAN_INFO_RANGE_BEGIN) { if (vlan->vid_begin) |
