Netdev List
 help / color / mirror / Atom feed
From: Sabrina Dubroca <sd@queasysnail.net>
To: Sung Byeongchan <tjdqudcks0424@naver.com>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH net] macsec: reject replays after non-XPN receive PN exhaustion
Date: Thu, 8 Oct 2026 18:35:39 +0200	[thread overview]
Message-ID: <asfGW5xAQ9_dCN71@krikkit> (raw)
In-Reply-To: <20261008082550.349487-1-tjdqudcks0424@naver.com>

2026-10-08, 17:25:50 +0900, Sung Byeongchan wrote:
> When a non-XPN RXSA accepts PN U32_MAX, advancing the receive PN cannot
> represent the next value. The replay checks subsequently accept the same
> authenticated terminal frame again.

And in XPN? I don't see anything checking that .upper didn't wrap, so
we'll accept replays of the first chunk of sequence numbers?

It also feels strange to have an "exhausted" bit that only ever gets
set for !xpn.

> Record receive-SA exhaustion after accepting the legitimate terminal frame
> and reject subsequent frames until userspace explicitly resets the PN. Keep
> XPN behavior unchanged. Preserve the exhaustion state if a hardware-offload
> PN update fails and the old PN is restored.
> 
> The identical terminal-PN frame crossed the controlled port twice in all
> three baseline runs. All three fixed runs rejected the replay. PN max-1,
> fresh terminal-frame, and bad-ICV controls retained their expected
> behavior.

We should also have selftests for all those limit cases (for 32b:
exhaustion/wrap, for XPN: both upper32 increase and exhaustion).

> diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
> index 78a19b1346321..906108e10b32d 100644
> --- a/drivers/net/macsec.c
> +++ b/drivers/net/macsec.c
> @@ -750,8 +750,10 @@ static bool macsec_post_decrypt(struct sk_buff *skb, struct macsec_secy *secy, u
>  	/* Now perform replay protection check again
>  	 * (see IEEE 802.1AE-2006 figure 10-5)
>  	 */
> -	if (secy->replay_protect && pn < lowest_pn &&
> -	    (!secy->xpn || pn_same_half(pn, lowest_pn))) {
> +	if (secy->replay_protect &&
> +	    (rx_sa->exhausted ||
> +	     (pn < lowest_pn &&
> +	      (!secy->xpn || pn_same_half(pn, lowest_pn))))) {

The code you're modifying wasn't particularly nice, but this is
completely unreadable. And there's another variant of this test
written in a slightly different, but also completely unreadable, for
the pre-check (well, pn_same_half doesn't take the same reference for
some mysterious reason).

-- 
Sabrina

      parent reply	other threads:[~2026-10-08 16:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-08  8:25 [PATCH net] macsec: reject replays after non-XPN receive PN exhaustion Sung Byeongchan
2026-10-08  8:30 ` netdev-bot+sinfo
2026-10-08  8:39   ` 성병찬
2026-10-08 16:35 ` Sabrina Dubroca [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=asfGW5xAQ9_dCN71@krikkit \
    --to=sd@queasysnail.net \
    --cc=netdev@vger.kernel.org \
    --cc=tjdqudcks0424@naver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox