OpenCloudOS-Kernel/drivers/md/bcache
Matthew Mirvish 6479b9f415 bcache: fix variable length array abuse in btree_iter
commit 3a861560ccb35f2a4f0a4b8207fa7c2a35fc7f31 upstream.

btree_iter is used in two ways: either allocated on the stack with a
fixed size MAX_BSETS, or from a mempool with a dynamic size based on the
specific cache set. Previously, the struct had a fixed-length array of
size MAX_BSETS which was indexed out-of-bounds for the dynamically-sized
iterators, which causes UBSAN to complain.

This patch uses the same approach as in bcachefs's sort_iter and splits
the iterator into a btree_iter with a flexible array member and a
btree_iter_stack which embeds a btree_iter as well as a fixed-length
data array.

Cc: stable@vger.kernel.org
Closes: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2039368
Signed-off-by: Matthew Mirvish <matthew@mm12.xyz>
Signed-off-by: Coly Li <colyli@suse.de>
Link: https://lore.kernel.org/r/20240509011117.2697-3-colyli@suse.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-06-16 13:47:32 +02:00
..
Kconfig bcache: remove EXPERIMENTAL for Kconfig option 'Asynchronous device registration' 2022-08-02 17:22:41 -06:00
Makefile bcache: add sysfs file to display feature sets information of cache set 2020-07-25 07:38:21 -06:00
alloc.c block: decouple REQ_OP_SECURE_ERASE from REQ_OP_DISCARD 2022-04-17 19:49:59 -06:00
bcache.h bcache: avoid oversize memory allocation by small stripe_size 2023-12-20 17:01:56 +01:00
bcache_ondisk.h flexible-array transformations for 6.3-rc1 2023-02-25 12:53:42 -08:00
bset.c bcache: fix variable length array abuse in btree_iter 2024-06-16 13:47:32 +02:00
bset.h bcache: fix variable length array abuse in btree_iter 2024-06-16 13:47:32 +02:00
btree.c bcache: fix variable length array abuse in btree_iter 2024-06-16 13:47:32 +02:00
btree.h Locking changes for v6.5: 2023-06-27 14:14:30 -07:00
closure.c bcache: Convert to DEFINE_SHOW_ATTRIBUTE 2020-10-02 14:25:29 -06:00
closure.h
debug.c block: turn bio_kmalloc into a simple kmalloc wrapper 2022-04-17 19:30:41 -06:00
debug.h
extents.c bcache: remove PTR_CACHE 2021-04-11 08:37:55 -06:00
extents.h
features.c bcache: move uapi header bcache.h to bcache code directory 2021-10-29 06:43:21 -06:00
features.h bcache: move uapi header bcache.h to bcache code directory 2021-10-29 06:43:21 -06:00
io.c block: pass a block_device and opf to bio_init 2022-02-02 07:49:59 -07:00
journal.c bcache: Silence memcpy() run-time false positive warnings 2023-01-25 12:24:50 -08:00
journal.h bcache: avoid journal no-space deadlock by reserving 1 journal bucket 2022-05-24 06:19:33 -06:00
movinggc.c block: remove bio_set_op_attrs 2022-12-07 09:43:12 -07:00
request.c block: replace fmode_t with a block-specific type for block open flags 2023-06-12 08:04:05 -06:00
request.h block: switch polling to be bio based 2021-10-18 06:17:36 -06:00
stats.c bcache: use default_groups in kobj_type 2022-01-26 15:56:18 +01:00
stats.h bcache: Remove dead references to cache_readaheads 2023-06-15 07:30:11 -06:00
super.c bcache: fix variable length array abuse in btree_iter 2024-06-16 13:47:32 +02:00
sysfs.c bcache: fix variable length array abuse in btree_iter 2024-06-16 13:47:32 +02:00
sysfs.h bcache: make kobj_type structures constant 2023-06-15 07:30:11 -06:00
trace.c
util.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
util.h for-5.16/bdev-size-2021-10-29 2021-11-01 09:50:37 -07:00
writeback.c bcache: fix variable length array abuse in btree_iter 2024-06-16 13:47:32 +02:00
writeback.h bcache: improve multithreaded bch_sectors_dirty_init() 2022-05-24 06:19:33 -06:00