Skip to content

Commit 711a28d

Browse files
atenartgregkh
authored andcommitted
net: macsec: fix the length used to copy the key for offloading
[ Upstream commit 1f7fe51 ] The key length used when offloading macsec to Ethernet or PHY drivers was set to MACSEC_KEYID_LEN (16), which is an issue as: - This was never meant to be the key length. - The key length can be > 16. Fix this by using MACSEC_MAX_KEY_LEN to store the key (the max length accepted in uAPI) and secy->key_len to copy it. Fixes: 3cf3227 ("net: macsec: hardware offloading infrastructure") Reported-by: Lior Nahmanson <liorna@nvidia.com> Signed-off-by: Antoine Tenart <atenart@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent c764f2d commit 711a28d

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

‎drivers/net/macsec.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1818,7 +1818,7 @@ static int macsec_add_rxsa(struct sk_buff *skb, struct genl_info *info)
18181818
ctx.sa.rx_sa = rx_sa;
18191819
ctx.secy = secy;
18201820
memcpy(ctx.sa.key, nla_data(tb_sa[MACSEC_SA_ATTR_KEY]),
1821-
MACSEC_KEYID_LEN);
1821+
secy->key_len);
18221822

18231823
err = macsec_offload(ops->mdo_add_rxsa, &ctx);
18241824
if (err)
@@ -2060,7 +2060,7 @@ static int macsec_add_txsa(struct sk_buff *skb, struct genl_info *info)
20602060
ctx.sa.tx_sa = tx_sa;
20612061
ctx.secy = secy;
20622062
memcpy(ctx.sa.key, nla_data(tb_sa[MACSEC_SA_ATTR_KEY]),
2063-
MACSEC_KEYID_LEN);
2063+
secy->key_len);
20642064

20652065
err = macsec_offload(ops->mdo_add_txsa, &ctx);
20662066
if (err)

‎include/net/macsec.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ struct macsec_context {
241241
struct macsec_rx_sc *rx_sc;
242242
struct {
243243
unsigned char assoc_num;
244-
u8 key[MACSEC_KEYID_LEN];
244+
u8 key[MACSEC_MAX_KEY_LEN];
245245
union {
246246
struct macsec_rx_sa *rx_sa;
247247
struct macsec_tx_sa *tx_sa;

0 commit comments

Comments
 (0)