Shigeru Yoshida
76965648fe
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-11 12:49:14 +02:00
..
2024-06-16 13:47:41 +02:00
2024-05-17 12:02:07 +02:00
2023-12-20 17:01:50 +01:00
2023-12-20 17:01:48 +01:00
2024-06-21 14:38:14 +02:00
2024-07-05 09:34:04 +02:00
2024-07-11 12:49:12 +02:00
2024-06-21 14:38:16 +02:00
2023-05-31 13:06:57 +02:00
2024-06-21 14:38:36 +02:00
2023-06-24 15:50:13 -07:00
2024-07-05 09:34:01 +02:00
2024-03-01 13:34:56 +01:00
2024-07-11 12:49:12 +02:00
2023-08-01 21:07:46 -07:00
2024-07-05 09:33:48 +02:00
2024-03-26 18:20:11 -04:00
2024-01-25 15:35:41 -08:00
2023-08-09 13:08:09 -07:00
2024-05-02 16:32:46 +02:00
2024-06-21 14:38:20 +02:00
2024-02-23 09:24:50 +01:00
2024-05-17 12:02:24 +02:00
2023-08-29 17:39:15 -07:00
2024-01-01 12:42:30 +00:00
2024-07-11 12:49:14 +02:00
2024-06-27 13:49:08 +02:00
2024-07-05 09:33:51 +02:00
2024-03-26 18:19:40 -04:00
2023-08-18 12:44:56 -07:00
2024-05-17 12:02:02 +02:00
2024-02-05 20:14:36 +00:00
2024-06-21 14:38:13 +02:00
2024-07-11 12:49:10 +02:00
2024-03-26 18:19:34 -04:00
2024-04-13 13:07:41 +02:00
2024-06-21 14:38:38 +02:00
2024-06-21 14:38:14 +02:00
2024-07-11 12:49:13 +02:00
2024-01-25 15:35:14 -08:00
2024-03-06 14:48:34 +00:00
2024-06-27 13:49:06 +02:00
2024-06-12 11:12:51 +02:00
2024-05-17 12:02:02 +02:00
2024-07-05 09:33:46 +02:00
2024-06-27 13:49:01 +02:00
2024-05-17 12:02:22 +02:00
2023-12-13 18:45:10 +01:00
2024-06-12 11:12:12 +02:00
2024-04-10 16:35:49 +02:00
2024-01-01 12:42:41 +00:00
2024-01-01 12:42:31 +00:00
2024-05-17 12:02:23 +02:00
2024-06-27 13:49:15 +02:00
2024-07-11 12:49:06 +02:00
2024-06-21 14:38:16 +02:00
2024-06-21 14:38:28 +02:00
2024-03-01 13:35:06 +01:00
2024-06-27 13:49:07 +02:00
2024-06-12 11:12:50 +02:00
2024-06-21 14:38:36 +02:00
2024-04-10 16:35:50 +02:00
2024-06-21 14:38:12 +02:00
2024-03-26 18:19:41 -04:00
2024-04-17 11:19:28 +02:00
2024-06-16 13:47:44 +02:00
2023-07-19 10:07:27 -07:00
2024-01-10 17:16:51 +01:00
2023-08-15 15:26:17 -07:00