@@ -243,6 +243,7 @@ static struct macsec_cb *macsec_skb_cb(struct sk_buff *skb)
243
243
#define DEFAULT_SEND_SCI true
244
244
#define DEFAULT_ENCRYPT false
245
245
#define DEFAULT_ENCODING_SA 0
246
+ #define MACSEC_XPN_MAX_REPLAY_WINDOW (((1 << 30) - 1))
246
247
247
248
static bool send_sci (const struct macsec_secy * secy )
248
249
{
@@ -1697,7 +1698,7 @@ static bool validate_add_rxsa(struct nlattr **attrs)
1697
1698
return false;
1698
1699
1699
1700
if (attrs [MACSEC_SA_ATTR_PN ] &&
1700
- * ( u64 * ) nla_data (attrs [MACSEC_SA_ATTR_PN ]) == 0 )
1701
+ nla_get_u64 (attrs [MACSEC_SA_ATTR_PN ]) == 0 )
1701
1702
return false;
1702
1703
1703
1704
if (attrs [MACSEC_SA_ATTR_ACTIVE ]) {
@@ -1753,7 +1754,8 @@ static int macsec_add_rxsa(struct sk_buff *skb, struct genl_info *info)
1753
1754
}
1754
1755
1755
1756
pn_len = secy -> xpn ? MACSEC_XPN_PN_LEN : MACSEC_DEFAULT_PN_LEN ;
1756
- if (nla_len (tb_sa [MACSEC_SA_ATTR_PN ]) != pn_len ) {
1757
+ if (tb_sa [MACSEC_SA_ATTR_PN ] &&
1758
+ nla_len (tb_sa [MACSEC_SA_ATTR_PN ]) != pn_len ) {
1757
1759
pr_notice ("macsec: nl: add_rxsa: bad pn length: %d != %d\n" ,
1758
1760
nla_len (tb_sa [MACSEC_SA_ATTR_PN ]), pn_len );
1759
1761
rtnl_unlock ();
@@ -1769,7 +1771,7 @@ static int macsec_add_rxsa(struct sk_buff *skb, struct genl_info *info)
1769
1771
if (nla_len (tb_sa [MACSEC_SA_ATTR_SALT ]) != MACSEC_SALT_LEN ) {
1770
1772
pr_notice ("macsec: nl: add_rxsa: bad salt length: %d != %d\n" ,
1771
1773
nla_len (tb_sa [MACSEC_SA_ATTR_SALT ]),
1772
- MACSEC_SA_ATTR_SALT );
1774
+ MACSEC_SALT_LEN );
1773
1775
rtnl_unlock ();
1774
1776
return - EINVAL ;
1775
1777
}
@@ -1939,7 +1941,7 @@ static bool validate_add_txsa(struct nlattr **attrs)
1939
1941
if (nla_get_u8 (attrs [MACSEC_SA_ATTR_AN ]) >= MACSEC_NUM_AN )
1940
1942
return false;
1941
1943
1942
- if (nla_get_u32 (attrs [MACSEC_SA_ATTR_PN ]) == 0 )
1944
+ if (nla_get_u64 (attrs [MACSEC_SA_ATTR_PN ]) == 0 )
1943
1945
return false;
1944
1946
1945
1947
if (attrs [MACSEC_SA_ATTR_ACTIVE ]) {
@@ -2011,7 +2013,7 @@ static int macsec_add_txsa(struct sk_buff *skb, struct genl_info *info)
2011
2013
if (nla_len (tb_sa [MACSEC_SA_ATTR_SALT ]) != MACSEC_SALT_LEN ) {
2012
2014
pr_notice ("macsec: nl: add_txsa: bad salt length: %d != %d\n" ,
2013
2015
nla_len (tb_sa [MACSEC_SA_ATTR_SALT ]),
2014
- MACSEC_SA_ATTR_SALT );
2016
+ MACSEC_SALT_LEN );
2015
2017
rtnl_unlock ();
2016
2018
return - EINVAL ;
2017
2019
}
@@ -2293,7 +2295,7 @@ static bool validate_upd_sa(struct nlattr **attrs)
2293
2295
if (nla_get_u8 (attrs [MACSEC_SA_ATTR_AN ]) >= MACSEC_NUM_AN )
2294
2296
return false;
2295
2297
2296
- if (attrs [MACSEC_SA_ATTR_PN ] && nla_get_u32 (attrs [MACSEC_SA_ATTR_PN ]) == 0 )
2298
+ if (attrs [MACSEC_SA_ATTR_PN ] && nla_get_u64 (attrs [MACSEC_SA_ATTR_PN ]) == 0 )
2297
2299
return false;
2298
2300
2299
2301
if (attrs [MACSEC_SA_ATTR_ACTIVE ]) {
@@ -3745,9 +3747,6 @@ static int macsec_changelink_common(struct net_device *dev,
3745
3747
secy -> operational = tx_sa && tx_sa -> active ;
3746
3748
}
3747
3749
3748
- if (data [IFLA_MACSEC_WINDOW ])
3749
- secy -> replay_window = nla_get_u32 (data [IFLA_MACSEC_WINDOW ]);
3750
-
3751
3750
if (data [IFLA_MACSEC_ENCRYPT ])
3752
3751
tx_sc -> encrypt = !!nla_get_u8 (data [IFLA_MACSEC_ENCRYPT ]);
3753
3752
@@ -3793,6 +3792,16 @@ static int macsec_changelink_common(struct net_device *dev,
3793
3792
}
3794
3793
}
3795
3794
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
+
3796
3805
return 0 ;
3797
3806
}
3798
3807
@@ -3822,7 +3831,7 @@ static int macsec_changelink(struct net_device *dev, struct nlattr *tb[],
3822
3831
3823
3832
ret = macsec_changelink_common (dev , data );
3824
3833
if (ret )
3825
- return ret ;
3834
+ goto cleanup ;
3826
3835
3827
3836
/* If h/w offloading is available, propagate to the device */
3828
3837
if (macsec_is_offloaded (macsec )) {
0 commit comments