From: Junrui Luo via B4 Relay <devnull+moonafterrain.outlook.com@kernel.org>
To: Sabrina Dubroca <sd@queasysnail.net>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>,
"Radu Pirea (NXP OSS)" <radu-nicolae.pirea@oss.nxp.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Yuhao Jiang <danisjiang@gmail.com>,
stable@vger.kernel.org, Junrui Luo <moonafterrain@outlook.com>
Subject: [PATCH net] macsec: check offload ops before inserting TX tag
Date: Wed, 05 Aug 2026 12:52:10 +0800 [thread overview]
Message-ID: <20260805-macsec-fixes-v1-1-634d7679a030@outlook.com> (raw)
From: Junrui Luo <moonafterrain@outlook.com>
macsec_insert_tx_tag() takes the ops pointer returned by
macsec_get_ops() and dereferences it straight away:
ops = macsec_get_ops(macsec, &ctx);
skb_final_len = skb->len - ETH_HLEN + ops->needed_headroom +
ops->needed_tailroom;
macsec_get_ops() returns NULL whenever the offload is no longer live:
for MACSEC_OFFLOAD_PHY, macsec_check_offload() requires
real_dev->phydev to still be attached.
phy_detach() clears real_dev->phydev, e.g. when the lower device is
brought down and its driver calls phy_disconnect() from ndo_stop(),
when the PHY driver is unbound, or when an SFP module is removed under
phylink. A frame sent after that point reaches macsec_insert_tx_tag()
with ops == NULL and oopses.
Check the pointer, as every other macsec_get_ops() caller already
does, and drop the frame through the existing cleanup path.
Fixes: a73d8779d61a ("net: macsec: introduce mdo_insert_tx_tag")
Reported-by: Yuhao Jiang <danisjiang@gmail.com>
Assisted-by: Claude:claude-opus-5
Cc: stable@vger.kernel.org
Signed-off-by: Junrui Luo <moonafterrain@outlook.com>
---
drivers/net/macsec.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
index ee0e2eb7dbc6..86c8009dcfa9 100644
--- a/drivers/net/macsec.c
+++ b/drivers/net/macsec.c
@@ -3436,6 +3436,11 @@ static struct sk_buff *macsec_insert_tx_tag(struct sk_buff *skb,
int err;
ops = macsec_get_ops(macsec, &ctx);
+ if (unlikely(!ops)) {
+ err = -EOPNOTSUPP;
+ goto cleanup;
+ }
+
skb_final_len = skb->len - ETH_HLEN + ops->needed_headroom +
ops->needed_tailroom;
if (unlikely(skb_final_len > macsec->real_dev->mtu)) {
---
base-commit: 075b74841bd0065a3bda3440873c747938e69b68
change-id: 20260805-macsec-fixes-d280baf70552
Best regards,
--
Junrui Luo <moonafterrain@outlook.com>
next reply other threads:[~2026-08-05 4:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-05 4:52 Junrui Luo via B4 Relay [this message]
2026-08-06 12:35 ` [PATCH net] macsec: check offload ops before inserting TX tag Antoine Tenart
2026-08-10 21:50 ` Jakub Kicinski
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=20260805-macsec-fixes-v1-1-634d7679a030@outlook.com \
--to=devnull+moonafterrain.outlook.com@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=danisjiang@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=moonafterrain@outlook.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=radu-nicolae.pirea@oss.nxp.com \
--cc=sd@queasysnail.net \
--cc=stable@vger.kernel.org \
/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