Stanislav Fomichev
9d63b59d1e
bpf: test_run: Fix overflow in xdp frags parsing
...
When kattr->test.data_size_in > INT_MAX, signed min_t will assign
negative value to data_len. This negative value then gets passed
over to copy_from_user where it is converted to (big) unsigned.
Use unsigned min_t to avoid this overflow.
usercopy: Kernel memory overwrite attempt detected to wrapped address
(offset 0, size 18446612140539162846)!
------------[ cut here ]------------
kernel BUG at mm/usercopy.c:102!
invalid opcode: 0000 [#1 ] SMP KASAN
Modules linked in:
CPU: 0 PID: 3781 Comm: syz-executor226 Not tainted 4.15.0-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 01/01/2011
RIP: 0010:usercopy_abort+0xbd/0xbf mm/usercopy.c:102
RSP: 0018:ffff8801e9703a38 EFLAGS: 00010286
RAX: 000000000000006c RBX: ffffffff84fc7040 RCX: 0000000000000000
RDX: 0000000000000000 RSI: ffffffff816560a2 RDI: ffffed003d2e0739
RBP: ffff8801e9703a90 R08: 000000000000006c R09: 0000000000000001
R10: 0000000000000000 R11: 0000000000000000 R12: ffffffff84fc73a0
R13: ffffffff84fc7180 R14: ffffffff84fc7040 R15: ffffffff84fc7040
FS: 00007f54e0bec300(0000) GS:ffff8801f6600000(0000)
knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000020000280 CR3: 00000001e90ea000 CR4: 00000000003426f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
check_bogus_address mm/usercopy.c:155 [inline]
__check_object_size mm/usercopy.c:263 [inline]
__check_object_size.cold+0x8c/0xad mm/usercopy.c:253
check_object_size include/linux/thread_info.h:112 [inline]
check_copy_size include/linux/thread_info.h:143 [inline]
copy_from_user include/linux/uaccess.h:142 [inline]
bpf_prog_test_run_xdp+0xe57/0x1240 net/bpf/test_run.c:989
bpf_prog_test_run kernel/bpf/syscall.c:3377 [inline]
__sys_bpf+0xdf2/0x4a50 kernel/bpf/syscall.c:4679
SYSC_bpf kernel/bpf/syscall.c:4765 [inline]
SyS_bpf+0x26/0x50 kernel/bpf/syscall.c:4763
do_syscall_64+0x21a/0x3e0 arch/x86/entry/common.c:305
entry_SYSCALL_64_after_hwframe+0x46/0xbb
Fixes: 1c1949982524 ("bpf: introduce frags support to bpf_prog_test_run_xdp()")
Reported-by: syzbot <syzkaller@googlegroups.com>
Signed-off-by: Stanislav Fomichev <sdf@google.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
Acked-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/bpf/20220204235849.14658-1-sdf@google.com
2022-02-07 18:26:13 -08:00
..
2021-07-22 16:19:03 +02:00
2022-01-18 10:05:48 +02:00
2021-11-19 11:23:23 +00:00
2021-12-07 20:44:58 -08:00
2021-07-23 14:20:25 +01:00
2021-10-24 13:59:45 +01:00
2022-01-09 17:00:17 -08:00
2022-01-05 14:36:10 -08:00
2022-01-17 05:49:30 +02:00
2022-02-07 18:26:13 -08:00
2021-06-25 13:13:50 +02:00
2022-01-12 14:44:18 +00:00
2021-12-31 14:35:40 +00:00
2022-01-05 21:49:47 +01:00
2022-01-15 16:30:29 +02:00
2022-01-31 12:39:12 -08:00
2021-11-23 20:16:22 -08:00
2021-12-31 14:35:40 +00:00
2022-01-06 11:59:10 +00:00
2021-11-24 17:21:42 -08:00
2022-01-06 12:33:35 +00:00
2021-11-29 12:12:36 +00:00
2021-11-16 13:20:45 +00:00
2022-01-27 12:03:46 -08:00
2022-01-20 20:18:37 -08:00
2021-12-29 08:48:14 -08:00
2021-12-29 08:48:14 -08:00
2021-12-10 06:38:27 -08:00
2021-12-10 19:43:00 -08:00
2022-01-05 14:36:10 -08:00
2021-10-20 14:27:40 +01:00
2022-01-11 20:26:36 -08:00
2021-12-02 11:44:56 -08:00
2022-01-21 19:26:03 -08:00
2021-12-29 17:53:24 -08:00
2022-01-24 15:42:29 -08:00
2021-11-22 17:52:47 -05:00
2021-12-29 08:48:14 -08:00
2022-01-07 14:11:05 +00:00
2022-01-20 10:57:05 +02:00
2022-01-09 17:00:17 -08:00
2022-01-20 10:12:53 +00:00
2021-12-20 11:49:51 +00:00
2021-12-17 17:17:14 +01:00
2021-12-16 16:13:19 -08:00
2021-12-20 11:02:38 +01:00
2021-12-29 08:48:14 -08:00
2022-01-22 02:03:24 +00:00
2022-01-20 11:25:57 +00:00
2022-01-05 14:36:10 -08:00
2022-01-24 12:06:08 +00:00
2021-11-09 01:05:28 +01:00
2022-01-16 07:42:58 +02:00
2021-12-07 20:44:58 -08:00
2022-01-05 14:36:10 -08:00
2022-01-17 13:07:47 +00:00
2022-01-24 15:42:29 -08:00
2022-01-18 10:05:48 +02:00
2022-01-19 11:15:19 +02:00
2021-12-09 18:35:11 -08:00
2022-01-27 17:25:32 +01:00
2022-01-11 20:36:08 -08:00
2021-11-20 12:25:57 +00:00
2021-12-10 06:38:26 -08:00
2021-07-29 15:06:49 +01:00
2022-01-06 12:18:08 +00:00
2021-11-09 10:02:50 -08:00