Netdev List
 help / color / mirror / Atom feed
* [PATCH net] macsec: reject lower device type changes
@ 2026-12-03 21:08 Kyuwon Cho
  2026-12-04 21:36 ` netdev-bot+sashiko
  0 siblings, 1 reply; 2+ messages in thread
From: Kyuwon Cho @ 2026-12-03 21:08 UTC (permalink / raw)
  To: Sabrina Dubroca, Andrew Lunn, David S . Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni
  Cc: Radu Pirea, netdev

MACsec devices require Ethernet lower devices, but a stacked lower
device can change its type after a MACsec device is attached. If the
lower device gains a longer address, macsec_set_mac_address() passes
its six-byte old_addr buffer to dev_uc_del(). The address lookup uses
the lower device addr_len and reads beyond the stack buffer:

  BUG: KASAN: stack-out-of-bounds in memcmp (lib/string.c:665)
  Read of size 8 at addr ffa0000000b36f48 by task test/115
  Call Trace:
   <TASK>
   memcmp (lib/string.c:665)
   __hw_addr_lookup.isra.0 (net/core/dev_addr_lists.c:215)
   dev_uc_del (net/core/dev_addr_lists.c:880)
   macsec_set_mac_address (drivers/net/macsec.c:3770)
   netif_set_mac_address (net/core/dev.c:10267)
   do_setlink.isra.0 (net/core/rtnetlink.c:3246)
   rtnl_newlink (net/core/rtnetlink.c:4252)
   rtnetlink_rcv_msg (net/core/rtnetlink.c:7169)
   </TASK>

Reject NETDEV_PRE_TYPE_CHANGE while MACsec devices are attached, as
macvlan and ipvlan do for their lower devices.

Fixes: 25a00d0cd691 ("net: macsec: revert the MAC address if mdo_upd_secy fails")
Signed-off-by: Kyuwon Cho <kyuwon.cho@skku.edu>
---
This issue was found by an LLM-guided test generator.
A reproducer is available on request.

Reproduced on mainline fe6ff8d5d675 (v7.4-rc5, with KASAN); the
patch was tested against net (90ae4042bd9f).

 drivers/net/macsec.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
index 240ba0ae07d1..5dd6f18cd186 100644
--- a/drivers/net/macsec.c
+++ b/drivers/net/macsec.c
@@ -4508,6 +4508,8 @@ static int macsec_notify(struct notifier_block *this, unsigned long event,
 	rxd = macsec_data_rtnl(real_dev);
 
 	switch (event) {
+	case NETDEV_PRE_TYPE_CHANGE:
+		return NOTIFY_BAD;
 	case NETDEV_DOWN:
 	case NETDEV_UP:
 	case NETDEV_CHANGE:
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-04 21:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03 21:08 [PATCH net] macsec: reject lower device type changes Kyuwon Cho
2026-12-04 21:36 ` netdev-bot+sashiko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox