diff mbox series

[2/2] macsec: Fix frame loss in XPN mode when PN=0 bug

Message ID 20200306025523.63457-2-mayflowerera@gmail.com
State Changes Requested
Delegated to: David Miller
Headers show
Series [1/2] macsec: Backward compatibility bugfix of consts values | expand

Commit Message

Era Mayflower March 6, 2020, 2:55 a.m. UTC
According to IEEE 802.1aebw figure 10-5,
the PN of incoming frame can be 0 when XPN cipher suite is used.

Fixed `macsec_validate_skb` to fail on PN=0 only if we are not using XPN.

Depends on: macsec: Backward compatibility bugfix of consts values

Signed-off-by: Era Mayflower <mayflowerera@gmail.com>
---
 drivers/net/macsec.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
index aff28ee89..418e1b126 100644
--- a/drivers/net/macsec.c
+++ b/drivers/net/macsec.c
@@ -386,7 +386,7 @@  static const struct macsec_ops *macsec_get_ops(struct macsec_dev *macsec,
 }
 
 /* validate MACsec packet according to IEEE 802.1AE-2006 9.12 */
-static bool macsec_validate_skb(struct sk_buff *skb, u16 icv_len)
+static bool macsec_validate_skb(struct sk_buff *skb, u16 icv_len, bool xpn)
 {
 	struct macsec_eth_header *h = (struct macsec_eth_header *)skb->data;
 	int len = skb->len - 2 * ETH_ALEN;
@@ -411,8 +411,8 @@  static bool macsec_validate_skb(struct sk_buff *skb, u16 icv_len)
 	if (h->unused)
 		return false;
 
-	/* rx.pn != 0 (figure 10-5) */
-	if (!h->packet_number)
+	/* rx.pn != 0 if not XPN (figure 10-5) */
+	if (!h->packet_number && !xpn)
 		return false;
 
 	/* length check, f) g) h) i) */
@@ -1117,7 +1117,7 @@  static rx_handler_result_t macsec_handle_frame(struct sk_buff **pskb)
 	secy_stats = this_cpu_ptr(macsec->stats);
 	rxsc_stats = this_cpu_ptr(rx_sc->stats);
 
-	if (!macsec_validate_skb(skb, secy->icv_len)) {
+	if (!macsec_validate_skb(skb, secy->icv_len, secy->xpn)) {
 		u64_stats_update_begin(&secy_stats->syncp);
 		secy_stats->stats.InPktsBadTag++;
 		u64_stats_update_end(&secy_stats->syncp);