aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/macsec.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/macsec.c')
-rw-r--r--drivers/net/macsec.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
index 3add2c4aac21..460740ccc238 100644
--- a/drivers/net/macsec.c
+++ b/drivers/net/macsec.c
@@ -85,7 +85,7 @@ struct gcm_iv {
85 * @tfm: crypto struct, key storage 85 * @tfm: crypto struct, key storage
86 */ 86 */
87struct macsec_key { 87struct macsec_key {
88 u64 id; 88 u8 id[MACSEC_KEYID_LEN];
89 struct crypto_aead *tfm; 89 struct crypto_aead *tfm;
90}; 90};
91 91
@@ -1530,7 +1530,8 @@ static const struct nla_policy macsec_genl_sa_policy[NUM_MACSEC_SA_ATTR] = {
1530 [MACSEC_SA_ATTR_AN] = { .type = NLA_U8 }, 1530 [MACSEC_SA_ATTR_AN] = { .type = NLA_U8 },
1531 [MACSEC_SA_ATTR_ACTIVE] = { .type = NLA_U8 }, 1531 [MACSEC_SA_ATTR_ACTIVE] = { .type = NLA_U8 },
1532 [MACSEC_SA_ATTR_PN] = { .type = NLA_U32 }, 1532 [MACSEC_SA_ATTR_PN] = { .type = NLA_U32 },
1533 [MACSEC_SA_ATTR_KEYID] = { .type = NLA_U64 }, 1533 [MACSEC_SA_ATTR_KEYID] = { .type = NLA_BINARY,
1534 .len = MACSEC_KEYID_LEN, },
1534 [MACSEC_SA_ATTR_KEY] = { .type = NLA_BINARY, 1535 [MACSEC_SA_ATTR_KEY] = { .type = NLA_BINARY,
1535 .len = MACSEC_MAX_KEY_LEN, }, 1536 .len = MACSEC_MAX_KEY_LEN, },
1536}; 1537};
@@ -1577,6 +1578,9 @@ static bool validate_add_rxsa(struct nlattr **attrs)
1577 return false; 1578 return false;
1578 } 1579 }
1579 1580
1581 if (nla_len(attrs[MACSEC_SA_ATTR_KEYID]) != MACSEC_KEYID_LEN)
1582 return false;
1583
1580 return true; 1584 return true;
1581} 1585}
1582 1586
@@ -1642,7 +1646,7 @@ static int macsec_add_rxsa(struct sk_buff *skb, struct genl_info *info)
1642 if (tb_sa[MACSEC_SA_ATTR_ACTIVE]) 1646 if (tb_sa[MACSEC_SA_ATTR_ACTIVE])
1643 rx_sa->active = !!nla_get_u8(tb_sa[MACSEC_SA_ATTR_ACTIVE]); 1647 rx_sa->active = !!nla_get_u8(tb_sa[MACSEC_SA_ATTR_ACTIVE]);
1644 1648
1645 rx_sa->key.id = nla_get_u64(tb_sa[MACSEC_SA_ATTR_KEYID]); 1649 nla_memcpy(rx_sa->key.id, tb_sa[MACSEC_SA_ATTR_KEY], MACSEC_KEYID_LEN);
1646 rx_sa->sc = rx_sc; 1650 rx_sa->sc = rx_sc;
1647 rcu_assign_pointer(rx_sc->sa[assoc_num], rx_sa); 1651 rcu_assign_pointer(rx_sc->sa[assoc_num], rx_sa);
1648 1652
@@ -1723,6 +1727,9 @@ static bool validate_add_txsa(struct nlattr **attrs)
1723 return false; 1727 return false;
1724 } 1728 }
1725 1729
1730 if (nla_len(attrs[MACSEC_SA_ATTR_KEYID]) != MACSEC_KEYID_LEN)
1731 return false;
1732
1726 return true; 1733 return true;
1727} 1734}
1728 1735
@@ -1778,7 +1785,7 @@ static int macsec_add_txsa(struct sk_buff *skb, struct genl_info *info)
1778 return -ENOMEM; 1785 return -ENOMEM;
1779 } 1786 }
1780 1787
1781 tx_sa->key.id = nla_get_u64(tb_sa[MACSEC_SA_ATTR_KEYID]); 1788 nla_memcpy(tx_sa->key.id, tb_sa[MACSEC_SA_ATTR_KEY], MACSEC_KEYID_LEN);
1782 1789
1783 spin_lock_bh(&tx_sa->lock); 1790 spin_lock_bh(&tx_sa->lock);
1784 tx_sa->next_pn = nla_get_u32(tb_sa[MACSEC_SA_ATTR_PN]); 1791 tx_sa->next_pn = nla_get_u32(tb_sa[MACSEC_SA_ATTR_PN]);
@@ -2365,9 +2372,7 @@ static int dump_secy(struct macsec_secy *secy, struct net_device *dev,
2365 2372
2366 if (nla_put_u8(skb, MACSEC_SA_ATTR_AN, i) || 2373 if (nla_put_u8(skb, MACSEC_SA_ATTR_AN, i) ||
2367 nla_put_u32(skb, MACSEC_SA_ATTR_PN, tx_sa->next_pn) || 2374 nla_put_u32(skb, MACSEC_SA_ATTR_PN, tx_sa->next_pn) ||
2368 nla_put_u64_64bit(skb, MACSEC_SA_ATTR_KEYID, 2375 nla_put(skb, MACSEC_SA_ATTR_KEYID, MACSEC_KEYID_LEN, tx_sa->key.id) ||
2369 tx_sa->key.id,
2370 MACSEC_SA_ATTR_PAD) ||
2371 nla_put_u8(skb, MACSEC_SA_ATTR_ACTIVE, tx_sa->active)) { 2376 nla_put_u8(skb, MACSEC_SA_ATTR_ACTIVE, tx_sa->active)) {
2372 nla_nest_cancel(skb, txsa_nest); 2377 nla_nest_cancel(skb, txsa_nest);
2373 nla_nest_cancel(skb, txsa_list); 2378 nla_nest_cancel(skb, txsa_list);
@@ -2469,9 +2474,7 @@ static int dump_secy(struct macsec_secy *secy, struct net_device *dev,
2469 2474
2470 if (nla_put_u8(skb, MACSEC_SA_ATTR_AN, i) || 2475 if (nla_put_u8(skb, MACSEC_SA_ATTR_AN, i) ||
2471 nla_put_u32(skb, MACSEC_SA_ATTR_PN, rx_sa->next_pn) || 2476 nla_put_u32(skb, MACSEC_SA_ATTR_PN, rx_sa->next_pn) ||
2472 nla_put_u64_64bit(skb, MACSEC_SA_ATTR_KEYID, 2477 nla_put(skb, MACSEC_SA_ATTR_KEYID, MACSEC_KEYID_LEN, rx_sa->key.id) ||
2473 rx_sa->key.id,
2474 MACSEC_SA_ATTR_PAD) ||
2475 nla_put_u8(skb, MACSEC_SA_ATTR_ACTIVE, rx_sa->active)) { 2478 nla_put_u8(skb, MACSEC_SA_ATTR_ACTIVE, rx_sa->active)) {
2476 nla_nest_cancel(skb, rxsa_nest); 2479 nla_nest_cancel(skb, rxsa_nest);
2477 nla_nest_cancel(skb, rxsc_nest); 2480 nla_nest_cancel(skb, rxsc_nest);