linux-yocto/drivers/md
Sheng Yong 68860d1ade dm-bufio: fix sched in atomic context
commit b1bf1a782f upstream.

If "try_verify_in_tasklet" is set for dm-verity, DM_BUFIO_CLIENT_NO_SLEEP
is enabled for dm-bufio. However, when bufio tries to evict buffers, there
is a chance to trigger scheduling in spin_lock_bh, the following warning
is hit:

BUG: sleeping function called from invalid context at drivers/md/dm-bufio.c:2745
in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 123, name: kworker/2:2
preempt_count: 201, expected: 0
RCU nest depth: 0, expected: 0
4 locks held by kworker/2:2/123:
 #0: ffff88800a2d1548 ((wq_completion)dm_bufio_cache){....}-{0:0}, at: process_one_work+0xe46/0x1970
 #1: ffffc90000d97d20 ((work_completion)(&dm_bufio_replacement_work)){....}-{0:0}, at: process_one_work+0x763/0x1970
 #2: ffffffff8555b528 (dm_bufio_clients_lock){....}-{3:3}, at: do_global_cleanup+0x1ce/0x710
 #3: ffff88801d5820b8 (&c->spinlock){....}-{2:2}, at: do_global_cleanup+0x2a5/0x710
Preemption disabled at:
[<0000000000000000>] 0x0
CPU: 2 UID: 0 PID: 123 Comm: kworker/2:2 Not tainted 6.16.0-rc3-g90548c634bd0 #305 PREEMPT(voluntary)
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.3-0-ga6ed6b701f0a-prebuilt.qemu.org 04/01/2014
Workqueue: dm_bufio_cache do_global_cleanup
Call Trace:
 <TASK>
 dump_stack_lvl+0x53/0x70
 __might_resched+0x360/0x4e0
 do_global_cleanup+0x2f5/0x710
 process_one_work+0x7db/0x1970
 worker_thread+0x518/0xea0
 kthread+0x359/0x690
 ret_from_fork+0xf3/0x1b0
 ret_from_fork_asm+0x1a/0x30
 </TASK>

That can be reproduced by:

  veritysetup format --data-block-size=4096 --hash-block-size=4096 /dev/vda /dev/vdb
  SIZE=$(blockdev --getsz /dev/vda)
  dmsetup create myverity -r --table "0 $SIZE verity 1 /dev/vda /dev/vdb 4096 4096 <data_blocks> 1 sha256 <root_hash> <salt> 1 try_verify_in_tasklet"
  mount /dev/dm-0 /mnt -o ro
  echo 102400 > /sys/module/dm_bufio/parameters/max_cache_size_bytes
  [read files in /mnt]

Cc: stable@vger.kernel.org	# v6.4+
Fixes: 450e8dee51 ("dm bufio: improve concurrent IO performance")
Signed-off-by: Wang Shuai <wangshuai12@xiaomi.com>
Signed-off-by: Sheng Yong <shengyong1@xiaomi.com>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-07-24 08:56:22 +02:00
..
bcache bcache: fix NULL pointer in cache_set_flush() 2025-07-06 11:01:34 +02:00
dm-vdo dm vdo indexer: don't read request structure after enqueuing 2025-07-06 11:01:32 +02:00
persistent-data dm array: fix cursor index when skipping across block boundaries 2025-01-17 13:40:34 +01:00
dm-audit.c
dm-audit.h
dm-bio-prison-v1.c
dm-bio-prison-v1.h
dm-bio-prison-v2.c
dm-bio-prison-v2.h
dm-bio-record.h
dm-bufio.c dm-bufio: fix sched in atomic context 2025-07-24 08:56:22 +02:00
dm-builtin.c
dm-cache-background-tracker.c dm-cache: fix warnings about duplicate slab caches 2024-11-11 17:04:39 +01:00
dm-cache-background-tracker.h dm-cache: fix warnings about duplicate slab caches 2024-11-11 17:04:39 +01:00
dm-cache-block-types.h
dm-cache-metadata.c dm: Constify struct dm_block_validator 2024-07-19 12:08:15 +02:00
dm-cache-metadata.h
dm-cache-policy-internal.h
dm-cache-policy-smq.c
dm-cache-policy.c
dm-cache-policy.h
dm-cache-target.c dm cache: prevent BUG_ON by blocking retries on failed device resumes 2025-05-29 11:02:28 +02:00
dm-clone-metadata.c dm: Make use of __assign_bit() API 2024-09-02 16:53:53 +02:00
dm-clone-metadata.h
dm-clone-target.c dm: stop using blk_limits_io_{min,opt} 2024-07-10 13:10:06 +02:00
dm-core.h dm: fix dm_blk_report_zones 2025-06-19 15:32:05 +02:00
dm-crypt.c dm-crypt: track tag_offset in convert_context 2025-02-17 10:05:19 +01:00
dm-delay.c dm-delay: remove timer_lock 2024-05-09 09:10:58 -04:00
dm-dust.c
dm-ebs-target.c dm-ebs: fix prefetch-vs-suspend race 2025-04-20 10:15:53 +02:00
dm-era-target.c dm: Constify struct dm_block_validator 2024-07-19 12:08:15 +02:00
dm-exception-store.c
dm-exception-store.h
dm-flakey.c dm-flakey: make corrupting read bios work 2025-06-19 15:32:05 +02:00
dm-ima.c
dm-ima.h
dm-init.c dm init: Handle minors larger than 255 2024-07-02 20:53:41 +02:00
dm-integrity.c dm-integrity: fix a warning on invalid table line 2025-05-09 09:50:33 +02:00
dm-io-rewind.c
dm-io-tracker.h
dm-io.c dm io: remove code duplication between sync_io and aysnc_io 2024-07-02 12:00:43 +02:00
dm-ioctl.c dm resume: don't return EINVAL when signalled 2024-08-13 13:51:34 +02:00
dm-kcopyd.c
dm-linear.c dm: optimize flushes 2024-06-26 11:32:39 -04:00
dm-log-userspace-base.c
dm-log-userspace-transfer.c
dm-log-userspace-transfer.h
dm-log-writes.c dm: always manage discard support in terms of max_hw_discard_sectors 2024-05-20 15:51:19 -04:00
dm-log.c
dm-mpath.c dm mpath: don't call dm_get_device in multipath_message 2024-07-10 13:10:06 +02:00
dm-mpath.h
dm-path-selector.c
dm-path-selector.h
dm-ps-historical-service-time.c
dm-ps-io-affinity.c
dm-ps-queue-length.c
dm-ps-round-robin.c
dm-ps-service-time.c
dm-raid.c dm-raid: fix variable in journal device check 2025-07-06 11:01:43 +02:00
dm-raid1.c dm-mirror: fix a tiny race condition 2025-06-27 11:11:23 +01:00
dm-region-hash.c
dm-rq.c Revert "dm: requeue IO if mapping table not yet available" 2024-09-15 21:02:54 +02:00
dm-rq.h
dm-snap-persistent.c
dm-snap-transient.c
dm-snap.c dm: always manage discard support in terms of max_hw_discard_sectors 2024-05-20 15:51:19 -04:00
dm-stats.c
dm-stats.h
dm-stripe.c dm: stop using blk_limits_io_{min,opt} 2024-07-10 13:10:06 +02:00
dm-switch.c
dm-sysfs.c
dm-table.c dm: lock limits when reading them 2025-06-27 11:11:23 +01:00
dm-target.c dm: always manage discard support in terms of max_hw_discard_sectors 2024-05-20 15:51:19 -04:00
dm-thin-metadata.c dm: Constify struct dm_block_validator 2024-07-19 12:08:15 +02:00
dm-thin-metadata.h
dm-thin.c dm thin: make get_first_thin use rcu-safe list first function 2025-01-17 13:40:45 +01:00
dm-uevent.c
dm-uevent.h
dm-unstripe.c dm-unstriped: cast an operand to sector_t to prevent potential uint32_t overflow 2024-11-04 17:34:56 +01:00
dm-verity-fec.c dm-verity: fix a memory leak if some arguments are specified multiple times 2025-06-27 11:11:23 +01:00
dm-verity-fec.h dm-verity: always "map" the data blocks 2024-07-03 21:41:11 +02:00
dm-verity-loadpin.c
dm-verity-target.c dm-verity: fix a memory leak if some arguments are specified multiple times 2025-06-27 11:11:23 +01:00
dm-verity-verify-sig.c dm-verity: fix a memory leak if some arguments are specified multiple times 2025-06-27 11:11:23 +01:00
dm-verity-verify-sig.h
dm-verity.h dm-verity: don't crash if panic_on_corruption is not selected 2024-11-04 17:39:23 +01:00
dm-writecache.c
dm-zero.c dm: always manage discard support in terms of max_hw_discard_sectors 2024-05-20 15:51:19 -04:00
dm-zone.c dm: fix dm_blk_report_zones 2025-06-19 15:32:05 +02:00
dm-zoned-metadata.c
dm-zoned-reclaim.c dm: Fix dm-zoned-reclaim zone write pointer alignment 2024-12-19 18:13:00 +01:00
dm-zoned-target.c dm: stop using blk_limits_io_{min,opt} 2024-07-10 13:10:06 +02:00
dm-zoned.h
dm.c dm: free table mempools if not used in __bind 2025-06-19 15:32:04 +02:00
dm.h dm: Remove unused declaration and empty definition "dm_zone_map_bio" 2024-08-21 13:12:12 +02:00
Kconfig md: reintroduce md-linear 2025-02-17 10:05:04 +01:00
Makefile md: reintroduce md-linear 2025-02-17 10:05:04 +01:00
md-autodetect.c md: reintroduce md-linear 2025-02-17 10:05:04 +01:00
md-bitmap.c md/md-bitmap: fix GPF in bitmap_get_stats() 2025-07-17 18:37:09 +02:00
md-bitmap.h md/md-bitmap: remove the last parameter for bimtap_ops->endwrite() 2025-02-08 09:58:11 +01:00
md-cluster.c md/md-bitmap: make in memory structure internal 2024-08-27 12:43:16 -07:00
md-cluster.h md-cluster: fix no recovery job when adding/re-adding a disk 2024-07-12 01:30:18 +00:00
md-linear.c md: Fix linear_set_limits() 2025-02-17 10:05:47 +01:00
md.c md: fix mddev uaf while iterating all_mddevs list 2025-04-25 10:48:04 +02:00
md.h md/md-bitmap: move bitmap_{start, end}write to md upper layer 2025-02-08 09:58:12 +01:00
raid1-10.c md/md-bitmap: merge md_bitmap_enabled() into bitmap_operations 2024-08-27 12:43:16 -07:00
raid1.c md/raid1: Fix stack memory use after return in raid1_reshape 2025-07-17 18:37:16 +02:00
raid1.h md/md-bitmap: remove the last parameter for bimtap_ops->endwrite() 2025-02-08 09:58:11 +01:00
raid5-cache.c md/md-bitmap: move bitmap_{start, end}write to md upper layer 2025-02-08 09:58:12 +01:00
raid5-log.h
raid5-ppl.c
raid5.c md/md-bitmap: move bitmap_{start, end}write to md upper layer 2025-02-08 09:58:12 +01:00
raid5.h md/md-bitmap: move bitmap_{start, end}write to md upper layer 2025-02-08 09:58:12 +01:00
raid10.c raid10: cleanup memleak at raid10_make_request 2025-07-17 18:37:16 +02:00
raid10.h md/md-bitmap: remove the last parameter for bimtap_ops->endwrite() 2025-02-08 09:58:11 +01:00
raid0.c md/raid*: Fix the set_queue_limits implementations 2025-02-27 04:30:19 -08:00
raid0.h