Justin Stitt
3220c90f4d
block/ioctl: prefer different overflow check
...
[ Upstream commit ccb326b5f9e623eb7f130fbbf2505ec0e2dcaff9 ]
Running syzkaller with the newly reintroduced signed integer overflow
sanitizer shows this report:
[ 62.982337] ------------[ cut here ]------------
[ 62.985692] cgroup: Invalid name
[ 62.986211] UBSAN: signed-integer-overflow in ../block/ioctl.c:36:46
[ 62.989370] 9pnet_fd: p9_fd_create_tcp (7343): problem connecting socket to 127.0.0.1
[ 62.992992] 9223372036854775807 + 4095 cannot be represented in type 'long long'
[ 62.997827] 9pnet_fd: p9_fd_create_tcp (7345): problem connecting socket to 127.0.0.1
[ 62.999369] random: crng reseeded on system resumption
[ 63.000634] GUP no longer grows the stack in syz-executor.2 (7353): 20002000-20003000 (20001000)
[ 63.000668] CPU: 0 PID: 7353 Comm: syz-executor.2 Not tainted 6.8.0-rc2-00035-gb3ef86b5a957 #1
[ 63.000677] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
[ 63.000682] Call Trace:
[ 63.000686] <TASK>
[ 63.000731] dump_stack_lvl+0x93/0xd0
[ 63.000919] __get_user_pages+0x903/0xd30
[ 63.001030] __gup_longterm_locked+0x153e/0x1ba0
[ 63.001041] ? _raw_read_unlock_irqrestore+0x17/0x50
[ 63.001072] ? try_get_folio+0x29c/0x2d0
[ 63.001083] internal_get_user_pages_fast+0x1119/0x1530
[ 63.001109] iov_iter_extract_pages+0x23b/0x580
[ 63.001206] bio_iov_iter_get_pages+0x4de/0x1220
[ 63.001235] iomap_dio_bio_iter+0x9b6/0x1410
[ 63.001297] __iomap_dio_rw+0xab4/0x1810
[ 63.001316] iomap_dio_rw+0x45/0xa0
[ 63.001328] ext4_file_write_iter+0xdde/0x1390
[ 63.001372] vfs_write+0x599/0xbd0
[ 63.001394] ksys_write+0xc8/0x190
[ 63.001403] do_syscall_64+0xd4/0x1b0
[ 63.001421] ? arch_exit_to_user_mode_prepare+0x3a/0x60
[ 63.001479] entry_SYSCALL_64_after_hwframe+0x6f/0x77
[ 63.001535] RIP: 0033:0x7f7fd3ebf539
[ 63.001551] Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 14 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
[ 63.001562] RSP: 002b:00007f7fd32570c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
[ 63.001584] RAX: ffffffffffffffda RBX: 00007f7fd3ff3f80 RCX: 00007f7fd3ebf539
[ 63.001590] RDX: 4db6d1e4f7e43360 RSI: 0000000020000000 RDI: 0000000000000004
[ 63.001595] RBP: 00007f7fd3f1e496 R08: 0000000000000000 R09: 0000000000000000
[ 63.001599] R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
[ 63.001604] R13: 0000000000000006 R14: 00007f7fd3ff3f80 R15: 00007ffd415ad2b8
...
[ 63.018142] ---[ end trace ]---
Historically, the signed integer overflow sanitizer did not work in the
kernel due to its interaction with `-fwrapv` but this has since been
changed [1] in the newest version of Clang; It was re-enabled in the
kernel with Commit 557f8c582a9ba8ab ("ubsan: Reintroduce signed overflow
sanitizer").
Let's rework this overflow checking logic to not actually perform an
overflow during the check itself, thus avoiding the UBSAN splat.
[1]: https://github.com/llvm/llvm-project/pull/82432
Signed-off-by: Justin Stitt <justinstitt@google.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20240507-b4-sio-block-ioctl-v3-1-ba0c2b32275e@google.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-07-05 09:14:25 +02:00
..
2024-02-23 08:54:35 +01:00
2020-08-23 17:36:59 -05:00
2023-09-19 12:23:02 +02:00
2023-02-09 11:26:36 +01:00
2023-02-09 11:26:36 +01:00
2022-06-09 10:23:19 +02:00
2022-04-08 14:23:55 +02:00
2023-03-10 09:39:05 +01:00
2024-02-23 08:54:44 +01:00
2021-03-05 11:32:15 -07:00
2023-12-20 15:17:39 +01:00
2023-11-20 11:08:29 +01:00
2021-03-11 07:47:48 -07:00
2023-05-11 23:00:16 +09:00
2023-05-11 23:00:16 +09:00
2021-06-30 15:35:45 -06:00
2022-01-27 11:05:25 +01:00
2021-09-14 20:03:30 -06:00
2022-08-11 13:07:50 +02:00
2024-05-17 11:50:54 +02:00
2022-08-17 14:24:24 +02:00
2021-06-21 15:03:40 -06:00
2021-06-21 15:03:40 -06:00
2021-06-17 15:51:20 +02:00
2022-03-08 19:12:31 +01:00
2023-05-11 23:00:16 +09:00
2020-10-20 07:08:17 -06:00
2022-08-17 14:23:12 +02:00
2023-03-10 09:39:04 +01:00
2021-06-24 18:43:55 -06:00
2022-12-31 13:14:43 +01:00
2021-09-12 19:32:43 -06:00
2021-05-24 06:47:22 -06:00
2020-03-17 20:55:21 +01:00
2024-02-23 08:54:52 +01:00
2021-12-01 09:04:56 +01:00
2022-01-27 11:04:15 +01:00
2021-02-22 06:33:48 -07:00
2021-06-08 15:12:57 -06:00
2022-08-17 14:24:24 +02:00
2024-04-10 16:18:35 +02:00
2024-04-13 13:01:45 +02:00
2023-10-10 21:59:05 +02:00
2023-12-20 15:17:39 +01:00
2020-07-31 16:29:47 -06:00
2022-10-26 12:35:54 +02:00
2021-06-21 15:03:41 -06:00
2021-11-18 19:17:15 +01:00
2021-11-18 19:16:16 +01:00
2021-08-02 13:37:28 -06:00
2021-08-01 13:21:40 -04:00
2021-09-14 00:22:15 -04:00
2023-07-23 13:47:20 +02:00
2022-02-23 12:03:15 +01:00
2024-01-15 18:51:07 +01:00
2024-01-25 14:52:39 -08:00
2022-03-16 14:23:46 +01:00
2024-07-05 09:14:25 +02:00
2022-08-11 13:07:50 +02:00
2021-09-02 15:09:46 -07:00
2021-08-11 13:47:26 -06:00
2023-05-11 23:00:16 +09:00
2021-10-15 21:02:57 -06:00
2022-12-14 11:37:30 +01:00
2023-01-24 07:22:49 +01:00
2024-03-26 18:21:13 -04:00
2024-03-26 18:21:13 -04:00
2021-08-02 13:37:28 -06:00