Skip to contentSkip to conversation

tap: fix stack info leak in tap_ioctl() SIOCGIFHWADDR

PATCH Applied Weiming Shi 3 participants 4 messages May 20 – May 21

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

PATCH 1/1 tap: fix stack info leak in tap_ioctl() SIOCGIFHWADDR

In the SIOCGIFHWADDR path, tap_ioctl() copies 16 bytes of an uninitialised on-stack struct sockaddr_storage to userspace via ifr_hwaddr, but netif_get_mac_address() only writes sa_family and dev->addr_len (6 for Ethernet) bytes, leaving sa_data[6..13] uninitialised.

Those 8 trailing bytes leak kernel stack contents; SIOCGIFHWADDR on a macvtap chardev returns kernel .text and direct-map pointers, defeating KASLR.

Initialise ss at declaration.

Fixes 3b23a32a6321 ("net: fix dev_ifsioc_locked() race condition")
Assisted-by Claude:claude-opus-4-7
---
 drivers/net/tap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/tap.c +1 -1
index b8240737dc51..e1522101b9e4 100644
@@ -923,7 +923,7 @@ static long tap_ioctl(struct file *file, unsigned int cmd,
 	unsigned int __user *up = argp;
 	unsigned short u;
 	int __user *sp = argp;
-	struct sockaddr_storage ss;
+	struct sockaddr_storage ss = {};
 	int s;
 	int ret;
 
Signature · 1 line
2.43.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Weiming Shi

In the SIOCGIFHWADDR path, tap_ioctl() copies 16 bytes of an uninitialised on-stack struct sockaddr_storage to userspace via ifr_hwaddr, but netif_get_mac_address() only writes sa_family and dev->addr_len (6 for Ethernet) bytes, leaving sa_data[6..13] uninitialised.

Those 8 trailing bytes leak kernel stack contents; SIOCGIFHWADDR on a macvtap chardev returns kernel .text and direct-map pointers, defeating KASLR.

Quoted 6 lines

Initialise ss at declaration.

Fixes 3b23a32a6321 ("net: fix dev_ifsioc_locked() race condition")
Assisted-by Claude:claude-opus-4-7
maintainer
#2 lore raw
Quoted 10 lines · Willem de Bruijn
Quoted 9 lines · Weiming Shi

In the SIOCGIFHWADDR path, tap_ioctl() copies 16 bytes of an uninitialised on-stack struct sockaddr_storage to userspace via ifr_hwaddr, but netif_get_mac_address() only writes sa_family and dev->addr_len (6 for Ethernet) bytes, leaving sa_data[6..13] uninitialised.

Those 8 trailing bytes leak kernel stack contents; SIOCGIFHWADDR on a macvtap chardev returns kernel .text and direct-map pointers, defeating KASLR.

Quoted 8 lines
Quoted 6 lines

Initialise ss at declaration.

Fixes 3b23a32a6321 ("net: fix dev_ifsioc_locked() race condition")
Assisted-by Claude:claude-opus-4-7

But it should target [PATCH net] and

#3 lore raw
In reply to Weiming Shi
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Wed, 20 May 2026 00:57:38 -0700 you wrote:

In the SIOCGIFHWADDR path, tap_ioctl() copies 16 bytes of an uninitialised on-stack struct sockaddr_storage to userspace via ifr_hwaddr, but netif_get_mac_address() only writes sa_family and dev->addr_len (6 for Ethernet) bytes, leaving sa_data[6..13] uninitialised.

Those 8 trailing bytes leak kernel stack contents; SIOCGIFHWADDR on a macvtap chardev returns kernel .text and direct-map pointers, defeating KASLR.

[...]

Here is the summary with links:
- tap: fix stack info leak in tap_ioctl() SIOCGIFHWADDR

    https://git.kernel.org/netdev/net/c/bddc09212c24

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html