Skip to content

Commit 60aa57d

Browse files
qsnopsiff
authored andcommitted
macsec: read MACSEC_SA_ATTR_PN with nla_get_uint
[ Upstream commit 030e1c4 ] The code currently reads both U32 attributes and U64 attributes as U64, so when a U32 attribute is provided by userspace (ie, when not using XPN), on big endian systems, we'll load that value into the upper 32bits of the next_pn field instead of the lower 32bits. This means that the value that userspace provided is ignored (we only care about the lower 32bits for non-XPN), and we'll start using PNs from 0. Switch to nla_get_uint, which will read the value correctly on all arches, whether it's 32b or 64b. Fixes: 48ef50f ("macsec: Netlink support of XPN cipher suites (IEEE 802.1AEbw)") Signed-off-by: Sabrina Dubroca <sd@queasysnail.net> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/1c1df1661b89238caf5beefb84a10ebfd56c66ea.1756459839.git.sd@queasysnail.net Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org> (cherry picked from commit 668f4f6382c3644d22a1168f62294aaaba60deec)
1 parent 6923b69 commit 60aa57d

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

drivers/net/macsec.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1840,7 +1840,7 @@ static int macsec_add_rxsa(struct sk_buff *skb, struct genl_info *info)
18401840

18411841
if (tb_sa[MACSEC_SA_ATTR_PN]) {
18421842
spin_lock_bh(&rx_sa->lock);
1843-
rx_sa->next_pn = nla_get_u64(tb_sa[MACSEC_SA_ATTR_PN]);
1843+
rx_sa->next_pn = nla_get_uint(tb_sa[MACSEC_SA_ATTR_PN]);
18441844
spin_unlock_bh(&rx_sa->lock);
18451845
}
18461846

@@ -2082,7 +2082,7 @@ static int macsec_add_txsa(struct sk_buff *skb, struct genl_info *info)
20822082
}
20832083

20842084
spin_lock_bh(&tx_sa->lock);
2085-
tx_sa->next_pn = nla_get_u64(tb_sa[MACSEC_SA_ATTR_PN]);
2085+
tx_sa->next_pn = nla_get_uint(tb_sa[MACSEC_SA_ATTR_PN]);
20862086
spin_unlock_bh(&tx_sa->lock);
20872087

20882088
if (tb_sa[MACSEC_SA_ATTR_ACTIVE])
@@ -2394,7 +2394,7 @@ static int macsec_upd_txsa(struct sk_buff *skb, struct genl_info *info)
23942394

23952395
spin_lock_bh(&tx_sa->lock);
23962396
prev_pn = tx_sa->next_pn_halves;
2397-
tx_sa->next_pn = nla_get_u64(tb_sa[MACSEC_SA_ATTR_PN]);
2397+
tx_sa->next_pn = nla_get_uint(tb_sa[MACSEC_SA_ATTR_PN]);
23982398
spin_unlock_bh(&tx_sa->lock);
23992399
}
24002400

@@ -2492,7 +2492,7 @@ static int macsec_upd_rxsa(struct sk_buff *skb, struct genl_info *info)
24922492

24932493
spin_lock_bh(&rx_sa->lock);
24942494
prev_pn = rx_sa->next_pn_halves;
2495-
rx_sa->next_pn = nla_get_u64(tb_sa[MACSEC_SA_ATTR_PN]);
2495+
rx_sa->next_pn = nla_get_uint(tb_sa[MACSEC_SA_ATTR_PN]);
24962496
spin_unlock_bh(&rx_sa->lock);
24972497
}
24982498

0 commit comments

Comments
 (0)