WSL2-Linux-Kernel/block
Tejun Heo 1e4d3f8bd8 blk-iocost: Fix an UBSAN shift-out-of-bounds warning
[ Upstream commit 2a427b49d02995ea4a6ff93a1432c40fa4d36821 ]

When iocg_kick_delay() is called from a CPU different than the one which set
the delay, @now may be in the past of @iocg->delay_at leading to the
following warning:

  UBSAN: shift-out-of-bounds in block/blk-iocost.c:1359:23
  shift exponent 18446744073709 is too large for 64-bit type 'u64' (aka 'unsigned long long')
  ...
  Call Trace:
   <TASK>
   dump_stack_lvl+0x79/0xc0
   __ubsan_handle_shift_out_of_bounds+0x2ab/0x300
   iocg_kick_delay+0x222/0x230
   ioc_rqos_merge+0x1d7/0x2c0
   __rq_qos_merge+0x2c/0x80
   bio_attempt_back_merge+0x83/0x190
   blk_attempt_plug_merge+0x101/0x150
   blk_mq_submit_bio+0x2b1/0x720
   submit_bio_noacct_nocheck+0x320/0x3e0
   __swap_writepage+0x2ab/0x9d0

The underflow itself doesn't really affect the behavior in any meaningful
way; however, the past timestamp may exaggerate the delay amount calculated
later in the code, which shouldn't be a material problem given the nature of
the delay mechanism.

If @now is in the past, this CPU is racing another CPU which recently set up
the delay and there's nothing this CPU can contribute w.r.t. the delay.
Let's bail early from iocg_kick_delay() in such cases.

Reported-by: Breno Leitão <leitao@debian.org>
Signed-off-by: Tejun Heo <tj@kernel.org>
Fixes: 5160a5a53c ("blk-iocost: implement delay adjustment hysteresis")
Link: https://lore.kernel.org/r/ZVvc9L_CYk5LO1fT@slm.duckdns.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-02-23 08:54:59 +01:00
..
partitions block: Move checking GENHD_FL_NO_PART to bdev_add_partition() 2024-02-23 08:54:35 +01:00
Kconfig
Kconfig.iosched
Makefile
badblocks.c
bdev.c block: move GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE to disk->event_flags 2023-09-19 12:23:02 +02:00
bfq-cgroup.c
bfq-iosched.c
bfq-iosched.h
bfq-wf2q.c
bio-integrity.c
bio.c block: prevent an integer overflow in bvec_try_merge_hw_page 2024-02-23 08:54:44 +01:00
blk-cgroup-rwstat.c
blk-cgroup-rwstat.h
blk-cgroup.c blk-cgroup: bypass blkcg_deactivate_policy after destroying 2023-12-20 15:17:39 +01:00
blk-core.c blk-core: use pr_warn_ratelimited() in bio_check_ro() 2023-11-20 11:08:29 +01:00
blk-crypto-fallback.c
blk-crypto-internal.h
blk-crypto.c
blk-exec.c
blk-flush.c
blk-integrity.c
blk-ioc.c
blk-iocost.c blk-iocost: Fix an UBSAN shift-out-of-bounds warning 2024-02-23 08:54:59 +01:00
blk-iolatency.c
blk-ioprio.c
blk-ioprio.h
blk-lib.c
blk-map.c
blk-merge.c
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-mq-sched.h
blk-mq-sysfs.c
blk-mq-tag.c
blk-mq-tag.h
blk-mq-virtio.c
blk-mq.c blk-mq: fix IO hang from sbitmap wakeup race 2024-02-23 08:54:52 +01:00
blk-mq.h
blk-pm.c
blk-pm.h
blk-rq-qos.c
blk-rq-qos.h
blk-settings.c block: make BLK_DEF_MAX_SECTORS unsigned 2024-01-25 14:52:40 -08:00
blk-stat.c
blk-stat.h
blk-sysfs.c block: fix use-after-free of q->q_usage_counter 2023-10-10 21:59:05 +02:00
blk-throttle.c blk-throttle: fix lockdep warning of "cgroup_mutex or RCU read lock required!" 2023-12-20 15:17:39 +01:00
blk-timeout.c
blk-wbt.c
blk-wbt.h
blk-zoned.c
blk.h
bounce.c
bsg-lib.c
bsg.c
disk-events.c block: increment diskseq on all media change events 2023-07-23 13:47:20 +02:00
elevator.c
fops.c block: Don't invalidate pagecache for invalid falloc modes 2024-01-15 18:51:07 +01:00
genhd.c block: add check of 'minors' and 'first_minor' in device_add_disk() 2024-01-25 14:52:39 -08:00
holder.c
ioctl.c block: Move checking GENHD_FL_NO_PART to bdev_add_partition() 2024-02-23 08:54:35 +01:00
ioprio.c
keyslot-manager.c
kyber-iosched.c
mq-deadline.c
opal_proto.h
sed-opal.c
t10-pi.c