Shigeru Yoshida
7ef519c8ef
inet_diag: Initialize pad field in struct inet_diag_req_v2
...
[ Upstream commit 61cf1c739f08190a4cbf047b9fbb192a94d87e3f ]
KMSAN reported uninit-value access in raw_lookup() [1]. Diag for raw
sockets uses the pad field in struct inet_diag_req_v2 for the
underlying protocol. This field corresponds to the sdiag_raw_protocol
field in struct inet_diag_req_raw.
inet_diag_get_exact_compat() converts inet_diag_req to
inet_diag_req_v2, but leaves the pad field uninitialized. So the issue
occurs when raw_lookup() accesses the sdiag_raw_protocol field.
Fix this by initializing the pad field in
inet_diag_get_exact_compat(). Also, do the same fix in
inet_diag_dump_compat() to avoid the similar issue in the future.
[1]
BUG: KMSAN: uninit-value in raw_lookup net/ipv4/raw_diag.c:49 [inline]
BUG: KMSAN: uninit-value in raw_sock_get+0x657/0x800 net/ipv4/raw_diag.c:71
raw_lookup net/ipv4/raw_diag.c:49 [inline]
raw_sock_get+0x657/0x800 net/ipv4/raw_diag.c:71
raw_diag_dump_one+0xa1/0x660 net/ipv4/raw_diag.c:99
inet_diag_cmd_exact+0x7d9/0x980
inet_diag_get_exact_compat net/ipv4/inet_diag.c:1404 [inline]
inet_diag_rcv_msg_compat+0x469/0x530 net/ipv4/inet_diag.c:1426
sock_diag_rcv_msg+0x23d/0x740 net/core/sock_diag.c:282
netlink_rcv_skb+0x537/0x670 net/netlink/af_netlink.c:2564
sock_diag_rcv+0x35/0x40 net/core/sock_diag.c:297
netlink_unicast_kernel net/netlink/af_netlink.c:1335 [inline]
netlink_unicast+0xe74/0x1240 net/netlink/af_netlink.c:1361
netlink_sendmsg+0x10c6/0x1260 net/netlink/af_netlink.c:1905
sock_sendmsg_nosec net/socket.c:730 [inline]
__sock_sendmsg+0x332/0x3d0 net/socket.c:745
____sys_sendmsg+0x7f0/0xb70 net/socket.c:2585
___sys_sendmsg+0x271/0x3b0 net/socket.c:2639
__sys_sendmsg net/socket.c:2668 [inline]
__do_sys_sendmsg net/socket.c:2677 [inline]
__se_sys_sendmsg net/socket.c:2675 [inline]
__x64_sys_sendmsg+0x27e/0x4a0 net/socket.c:2675
x64_sys_call+0x135e/0x3ce0 arch/x86/include/generated/asm/syscalls_64.h:47
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xd9/0x1e0 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Uninit was stored to memory at:
raw_sock_get+0x650/0x800 net/ipv4/raw_diag.c:71
raw_diag_dump_one+0xa1/0x660 net/ipv4/raw_diag.c:99
inet_diag_cmd_exact+0x7d9/0x980
inet_diag_get_exact_compat net/ipv4/inet_diag.c:1404 [inline]
inet_diag_rcv_msg_compat+0x469/0x530 net/ipv4/inet_diag.c:1426
sock_diag_rcv_msg+0x23d/0x740 net/core/sock_diag.c:282
netlink_rcv_skb+0x537/0x670 net/netlink/af_netlink.c:2564
sock_diag_rcv+0x35/0x40 net/core/sock_diag.c:297
netlink_unicast_kernel net/netlink/af_netlink.c:1335 [inline]
netlink_unicast+0xe74/0x1240 net/netlink/af_netlink.c:1361
netlink_sendmsg+0x10c6/0x1260 net/netlink/af_netlink.c:1905
sock_sendmsg_nosec net/socket.c:730 [inline]
__sock_sendmsg+0x332/0x3d0 net/socket.c:745
____sys_sendmsg+0x7f0/0xb70 net/socket.c:2585
___sys_sendmsg+0x271/0x3b0 net/socket.c:2639
__sys_sendmsg net/socket.c:2668 [inline]
__do_sys_sendmsg net/socket.c:2677 [inline]
__se_sys_sendmsg net/socket.c:2675 [inline]
__x64_sys_sendmsg+0x27e/0x4a0 net/socket.c:2675
x64_sys_call+0x135e/0x3ce0 arch/x86/include/generated/asm/syscalls_64.h:47
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xd9/0x1e0 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Local variable req.i created at:
inet_diag_get_exact_compat net/ipv4/inet_diag.c:1396 [inline]
inet_diag_rcv_msg_compat+0x2a6/0x530 net/ipv4/inet_diag.c:1426
sock_diag_rcv_msg+0x23d/0x740 net/core/sock_diag.c:282
CPU: 1 PID: 8888 Comm: syz-executor.6 Not tainted 6.10.0-rc4-00217-g35bb670d65fc #32
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.3-2.fc40 04/01/2014
Fixes: 432490f9d455 ("net: ip, diag -- Add diag interface for raw sockets")
Reported-by: syzkaller <syzkaller@googlegroups.com>
Signed-off-by: Shigeru Yoshida <syoshida@redhat.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20240703091649.111773-1-syoshida@redhat.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-07-18 13:05:42 +02:00
..
2024-06-16 13:32:34 +02:00
2023-01-14 10:16:18 +01:00
2024-02-23 08:41:55 +01:00
2023-12-20 15:44:29 +01:00
2023-12-20 15:44:28 +01:00
2022-06-22 14:13:17 +02:00
2024-07-05 09:12:54 +02:00
2024-07-05 09:12:28 +02:00
2023-01-14 10:15:31 +01:00
2024-05-17 11:48:07 +02:00
2023-03-17 08:45:11 +01:00
2024-07-05 09:12:53 +02:00
2023-10-25 11:54:15 +02:00
2024-07-05 09:12:57 +02:00
2023-08-11 11:57:50 +02:00
2023-11-20 11:06:55 +01:00
2023-06-21 15:45:38 +02:00
2024-01-25 14:37:50 -08:00
2023-07-27 08:44:10 +02:00
2024-05-02 16:23:44 +02:00
2024-01-25 14:37:56 -08:00
2024-03-26 18:22:03 -04:00
2022-11-03 23:57:51 +09:00
2024-01-05 15:12:24 +01:00
2024-07-18 13:05:42 +02:00
2024-07-05 09:12:56 +02:00
2024-07-05 09:12:49 +02:00
2024-03-26 18:21:54 -04:00
2023-08-26 15:26:51 +02:00
2024-05-17 11:48:00 +02:00
2022-04-27 13:53:50 +02:00
2024-02-23 08:42:17 +01:00
2024-07-05 09:12:21 +02:00
2024-04-13 12:58:25 +02:00
2023-02-22 12:55:58 +01:00
2024-07-05 09:12:32 +02:00
2024-07-05 09:12:22 +02:00
2024-07-05 09:12:49 +02:00
2024-01-25 14:37:40 -08:00
2024-05-25 16:19:06 +02:00
2024-07-05 09:12:37 +02:00
2024-06-16 13:32:27 +02:00
2024-05-17 11:48:00 +02:00
2024-06-16 13:32:27 +02:00
2024-07-05 09:12:34 +02:00
2024-05-17 11:48:07 +02:00
2023-12-13 18:27:06 +01:00
2024-06-16 13:32:15 +02:00
2024-04-13 12:59:19 +02:00
2024-01-05 15:12:28 +01:00
2024-01-05 15:12:24 +01:00
2024-02-23 08:42:20 +01:00
2024-07-05 09:12:39 +02:00
2024-07-18 13:05:39 +02:00
2024-04-13 12:59:43 +02:00
2021-11-18 14:04:27 +01:00
2024-07-05 09:12:47 +02:00
2024-07-05 09:12:38 +02:00
2024-06-16 13:32:27 +02:00
2024-07-05 09:12:23 +02:00
2024-01-25 14:37:45 -08:00
2024-07-05 09:12:21 +02:00
2024-03-26 18:21:54 -04:00
2024-05-02 16:23:33 +02:00
2024-06-16 13:32:36 +02:00
2023-06-21 15:45:38 +02:00
2023-06-21 15:45:38 +02:00
2024-01-15 18:48:04 +01:00