Skip to contentSkip to conversation

KMSAN: uninit-value in rxrpc_lookup_peer_rcu

syzbot In review syzbot 3 participants 3 messages Oct 24, 2024 – Nov 18, 2024

Subsystems (3)
lore
Share & tools
lore

syzbot

author syzbot
#0 lore raw

Hello,

syzbot found the following issue on:

HEAD commit:    db87114dcf13 Merge tag 'x86_urgent_for_v6.12_rc4' of git:/..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=12cf2a40580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=7a0aee472a2b5f0a
dashboard link: https://syzkaller.appspot.com/bug?extid=14c04e62ca58315571d1
compiler:       Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/140719cfa0c4/disk-db87114d.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/fb8a264c89a8/vmlinux-db87114d.xz
kernel image: https://storage.googleapis.com/syzbot-assets/4de63179d231/bzImage-db87114d.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:

Reported-by [email protected]

=====================================================

BUG: KMSAN: uninit-value in rxrpc_lookup_peer_rcu+0x2f8/0x300 net/rxrpc/peer_object.c:142
 rxrpc_lookup_peer_rcu+0x2f8/0x300 net/rxrpc/peer_object.c:142
 rxrpc_lookup_peer_local_rcu net/rxrpc/peer_event.c:97 [inline]
 rxrpc_input_error+0x756/0x16e0 net/rxrpc/peer_event.c:148
 rxrpc_io_thread+0x13aa/0x5190 net/rxrpc/io_thread.c:498
 kthread+0x3e2/0x540 kernel/kthread.c:389
 ret_from_fork+0x6d/0x90 arch/x86/kernel/process.c:147
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244

Uninit was stored to memory at:

 rxrpc_input_error+0x499/0x16e0 net/rxrpc/peer_event.c:148
 rxrpc_io_thread+0x13aa/0x5190 net/rxrpc/io_thread.c:498
 kthread+0x3e2/0x540 kernel/kthread.c:389
 ret_from_fork+0x6d/0x90 arch/x86/kernel/process.c:147
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244

Uninit was created at:

 slab_post_alloc_hook mm/slub.c:4091 [inline]
 slab_alloc_node mm/slub.c:4134 [inline]
 kmem_cache_alloc_node_noprof+0x6bf/0xb80 mm/slub.c:4186
 kmalloc_reserve+0x13d/0x4a0 net/core/skbuff.c:587
 __alloc_skb+0x363/0x7b0 net/core/skbuff.c:678
 alloc_skb include/linux/skbuff.h:1322 [inline]
 ipv6_local_error+0xd0/0xa10 net/ipv6/datagram.c:354
 __ip6_append_data+0x6f3/0x68e0 net/ipv6/ip6_output.c:1491
 ip6_make_skb+0x5bd/0xd60 net/ipv6/ip6_output.c:2048
 udpv6_sendmsg+0x3b5e/0x40c0 net/ipv6/udp.c:1584
 do_udp_sendmsg net/rxrpc/output.c:32 [inline]
 rxrpc_send_data_packet net/rxrpc/output.c:488 [inline]
 rxrpc_transmit_one+0xf68/0x2f20 net/rxrpc/output.c:713
 rxrpc_decant_prepared_tx net/rxrpc/call_event.c:271 [inline]
 rxrpc_transmit_some_data net/rxrpc/call_event.c:295 [inline]
 rxrpc_input_call_event+0x18ba/0x2c10 net/rxrpc/call_event.c:401
 rxrpc_io_thread+0xa5c/0x5190 net/rxrpc/io_thread.c:478
 kthread+0x3e2/0x540 kernel/kthread.c:389
 ret_from_fork+0x6d/0x90 arch/x86/kernel/process.c:147
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244

CPU: 0 UID: 0 PID: 12896 Comm: krxrpcio/0 Tainted: G        W          6.12.0-rc3-syzkaller-00454-gdb87114dcf13 #0
Tainted: [W]=WARN
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
=====================================================

---
This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at [email protected].

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

#1 lore raw

PATCH 1/1 rxrpc: Initialize sockaddr_rxrpc directly

In rxrpc_lookup_peer_local_rcu(), removed the redundant memset call that zeros out the sockaddr_rxrpc structure before setting its fields. Instead, initialize the sockaddr_rxrpc structure directly in rxrpc_input_error().

This change simplifies the code and ensures that the sockaddr_rxrpc structure is properly zero-initialized.

---
 net/rxrpc/peer_event.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
net/rxrpc/peer_event.c +1 -2
index 552ba84a255c..c86b432201fd 100644
@@ -33,7 +33,6 @@ static struct rxrpc_peer *rxrpc_lookup_peer_local_rcu(struct rxrpc_local *local,
 
 	_enter("");
 
-	memset(srx, 0, sizeof(*srx));
 	srx->transport_type = local->srx.transport_type;
 	srx->transport_len = local->srx.transport_len;
 	srx->transport.family = local->srx.transport.family;
@@ -134,7 +133,7 @@ static void rxrpc_adjust_mtu(struct rxrpc_peer *peer, unsigned int mtu)
 void rxrpc_input_error(struct rxrpc_local *local, struct sk_buff *skb)
 {
 	struct sock_exterr_skb *serr = SKB_EXT_ERR(skb);
-	struct sockaddr_rxrpc srx;
+	struct sockaddr_rxrpc srx = {};
 	struct rxrpc_peer *peer = NULL;
 
 	_enter("L=%x", local->debug_id);
Signature · 1 line
2.25.1
maintainer
#2 lore raw

Re: [PATCH] rxrpc: Initialize sockaddr_rxrpc directly

Quoted 7 lines · Matt Jan

In rxrpc_lookup_peer_local_rcu(), removed the redundant memset call that zeros out the sockaddr_rxrpc structure before setting its fields. Instead, initialize the sockaddr_rxrpc structure directly in rxrpc_input_error().

This change simplifies the code and ensures that the sockaddr_rxrpc structure is properly zero-initialized.

How does that actually fix the issue?

All the patch does is move the initialisation of srx from rxrpc_lookup_peer_local_rcu() into its only caller - and nothing samples the contents of srx between.

Looking at the bug report, the history of the uninitialised location goes back further, to a network address generated/assembled in the ipv6 stack or from the transmission side of the rxrpc stack, possibly call->peer->srx.transport.

David