Thread View: linux.kernel.netdev
3 messages
3 total messages
Started by Jérémy Jean
Thu, 08 Oct 2026 08:06
[PATCH net v2] macsec: prevent AES-GCM nonce reuse after packet number wrap
Author: Jérémy Jean
Date: Thu, 08 Oct 2026 08:06
Date: Thu, 08 Oct 2026 08:06
52 lines
8466 bytes
8466 bytes
After allocating the last valid packet number, MACsec wraps next_pn to
zero and deactivates the transmit SA. This happens for both 32- and
64-bit types of packet numbers (at values 0xffffffff and
0xffffffffffffffff, respectively).
TX packets that were still getting processed during deactivation keep
being processed and then receive packet numbers. The first gets 0 and
is correctly dropped, but next_pn is incremented to 1, which makes the
next packet take number 1. It then does not get dropped and may induce
a reuse of the AES-GCM nonce corresponding to value 1.
This race affects TX packets that have already passed the SA activity
check: packets that observe the inactive SA are correctly dropped.
Reactivating the SA after PN wrap without a packet number can also
cause nonce reuse. Keep next_pn at 0 after wrap, even if the SA is
reactivated, so further packet number allocations return 0 and the
corresponding packets are dropped.
Fixes: c09440f7dcb3 ("macsec: introduce IEEE 802.1AE driver")
Cc: stable@vger.kernel.org
Assisted-by: LLM
Signed-off-by: Jérémy Jean <Jeremy.Jean@oss.cyber.gouv.fr>
---
drivers/net/macsec.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
index 78a19b134632..233391acebb0 100644
--- a/drivers/net/macsec.c
+++ b/drivers/net/macsec.c
@@ -486,6 +486,9 @@ static pn_t tx_sa_update_pn(struct macsec_tx_sa *tx_sa,
spin_lock_bh(&tx_sa->lock);
pn = tx_sa->next_pn_halves;
+ if (unlikely(pn.full64 == 0))
+ goto out;
+
if (secy->xpn)
tx_sa->next_pn++;
else
@@ -493,6 +496,8 @@ static pn_t tx_sa_update_pn(struct macsec_tx_sa *tx_sa,
if (tx_sa->next_pn == 0)
__macsec_pn_wrapped(secy, tx_sa);
+
+out:
spin_unlock_bh(&tx_sa->lock);
return pn;
--
2.47.3
Re: [PATCH net v2] macsec: prevent AES-GCM nonce reuse after packet number wrap
Author: netdev-bot+sinfo
Date: Thu, 08 Oct 2026 08:15
Date: Thu, 08 Oct 2026 08:15
22 lines
6413 bytes
6413 bytes
Hi! This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information: - How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan. - Whether the issue was actually triggered, or is only theoretical (e.g. found by code inspection). If it was triggered please include the symptoms, like the stack trace or error messages. Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account. If the series needs another revision for other reasons, please include the information in the commit messages then. The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.
Re: [PATCH net v2] macsec: prevent AES-GCM nonce reuse after packet number wrap
Author: patchwork-bot+netdevbpf
Date: Fri, 16 Oct 2026 01:00
Date: Fri, 16 Oct 2026 01:00
28 lines
6621 bytes
6621 bytes
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 8 Oct 2026 08:06:26 +0000 you wrote:
> After allocating the last valid packet number, MACsec wraps next_pn to
> zero and deactivates the transmit SA. This happens for both 32- and
> 64-bit types of packet numbers (at values 0xffffffff and
> 0xffffffffffffffff, respectively).
>
> TX packets that were still getting processed during deactivation keep
> being processed and then receive packet numbers. The first gets 0 and
> is correctly dropped, but next_pn is incremented to 1, which makes the
> next packet take number 1. It then does not get dropped and may induce
> a reuse of the AES-GCM nonce corresponding to value 1.
>
> [...]
Here is the summary with links:
- [net,v2] macsec: prevent AES-GCM nonce reuse after packet number wrap
https://git.kernel.org/netdev/net-next/c/94d51c59f0a8
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads