Kuniyuki Iwashima
a0ade8404c
af_packet: Fix warning of fortified memcpy() in packet_getname().
syzkaller found a warning in packet_getname() [0], where we try to
copy 16 bytes to sockaddr_ll.sll_addr[8].
Some devices (ip6gre, vti6, ip6tnl) have 16 bytes address expressed
by struct in6_addr. Also, Infiniband has 32 bytes as MAX_ADDR_LEN.
The write seems to overflow, but actually not since we use struct
sockaddr_storage defined in __sys_getsockname() and its size is 128
(_K_SS_MAXSIZE) bytes. Thus, we have sufficient room after sll_addr[]
as __data[].
To avoid the warning, let's add a flex array member union-ed with
sll_addr.
Another option would be to use strncpy() and limit the copied length
to sizeof(sll_addr), but it will return the partial address and break
an application that passes sockaddr_storage to getsockname().
[0]:
memcpy: detected field-spanning write (size 16) of single field "sll->sll_addr" at net/packet/af_packet.c:3604 (size 8)
WARNING: CPU: 0 PID: 255 at net/packet/af_packet.c:3604 packet_getname+0x25c/0x3a0 net/packet/af_packet.c:3604
Modules linked in:
CPU: 0 PID: 255 Comm: syz-executor750 Not tainted 6.5.0-rc1-00330-g60cc1f7d0605 #4
Hardware name: linux,dummy-virt (DT)
pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
pc : packet_getname+0x25c/0x3a0 net/packet/af_packet.c:3604
lr : packet_getname+0x25c/0x3a0 net/packet/af_packet.c:3604
sp : ffff800089887bc0
x29: ffff800089887bc0 x28: ffff000010f80f80 x27: 0000000000000003
x26: dfff800000000000 x25: ffff700011310f80 x24: ffff800087d55000
x23: dfff800000000000 x22: ffff800089887c2c x21: 0000000000000010
x20: ffff00000de08310 x19: ffff800089887c20 x18: ffff800086ab1630
x17: 20646c6569662065 x16: 6c676e697320666f x15: 0000000000000001
x14: 1fffe0000d56d7ca x13: 0000000000000000 x12: 0000000000000000
x11: 0000000000000000 x10: 0000000000000000 x9 : 3e60944c3da92b00
x8 : 3e60944c3da92b00 x7 : 0000000000000001 x6 : 0000000000000001
x5 : ffff8000898874f8 x4 : ffff800086ac99e0 x3 : ffff8000803f8808
x2 : 0000000000000001 x1 : 0000000100000000 x0 : 0000000000000000
Call trace:
packet_getname+0x25c/0x3a0 net/packet/af_packet.c:3604
__sys_getsockname+0x168/0x24c net/socket.c:2042
__do_sys_getsockname net/socket.c:2057 [inline]
__se_sys_getsockname net/socket.c:2054 [inline]
__arm64_sys_getsockname+0x7c/0x94 net/socket.c:2054
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x134/0x240 arch/arm64/kernel/syscall.c:139
do_el0_svc+0x64/0x198 arch/arm64/kernel/syscall.c:188
el0_svc+0x2c/0x7c arch/arm64/kernel/entry-common.c:647
el0t_64_sync_handler+0x84/0xfc arch/arm64/kernel/entry-common.c:665
el0t_64_sync+0x190/0x194 arch/arm64/kernel/entry.S:591
Fixes: df8fc4e934 ("kbuild: Enable -fstrict-flex-arrays=3")
Reported-by: syzkaller <syzkaller@googlegroups.com>
Suggested-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Link: https://lore.kernel.org/r/20230724213425.22920-3-kuniyu@amazon.com
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2023-07-25 20:10:05 -07:00
..
2023-01-19 17:14:18 +01:00
2023-06-22 09:44:28 +02:00
2023-05-14 16:05:28 +01:00
2022-11-17 22:49:39 +01:00
2022-09-21 18:42:55 +01:00
2022-06-28 21:26:05 +02:00
2023-06-26 08:05:57 +02:00
2022-06-28 21:26:05 +02:00
2022-06-28 21:26:05 +02:00
2022-06-28 21:26:05 +02:00
2022-08-09 19:51:05 +02:00
2023-04-27 18:49:24 -04:00
2022-06-28 21:26:05 +02:00
2023-05-30 15:20:08 +01:00
2023-03-30 23:24:24 -07:00
2023-07-08 12:08:39 -07:00
2022-11-23 19:55:22 +01:00
2023-06-20 14:28:17 -06:00
2022-11-04 16:56:41 +01:00
2022-08-11 10:31:19 -07:00
2022-12-22 18:18:37 -08:00
2023-03-10 21:05:16 +01:00
2022-10-31 07:29:47 -04:00
2023-05-30 16:42:00 -07:00
2022-12-27 12:52:10 +01:00
2023-01-21 19:01:59 +01:00
2022-06-28 21:26:05 +02:00
2023-06-24 14:52:28 -07:00
2022-06-07 10:20:42 -07:00
2022-12-05 18:00:58 +01:00
2023-04-17 19:52:19 +02:00
2023-06-22 09:44:28 +02:00
2023-06-06 17:05:54 -04:00
2022-09-24 08:50:04 +02:00
2022-09-24 08:50:04 +02:00
2022-06-28 21:26:05 +02:00
2023-04-18 16:39:34 -07:00
2023-06-08 10:11:17 -04:00
2023-04-22 14:41:30 -07:00
2022-06-28 21:26:05 +02:00
2023-01-20 09:33:22 +00:00
2022-12-07 20:09:18 -08:00
2023-03-06 15:49:07 -06:00
2023-03-06 15:49:07 -06:00
2023-03-30 15:57:50 -04:00
2022-06-28 21:26:05 +02:00
2022-06-20 18:21:25 +02:00
2022-08-29 15:32:13 +02:00
2022-06-03 20:09:27 +08:00
2023-06-30 09:37:26 -07:00
2023-06-12 08:50:48 +01:00
2023-01-23 12:44:18 +00:00
2023-06-15 14:55:15 +02:00
2023-03-10 21:05:16 +01:00
2023-04-19 23:39:42 -04:00
2022-11-28 12:46:23 -08:00
2023-02-07 12:53:53 +01:00
2023-05-25 13:16:57 +02:00
2022-06-28 21:26:05 +02:00
2023-06-06 07:54:00 +09:00
2023-03-16 21:20:32 -07:00
2022-06-28 21:26:05 +02:00
2022-12-01 19:58:50 -08:00
2023-06-07 16:26:33 +02:00
2022-08-10 13:49:50 +01:00
2023-03-29 10:50:48 +02:00
2023-05-24 22:05:24 -07:00
2022-09-20 11:53:32 +01:00
2023-03-10 21:05:16 +01:00
2023-04-12 23:18:45 +05:30
2022-10-28 12:36:34 +08:00
2022-06-28 21:26:05 +02:00
2023-04-21 08:25:50 +01:00
2022-09-15 09:08:09 +02:00
2023-05-13 17:02:33 +01:00
2022-08-18 20:37:35 -07:00
2023-07-25 20:10:05 -07:00
2022-06-28 21:26:05 +02:00
2022-12-12 09:29:56 +00:00
2022-06-28 21:26:05 +02:00
2023-05-23 15:38:59 +02:00
2022-06-28 21:26:05 +02:00
2022-06-28 21:26:05 +02:00
2022-11-22 17:50:36 -08:00
2022-07-17 07:52:46 -07:00
2023-06-28 16:09:41 -06:00
2023-01-06 19:22:53 -08:00
2022-11-30 20:16:49 -04:00
2023-06-16 12:04:30 -04:00
2022-06-28 21:26:05 +02:00
2023-02-06 09:01:00 +00:00
2022-10-17 09:51:26 -05:00
2023-03-30 14:06:56 -06:00
2022-06-28 21:26:05 +02:00
2023-03-16 15:18:02 +01:00
2022-06-28 21:26:05 +02:00
2022-06-28 21:26:05 +02:00
2023-01-19 16:28:57 +01:00
2022-06-03 20:09:27 +08:00
2023-06-15 11:37:55 -04:00
2023-06-09 12:34:45 -04:00
2023-07-01 07:07:55 -04:00
2022-09-20 09:13:38 +02:00
2023-02-21 18:15:59 +01:00
2022-07-08 10:46:53 -07:00
2022-08-29 10:44:08 +02:00
2022-08-02 12:34:03 -04:00
2023-05-24 09:13:22 -07:00
2023-01-04 14:59:25 +01:00
2023-05-25 16:21:22 +02:00
2023-03-23 17:25:46 +01:00
2023-03-23 17:25:46 +01:00
2023-01-07 11:29:29 +01:00
2023-01-18 17:12:37 -08:00
2022-06-28 21:26:05 +02:00
2023-06-09 16:25:16 -07:00
2023-05-19 04:30:22 +02:00
2023-06-21 22:45:57 -07:00
2023-04-27 19:15:11 -06:00
2022-06-28 21:26:05 +02:00
2022-11-03 20:46:32 -07:00
2022-06-28 21:26:05 +02:00
2022-12-08 19:49:21 -08:00
2023-03-16 21:20:32 -07:00
2022-09-07 16:46:03 +02:00
2022-11-18 18:36:54 -08:00
2023-06-21 14:01:29 +02:00
2023-06-12 09:46:30 +01:00
2023-03-23 12:22:19 +09:00
2023-05-31 16:34:38 -05:00
2023-02-07 11:52:00 +00:00
2023-06-12 17:01:45 -07:00
2023-05-31 10:00:30 +01:00
2023-06-07 14:26:09 -06:00
2022-12-01 03:22:20 +00:00
2023-06-08 07:16:53 -07:00
2023-01-06 17:12:39 +00:00
2023-03-21 11:37:32 +01:00
2023-06-20 09:02:33 +01:00
2023-04-16 14:23:07 +02:00
2022-06-28 21:26:05 +02:00
2022-09-24 08:31:54 +02:00
2022-06-28 21:26:05 +02:00
2023-01-06 19:28:01 -08:00
2022-12-27 12:52:12 +01:00
2023-03-16 21:25:45 -07:00
2023-03-09 11:31:44 +01:00
2023-04-19 14:07:13 -06:00
2022-08-03 16:29:08 -07:00
2022-09-20 12:33:22 +02:00
2022-06-28 21:26:05 +02:00
2023-02-08 13:10:15 +01:00
2023-01-19 15:01:20 +01:00
2022-11-03 03:43:05 +01:00
2023-03-21 15:43:19 +01:00
2022-07-18 11:19:17 +01:00
2023-01-26 10:52:18 +01:00
2022-06-01 16:48:05 -07:00
2022-09-11 19:47:04 -05:00
2022-06-28 21:26:05 +02:00
2022-11-09 14:06:51 +01:00
2023-03-28 13:39:02 -07:00
2022-06-30 13:14:35 +02:00
2023-03-24 16:59:09 -04:00
2023-04-18 16:39:34 -07:00
2022-10-28 10:47:42 +01:00
2022-11-17 11:04:23 -08:00
2022-09-27 17:29:09 -07:00
2023-06-15 13:41:53 +02:00
2022-06-27 16:25:41 +02:00
2023-06-05 09:36:35 +02:00
2023-06-04 08:34:14 -06:00
2022-06-28 21:26:05 +02:00
2022-08-31 09:07:53 +02:00
2023-03-29 06:52:09 -04:00
2023-04-05 19:42:48 -07:00
2023-03-23 17:25:46 +01:00
2023-01-15 23:45:15 +02:00
2022-12-07 17:58:46 +01:00
2023-06-09 16:13:01 +01:00
2022-12-07 17:58:46 +01:00
2022-12-07 17:58:46 +01:00
2023-04-15 08:58:41 +01:00
2022-12-28 05:09:46 -05:00
2022-08-11 04:26:08 -04:00
2022-07-11 09:54:37 +02:00
2023-06-30 15:22:09 -07:00
2023-07-03 12:15:14 -04:00
2023-07-03 12:15:14 -04:00
2023-06-09 16:14:40 +01:00
2022-06-28 21:26:05 +02:00
2023-04-04 11:01:57 -04:00
2022-12-12 14:19:23 -08:00
2023-04-21 03:02:35 -04:00
2023-03-13 16:32:16 -07:00
2022-08-11 04:06:40 -04:00
2022-08-16 01:40:24 -04:00
2023-05-28 19:07:48 -06:00
2022-12-05 10:30:47 +01:00