@@ -85,7 +85,7 @@ struct gcm_iv {
85
85
* @tfm: crypto struct, key storage
86
86
*/
87
87
struct macsec_key {
88
- u64 id ;
88
+ u8 id [ MACSEC_KEYID_LEN ] ;
89
89
struct crypto_aead * tfm ;
90
90
};
91
91
@@ -1529,7 +1529,8 @@ static const struct nla_policy macsec_genl_sa_policy[NUM_MACSEC_SA_ATTR] = {
1529
1529
[MACSEC_SA_ATTR_AN ] = { .type = NLA_U8 },
1530
1530
[MACSEC_SA_ATTR_ACTIVE ] = { .type = NLA_U8 },
1531
1531
[MACSEC_SA_ATTR_PN ] = { .type = NLA_U32 },
1532
- [MACSEC_SA_ATTR_KEYID ] = { .type = NLA_U64 },
1532
+ [MACSEC_SA_ATTR_KEYID ] = { .type = NLA_BINARY ,
1533
+ .len = MACSEC_KEYID_LEN , },
1533
1534
[MACSEC_SA_ATTR_KEY ] = { .type = NLA_BINARY ,
1534
1535
.len = MACSEC_MAX_KEY_LEN , },
1535
1536
};
@@ -1576,6 +1577,9 @@ static bool validate_add_rxsa(struct nlattr **attrs)
1576
1577
return false;
1577
1578
}
1578
1579
1580
+ if (nla_len (attrs [MACSEC_SA_ATTR_KEYID ]) != MACSEC_KEYID_LEN )
1581
+ return false;
1582
+
1579
1583
return true;
1580
1584
}
1581
1585
@@ -1641,7 +1645,7 @@ static int macsec_add_rxsa(struct sk_buff *skb, struct genl_info *info)
1641
1645
if (tb_sa [MACSEC_SA_ATTR_ACTIVE ])
1642
1646
rx_sa -> active = !!nla_get_u8 (tb_sa [MACSEC_SA_ATTR_ACTIVE ]);
1643
1647
1644
- rx_sa -> key .id = nla_get_u64 ( tb_sa [MACSEC_SA_ATTR_KEYID ] );
1648
+ nla_memcpy ( rx_sa -> key .id , tb_sa [MACSEC_SA_ATTR_KEY ], MACSEC_KEYID_LEN );
1645
1649
rx_sa -> sc = rx_sc ;
1646
1650
rcu_assign_pointer (rx_sc -> sa [assoc_num ], rx_sa );
1647
1651
@@ -1722,6 +1726,9 @@ static bool validate_add_txsa(struct nlattr **attrs)
1722
1726
return false;
1723
1727
}
1724
1728
1729
+ if (nla_len (attrs [MACSEC_SA_ATTR_KEYID ]) != MACSEC_KEYID_LEN )
1730
+ return false;
1731
+
1725
1732
return true;
1726
1733
}
1727
1734
@@ -1777,7 +1784,7 @@ static int macsec_add_txsa(struct sk_buff *skb, struct genl_info *info)
1777
1784
return - ENOMEM ;
1778
1785
}
1779
1786
1780
- tx_sa -> key .id = nla_get_u64 ( tb_sa [MACSEC_SA_ATTR_KEYID ] );
1787
+ nla_memcpy ( tx_sa -> key .id , tb_sa [MACSEC_SA_ATTR_KEY ], MACSEC_KEYID_LEN );
1781
1788
1782
1789
spin_lock_bh (& tx_sa -> lock );
1783
1790
tx_sa -> next_pn = nla_get_u32 (tb_sa [MACSEC_SA_ATTR_PN ]);
@@ -2318,7 +2325,7 @@ static int dump_secy(struct macsec_secy *secy, struct net_device *dev,
2318
2325
2319
2326
if (nla_put_u8 (skb , MACSEC_SA_ATTR_AN , i ) ||
2320
2327
nla_put_u32 (skb , MACSEC_SA_ATTR_PN , tx_sa -> next_pn ) ||
2321
- nla_put_u64 (skb , MACSEC_SA_ATTR_KEYID , tx_sa -> key .id ) ||
2328
+ nla_put (skb , MACSEC_SA_ATTR_KEYID , MACSEC_KEYID_LEN , tx_sa -> key .id ) ||
2322
2329
nla_put_u8 (skb , MACSEC_SA_ATTR_ACTIVE , tx_sa -> active )) {
2323
2330
nla_nest_cancel (skb , txsa_nest );
2324
2331
nla_nest_cancel (skb , txsa_list );
@@ -2419,7 +2426,7 @@ static int dump_secy(struct macsec_secy *secy, struct net_device *dev,
2419
2426
2420
2427
if (nla_put_u8 (skb , MACSEC_SA_ATTR_AN , i ) ||
2421
2428
nla_put_u32 (skb , MACSEC_SA_ATTR_PN , rx_sa -> next_pn ) ||
2422
- nla_put_u64 (skb , MACSEC_SA_ATTR_KEYID , rx_sa -> key .id ) ||
2429
+ nla_put (skb , MACSEC_SA_ATTR_KEYID , MACSEC_KEYID_LEN , rx_sa -> key .id ) ||
2423
2430
nla_put_u8 (skb , MACSEC_SA_ATTR_ACTIVE , rx_sa -> active )) {
2424
2431
nla_nest_cancel (skb , rxsa_nest );
2425
2432
nla_nest_cancel (skb , rxsc_nest );
0 commit comments