Skip to contentSkip to conversation

macsec: Backward compatibility bugfix of consts values

PATCH In review Era Mayflower 2 participants 3 messages Mar 5, 2020 – Mar 7, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 macsec: Backward compatibility bugfix of consts values

Fixed a compatibility bug, the value of the following consts changes:
* IFLA_MACSEC_PAD (include/uapi/linux/if_link.h)
* MACSEC_SECY_ATTR_PAD (include/uapi/linux/if_macsec.h)
* MACSEC_RXSC_ATTR_PAD (include/uapi/linux/if_macsec.h)

Depends on: macsec: Netlink support of XPN cipher suites (IEEE 802.1AEbw)

---
 include/uapi/linux/if_link.h   | 2 +-
 include/uapi/linux/if_macsec.h | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
include/uapi/linux/if_link.h +1 -1
index ee424d915..383316421 100644
@@ -462,9 +462,9 @@ enum {
 	IFLA_MACSEC_SCB,
 	IFLA_MACSEC_REPLAY_PROTECT,
 	IFLA_MACSEC_VALIDATION,
+	IFLA_MACSEC_PAD,
 	IFLA_MACSEC_SSCI,
 	IFLA_MACSEC_SALT,
-	IFLA_MACSEC_PAD,
 	__IFLA_MACSEC_MAX,
 };
 
include/uapi/linux/if_macsec.h +2 -2
index c8fab9673..a1132107d 100644
@@ -68,9 +68,9 @@ enum macsec_secy_attrs {
 	MACSEC_SECY_ATTR_INC_SCI,
 	MACSEC_SECY_ATTR_ES,
 	MACSEC_SECY_ATTR_SCB,
+	MACSEC_SECY_ATTR_PAD,
 	MACSEC_SECY_ATTR_SSCI,
 	MACSEC_SECY_ATTR_SALT,
-	MACSEC_SECY_ATTR_PAD,
 	__MACSEC_SECY_ATTR_END,
 	NUM_MACSEC_SECY_ATTR = __MACSEC_SECY_ATTR_END,
 	MACSEC_SECY_ATTR_MAX = __MACSEC_SECY_ATTR_END - 1,
@@ -82,8 +82,8 @@ enum macsec_rxsc_attrs {
 	MACSEC_RXSC_ATTR_ACTIVE,  /* config/dump, u8 0..1 */
 	MACSEC_RXSC_ATTR_SA_LIST, /* dump, nested */
 	MACSEC_RXSC_ATTR_STATS,   /* dump, nested, macsec_rxsc_stats_attr */
-	MACSEC_RXSC_ATTR_SSCI,    /* config/dump, u32 */
 	MACSEC_RXSC_ATTR_PAD,
+	MACSEC_RXSC_ATTR_SSCI,    /* config/dump, u32 */
 	__MACSEC_RXSC_ATTR_END,
 	NUM_MACSEC_RXSC_ATTR = __MACSEC_RXSC_ATTR_END,
 	MACSEC_RXSC_ATTR_MAX = __MACSEC_RXSC_ATTR_END - 1,
Signature · 1 line
2.20.1
#1 lore raw

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

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

---
 drivers/net/macsec.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/macsec.c +4 -4
index aff28ee89..418e1b126 100644
@@ -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);
Signature · 1 line
2.20.1
maintainer
#2 lore raw
In reply to Era Mayflower

From: Era Mayflower <[email protected]>
Date: Fri, 6 Mar 2020 02:55:22 +0000

Quoted 8 lines

Fixed a compatibility bug, the value of the following consts changes:
* IFLA_MACSEC_PAD (include/uapi/linux/if_link.h)
* MACSEC_SECY_ATTR_PAD (include/uapi/linux/if_macsec.h)
* MACSEC_RXSC_ATTR_PAD (include/uapi/linux/if_macsec.h)

Depends on: macsec: Netlink support of XPN cipher suites (IEEE 802.1AEbw)

Fix your original patches so that they don't have these bugs, and then resubmit that.