Skip to content

Commit b07a0e2

Browse files
qsndavem330
authored andcommitted
macsec: limit replay window size with XPN
IEEE 802.1AEbw-2013 (section 10.7.8) specifies that the maximum value of the replay window is 2^30-1, to help with recovery of the upper bits of the PN. To avoid leaving the existing macsec device in an inconsistent state if this test fails during changelink, reuse the cleanup mechanism introduced for HW offload. This wasn't needed until now because macsec_changelink_common could not fail during changelink, as modifying the cipher suite was not allowed. Finally, this must happen after handling IFLA_MACSEC_CIPHER_SUITE so that secy->xpn is set. Fixes: 48ef50f ("macsec: Netlink support of XPN cipher suites (IEEE 802.1AEbw)") Signed-off-by: Sabrina Dubroca <sd@queasysnail.net> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 3240eac commit b07a0e2

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

drivers/net/macsec.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ static struct macsec_cb *macsec_skb_cb(struct sk_buff *skb)
243243
#define DEFAULT_SEND_SCI true
244244
#define DEFAULT_ENCRYPT false
245245
#define DEFAULT_ENCODING_SA 0
246+
#define MACSEC_XPN_MAX_REPLAY_WINDOW (((1 << 30) - 1))
246247

247248
static bool send_sci(const struct macsec_secy *secy)
248249
{
@@ -3746,9 +3747,6 @@ static int macsec_changelink_common(struct net_device *dev,
37463747
secy->operational = tx_sa && tx_sa->active;
37473748
}
37483749

3749-
if (data[IFLA_MACSEC_WINDOW])
3750-
secy->replay_window = nla_get_u32(data[IFLA_MACSEC_WINDOW]);
3751-
37523750
if (data[IFLA_MACSEC_ENCRYPT])
37533751
tx_sc->encrypt = !!nla_get_u8(data[IFLA_MACSEC_ENCRYPT]);
37543752

@@ -3794,6 +3792,16 @@ static int macsec_changelink_common(struct net_device *dev,
37943792
}
37953793
}
37963794

3795+
if (data[IFLA_MACSEC_WINDOW]) {
3796+
secy->replay_window = nla_get_u32(data[IFLA_MACSEC_WINDOW]);
3797+
3798+
/* IEEE 802.1AEbw-2013 10.7.8 - maximum replay window
3799+
* for XPN cipher suites */
3800+
if (secy->xpn &&
3801+
secy->replay_window > MACSEC_XPN_MAX_REPLAY_WINDOW)
3802+
return -EINVAL;
3803+
}
3804+
37973805
return 0;
37983806
}
37993807

@@ -3823,7 +3831,7 @@ static int macsec_changelink(struct net_device *dev, struct nlattr *tb[],
38233831

38243832
ret = macsec_changelink_common(dev, data);
38253833
if (ret)
3826-
return ret;
3834+
goto cleanup;
38273835

38283836
/* If h/w offloading is available, propagate to the device */
38293837
if (macsec_is_offloaded(macsec)) {

0 commit comments

Comments
 (0)