kernel_samsung_a53x/block
Konstantin Ovsepian 31aab2e514 blk_iocost: fix more out of bound shifts
[ Upstream commit 9bce8005ec0dcb23a58300e8522fe4a31da606fa ]

Recently running UBSAN caught few out of bound shifts in the
ioc_forgive_debts() function:

UBSAN: shift-out-of-bounds in block/blk-iocost.c:2142:38
shift exponent 80 is too large for 64-bit type 'u64' (aka 'unsigned long
long')
...
UBSAN: shift-out-of-bounds in block/blk-iocost.c:2144:30
shift exponent 80 is too large for 64-bit type 'u64' (aka 'unsigned long
long')
...
Call Trace:
<IRQ>
dump_stack_lvl+0xca/0x130
__ubsan_handle_shift_out_of_bounds+0x22c/0x280
? __lock_acquire+0x6441/0x7c10
ioc_timer_fn+0x6cec/0x7750
? blk_iocost_init+0x720/0x720
? call_timer_fn+0x5d/0x470
call_timer_fn+0xfa/0x470
? blk_iocost_init+0x720/0x720
__run_timer_base+0x519/0x700
...

Actual impact of this issue was not identified but I propose to fix the
undefined behaviour.
The proposed fix to prevent those out of bound shifts consist of
precalculating exponent before using it the shift operations by taking
min value from the actual exponent and maximum possible number of bits.

Reported-by: Breno Leitao <leitao@debian.org>
Signed-off-by: Konstantin Ovsepian <ovs@ovs.to>
Acked-by: Tejun Heo <tj@kernel.org>
Link: https://lore.kernel.org/r/20240822154137.2627818-1-ovs@ovs.to
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-23 23:21:38 +01:00
..
partitions block: fix potential invalid pointer dereference in blk_add_partition 2024-11-23 23:21:19 +01:00
badblocks.c
bfq-cgroup.c
bfq-iosched.c block, bfq: don't break merge chain in bfq_split_bfqq() 2024-11-23 23:21:19 +01:00
bfq-iosched.h block, bfq: save also injection state on queue merging 2024-11-19 17:43:15 +01:00
bfq-wf2q.c block, bfq: always inject I/O of queues blocked by wakers 2024-11-19 17:41:42 +01:00
bio-integrity.c block: initialize integrity buffer to zero before writing it to media 2024-11-23 23:20:59 +01:00
bio.c
blk-cgroup-rwstat.c
blk-cgroup-rwstat.h
blk-cgroup.c cgroup: rstat: punt root-level optimization to individual controllers 2024-11-19 17:40:21 +01:00
blk-core.c
blk-crypto-fallback.c
blk-crypto-internal.h
blk-crypto.c
blk-exec.c
blk-flush.c
blk-integrity.c block: remove the blk_flush_integrity call in blk_integrity_unregister 2024-11-23 23:20:58 +01:00
blk-ioc.c
blk-iocost.c blk_iocost: fix more out of bound shifts 2024-11-23 23:21:38 +01:00
blk-iolatency.c
blk-ioprio.c
blk-ioprio.h
blk-lib.c
blk-map.c
blk-merge.c blk: Fix lock inversion between ioc lock and bfqd lock 2024-11-19 17:40:26 +01:00
blk-mq-cpumap.c
blk-mq-debugfs-zoned.c
blk-mq-debugfs.c
blk-mq-debugfs.h
blk-mq-pci.c
blk-mq-rdma.c
blk-mq-sched.c blk: Fix lock inversion between ioc lock and bfqd lock 2024-11-19 17:40:26 +01:00
blk-mq-sched.h blk: Fix lock inversion between ioc lock and bfqd lock 2024-11-19 17:40:26 +01:00
blk-mq-sysfs.c
blk-mq-tag.c
blk-mq-tag.h
blk-mq-virtio.c
blk-mq.c
blk-mq.h blk: Fix lock inversion between ioc lock and bfqd lock 2024-11-19 17:40:26 +01:00
blk-pm.c
blk-pm.h
blk-rq-qos.c
blk-rq-qos.h
blk-sec-stats.c
blk-settings.c
blk-stat.c block: prevent division by zero in blk_rq_stat_sum() 2024-11-19 09:23:14 +01:00
blk-stat.h
blk-sysfs.c Revert "mm: apply init protection" 2024-11-19 18:15:13 +01:00
blk-throttle.c
blk-timeout.c
blk-wbt.c
blk-wbt.h
blk-zoned.c
blk.h blk: Fix lock inversion between ioc lock and bfqd lock 2024-11-19 17:40:26 +01:00
bounce.c
bsg-lib.c
bsg.c
cmdline-parser.c
elevator.c block: Add default I/O scheduler option 2024-11-19 17:43:55 +01:00
genhd.c
ioctl.c block/ioctl: prefer different overflow check 2024-11-19 14:19:06 +01:00
ioprio.c
Kconfig
Kconfig.iosched block: Add default I/O scheduler option 2024-11-19 17:43:55 +01:00
keyslot-manager.c
kyber-iosched.c
Makefile
mq-deadline-cgroup.c
mq-deadline-cgroup.h
mq-deadline-main.c blk: Fix lock inversion between ioc lock and bfqd lock 2024-11-19 17:40:26 +01:00
opal_proto.h
scsi_ioctl.c
sed-opal.c
ssg-cgroup.c
ssg-cgroup.h
ssg-iosched.c block: ssg-iosched: adapt to new patches 2024-11-19 17:40:09 +01:00
t10-pi.c