Skip to content

Commit ae5c3c8

Browse files
author
CKI Backport Bot
committed
macsec: read MACSEC_SA_ATTR_PN with nla_get_uint
JIRA: https://issues.redhat.com/browse/RHEL-115622 commit 030e1c4 Author: Sabrina Dubroca <sd@queasysnail.net> Date: Fri Aug 29 20:55:40 2025 +0200 macsec: read MACSEC_SA_ATTR_PN with nla_get_uint 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: CKI Backport Bot <cki-ci-bot+cki-gitlab-backport-bot@redhat.com>
1 parent a85d28a commit ae5c3c8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/net/macsec.c

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

18591859
if (tb_sa[MACSEC_SA_ATTR_PN]) {
18601860
spin_lock_bh(&rx_sa->lock);
1861-
rx_sa->next_pn = nla_get_u64(tb_sa[MACSEC_SA_ATTR_PN]);
1861+
rx_sa->next_pn = nla_get_uint(tb_sa[MACSEC_SA_ATTR_PN]);
18621862
spin_unlock_bh(&rx_sa->lock);
18631863
}
18641864

@@ -2100,7 +2100,7 @@ static int macsec_add_txsa(struct sk_buff *skb, struct genl_info *info)
21002100
}
21012101

21022102
spin_lock_bh(&tx_sa->lock);
2103-
tx_sa->next_pn = nla_get_u64(tb_sa[MACSEC_SA_ATTR_PN]);
2103+
tx_sa->next_pn = nla_get_uint(tb_sa[MACSEC_SA_ATTR_PN]);
21042104
spin_unlock_bh(&tx_sa->lock);
21052105

21062106
if (tb_sa[MACSEC_SA_ATTR_ACTIVE])
@@ -2412,7 +2412,7 @@ static int macsec_upd_txsa(struct sk_buff *skb, struct genl_info *info)
24122412

24132413
spin_lock_bh(&tx_sa->lock);
24142414
prev_pn = tx_sa->next_pn_halves;
2415-
tx_sa->next_pn = nla_get_u64(tb_sa[MACSEC_SA_ATTR_PN]);
2415+
tx_sa->next_pn = nla_get_uint(tb_sa[MACSEC_SA_ATTR_PN]);
24162416
spin_unlock_bh(&tx_sa->lock);
24172417
}
24182418

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

25112511
spin_lock_bh(&rx_sa->lock);
25122512
prev_pn = rx_sa->next_pn_halves;
2513-
rx_sa->next_pn = nla_get_u64(tb_sa[MACSEC_SA_ATTR_PN]);
2513+
rx_sa->next_pn = nla_get_uint(tb_sa[MACSEC_SA_ATTR_PN]);
25142514
spin_unlock_bh(&rx_sa->lock);
25152515
}
25162516

0 commit comments

Comments
 (0)