diff options
author | Nicolas Dichtel <nicolas.dichtel@6wind.com> | 2019-07-15 06:00:20 -0400 |
---|---|---|
committer | Steffen Klassert <steffen.klassert@secunet.com> | 2019-07-17 04:03:54 -0400 |
commit | e9e7e85d75f3731079ffd77c1a66f037aef04fe7 (patch) | |
tree | 65f27b789ff1758a4eea9a5942c283cad8bf97f0 /net/xfrm | |
parent | 114a5c3240155fdb01bf821c9d326d7bb05bd464 (diff) |
xfrm interface: avoid corruption on changelink
The new parameters must not be stored in the netdev_priv() before
validation, it may corrupt the interface. Note also that if data is NULL,
only a memset() is done.
$ ip link add xfrm1 type xfrm dev lo if_id 1
$ ip link add xfrm2 type xfrm dev lo if_id 2
$ ip link set xfrm1 type xfrm dev lo if_id 2
RTNETLINK answers: File exists
$ ip -d link list dev xfrm1
5: xfrm1@lo: <NOARP> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/none 00:00:00:00:00:00 brd 00:00:00:00:00:00 promiscuity 0 minmtu 68 maxmtu 1500
xfrm if_id 0x2 addrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
=> "if_id 0x2"
Fixes: f203b76d7809 ("xfrm: Add virtual xfrm interfaces")
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Tested-by: Julien Floret <julien.floret@6wind.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Diffstat (limited to 'net/xfrm')
-rw-r--r-- | net/xfrm/xfrm_interface.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/net/xfrm/xfrm_interface.c b/net/xfrm/xfrm_interface.c index 74868f9d81fb..2310dc9e35c2 100644 --- a/net/xfrm/xfrm_interface.c +++ b/net/xfrm/xfrm_interface.c | |||
@@ -671,12 +671,12 @@ static int xfrmi_changelink(struct net_device *dev, struct nlattr *tb[], | |||
671 | struct nlattr *data[], | 671 | struct nlattr *data[], |
672 | struct netlink_ext_ack *extack) | 672 | struct netlink_ext_ack *extack) |
673 | { | 673 | { |
674 | struct xfrm_if *xi = netdev_priv(dev); | ||
675 | struct net *net = dev_net(dev); | 674 | struct net *net = dev_net(dev); |
675 | struct xfrm_if_parms p; | ||
676 | struct xfrm_if *xi; | ||
676 | 677 | ||
677 | xfrmi_netlink_parms(data, &xi->p); | 678 | xfrmi_netlink_parms(data, &p); |
678 | 679 | xi = xfrmi_locate(net, &p); | |
679 | xi = xfrmi_locate(net, &xi->p); | ||
680 | if (!xi) { | 680 | if (!xi) { |
681 | xi = netdev_priv(dev); | 681 | xi = netdev_priv(dev); |
682 | } else { | 682 | } else { |
@@ -684,7 +684,7 @@ static int xfrmi_changelink(struct net_device *dev, struct nlattr *tb[], | |||
684 | return -EEXIST; | 684 | return -EEXIST; |
685 | } | 685 | } |
686 | 686 | ||
687 | return xfrmi_update(xi, &xi->p); | 687 | return xfrmi_update(xi, &p); |
688 | } | 688 | } |
689 | 689 | ||
690 | static size_t xfrmi_get_size(const struct net_device *dev) | 690 | static size_t xfrmi_get_size(const struct net_device *dev) |