Skip to content

Commit 8dce439

Browse files
antonyantonyklassert
authored andcommitted
xfrm: interface with if_id 0 should return error
xfrm interface if_id = 0 would cause xfrm policy lookup errors since Commit 9f8550e. Now explicitly fail to create an xfrm interface when if_id = 0 With this commit: ip link add ipsec0 type xfrm dev lo if_id 0 Error: if_id must be non zero. v1->v2 change: - add Fixes: tag Fixes: 9f8550e ("xfrm: fix disable_xfrm sysctl when used on xfrm interfaces") Signed-off-by: Antony Antony <[email protected]> Reviewed-by: Eyal Birger <[email protected]> Signed-off-by: Steffen Klassert <[email protected]>
1 parent 7770a39 commit 8dce439

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

net/xfrm/xfrm_interface.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -637,11 +637,16 @@ static int xfrmi_newlink(struct net *src_net, struct net_device *dev,
637637
struct netlink_ext_ack *extack)
638638
{
639639
struct net *net = dev_net(dev);
640-
struct xfrm_if_parms p;
640+
struct xfrm_if_parms p = {};
641641
struct xfrm_if *xi;
642642
int err;
643643

644644
xfrmi_netlink_parms(data, &p);
645+
if (!p.if_id) {
646+
NL_SET_ERR_MSG(extack, "if_id must be non zero");
647+
return -EINVAL;
648+
}
649+
645650
xi = xfrmi_locate(net, &p);
646651
if (xi)
647652
return -EEXIST;
@@ -666,7 +671,12 @@ static int xfrmi_changelink(struct net_device *dev, struct nlattr *tb[],
666671
{
667672
struct xfrm_if *xi = netdev_priv(dev);
668673
struct net *net = xi->net;
669-
struct xfrm_if_parms p;
674+
struct xfrm_if_parms p = {};
675+
676+
if (!p.if_id) {
677+
NL_SET_ERR_MSG(extack, "if_id must be non zero");
678+
return -EINVAL;
679+
}
670680

671681
xfrmi_netlink_parms(data, &p);
672682
xi = xfrmi_locate(net, &p);

0 commit comments

Comments
 (0)