kernel_samsung_a53x/drivers
Ming-Hung Tsai 656ff2aa25 dm cache: correct the number of origin blocks to match the target length
commit 235d2e739fcbe964c9ce179b4c991025662dcdb6 upstream.

When creating a cache device, the actual size of the cache origin might
be greater than the specified cache target length. In such case, the
number of origin blocks should match the cache target length, not the
full size of the origin device, since access beyond the cache target is
not possible. This issue occurs when reducing the origin device size
using lvm, as lvreduce preloads the new cache table before resuming the
cache origin, which can result in incorrect sizes for the discard bitset
and smq hotspot blocks.

Reproduce steps:

1. create a cache device consists of 4096 origin blocks

dmsetup create cmeta --table "0 8192 linear /dev/sdc 0"
dmsetup create cdata --table "0 65536 linear /dev/sdc 8192"
dmsetup create corig --table "0 524288 linear /dev/sdc 262144"
dd if=/dev/zero of=/dev/mapper/cmeta bs=4k count=1 oflag=direct
dmsetup create cache --table "0 524288 cache /dev/mapper/cmeta \
/dev/mapper/cdata /dev/mapper/corig 128 2 metadata2 writethrough smq 0"

2. reduce the cache origin to 2048 oblocks, in lvreduce's approach

dmsetup reload corig --table "0 262144 linear /dev/sdc 262144"
dmsetup reload cache --table "0 262144 cache /dev/mapper/cmeta \
/dev/mapper/cdata /dev/mapper/corig 128 2 metadata2 writethrough smq 0"
dmsetup suspend cache
dmsetup suspend corig
dmsetup suspend cdata
dmsetup suspend cmeta
dmsetup resume corig
dmsetup resume cdata
dmsetup resume cmeta
dmsetup resume cache

3. shutdown the cache, and check the number of discard blocks in
   superblock. The value is expected to be 2048, but actually is 4096.

dmsetup remove cache corig cdata cmeta
dd if=/dev/sdc bs=1c count=8 skip=224 2>/dev/null | hexdump -e '1/8 "%u\n"'

Fix by correcting the origin_blocks initialization in cache_create and
removing the unused origin_sectors from struct cache_args accordingly.

Signed-off-by: Ming-Hung Tsai <mtsai@redhat.com>
Fixes: c6b4fcbad044 ("dm: add cache target")
Cc: stable@vger.kernel.org
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Acked-by: Joe Thornber <thornber@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-11-30 02:33:24 +01:00
..
accessibility
acpi Revert "ACPI: processor: Return an error if acpi_processor_get_info() fails in processor_add()" 2024-11-24 00:23:37 +01:00
amba
android Revert "binder: fix UAF caused by offsets overwrite" 2024-11-24 00:23:38 +01:00
ata Revert "ata: libata-core: Fix null pointer dereference on error" 2024-11-24 00:23:50 +01:00
atm atm: idt77252: prevent use after free in dequeue_rx() 2024-11-23 23:20:43 +01:00
auxdisplay
base Revert "devres: Initialize an uninitialized struct member" 2024-11-24 00:23:40 +01:00
battery
bcma
block zram: Set default compressor to zstd 2024-11-30 02:02:54 +01:00
bluetooth Revert "Bluetooth: hci_ldisc: check HCI_UART_PROTO_READY flag in HCIUARTGETPROTO" 2024-11-24 00:23:50 +01:00
bts
bus Revert "bus: integrator-lm: fix OF node leak in probe()" 2024-11-24 00:23:16 +01:00
cdrom
char Revert "tpm: Clean up TPM space after command failure" 2024-11-24 00:23:24 +01:00
clk Revert "clk: imx: imx8mp: fix clock tree update of TF-A managed clocks" 2024-11-24 00:23:22 +01:00
clocksource Revert "clocksource/drivers/imx-tpm: Fix return -ETIME when delta exceeds INT_MAX" 2024-11-24 00:23:37 +01:00
connector
counter counter: ti-eqep: enable clock at probe 2024-11-19 14:19:33 +01:00
cpufreq Revert "cpufreq: ti-cpufreq: Introduce quirks to handle syscon fails appropriately" 2024-11-24 00:23:30 +01:00
cpuidle cpuidle: menu: Take negative "sleep length" values into account 2024-11-19 18:01:28 +01:00
crypto Revert "crypto: ccp - Properly unregister /dev/sev on sev PLATFORM_STATUS failure" 2024-11-24 00:23:16 +01:00
dax
dca
devfreq
dio
dma dmaengine: dw: Add memory bus width verification 2024-11-23 23:20:55 +01:00
dma-buf dma-buf/sync_file: Speed up ioctl by omitting debug names 2024-11-19 17:53:23 +01:00
edac EDAC, i10nm: make skx_common.o a separate module 2024-11-23 23:19:56 +01:00
eisa
extcon
fingerprint
firewire
firmware Revert "efistub/tpm: Use ACPI reclaim memory for event log to avoid corruption" 2024-11-24 00:23:16 +01:00
fpga
fsi
gnss
gpio Revert "gpio: prevent potential speculation leaks in gpio_device_get_desc()" 2024-11-24 00:23:32 +01:00
gpu drm/amdgpu: prevent NULL pointer dereference if ATIF is not supported 2024-11-30 02:33:24 +01:00
greybus greybus: Fix use-after-free bug in gb_interface_release due to race condition. 2024-11-19 14:19:05 +01:00
gud
hid HID: core: zero-initialize the report buffer 2024-11-30 02:33:21 +01:00
hsi
hv Revert "Drivers: hv: vmbus: Fix rescind handling in uio_hv_generic" 2024-11-24 00:23:37 +01:00
hwmon Revert "hwmon: (adc128d818) Fix underflows seen when writing limit attributes" 2024-11-24 00:23:40 +01:00
hwspinlock Revert "hwspinlock: Introduce hwspin_lock_bust()" 2024-11-24 00:23:48 +01:00
hwtracing Revert "coresight: tmc: sg: Do not leak sg_table" 2024-11-24 00:23:19 +01:00
i2c Revert "i2c: Add i2c_get_match_data()" 2024-11-24 00:23:27 +01:00
i3c
ide
idle
ifconn
iio Revert "iio: buffer-dmaengine: fix releasing dma channel on error" 2024-11-24 00:23:38 +01:00
infiniband Revert "RDMA/iwcm: Fix WARNING:at_kernel/workqueue.c:#check_flush_dependency" 2024-11-24 00:23:21 +01:00
input Revert "Input: uinput - reject requests with unreasonable number of slots" 2024-11-24 00:23:39 +01:00
interconnect Revert "interconnect: qcom: sm8250: Enable sync_state" 2024-11-24 00:23:19 +01:00
iommu Revert "iommu: sun50i: clear bypass register" 2024-11-24 00:23:43 +01:00
ipack
irqchip Revert "irqchip/gic-v2m: Fix refcount leak in gicv2m_of_init()" 2024-11-24 00:23:46 +01:00
isdn mISDN: Fix a use after free in hfcmulti_tx() 2024-11-23 23:20:17 +01:00
kperfmon
kq/mesh
leds Revert "leds: spi-byte: Call of_node_put() on error path" 2024-11-24 00:23:43 +01:00
lightnvm
macintosh macintosh/therm_windtunnel: fix module unload. 2024-11-23 23:20:11 +01:00
mailbox Revert "mailbox: rockchip: fix a typo in module autoloading" 2024-11-24 00:23:13 +01:00
mcb
md dm cache: correct the number of origin blocks to match the target length 2024-11-30 02:33:24 +01:00
media media: v4l2-tpg: prevent the risk of a division by zero 2024-11-30 02:33:23 +01:00
memory memory: stm32-fmc2-ebi: check regmap_read return value 2024-11-23 23:20:46 +01:00
memstick
message
mfd mfd: omap-usb-tll: Use struct_size to allocate tll 2024-11-23 23:20:09 +01:00
misc drivers: samsung: scsc: Adapt scsc_wlbtd.c for Linux 5.10.229 2024-11-24 00:42:20 +01:00
mmc Revert "mmc: mmc_test: Fix NULL dereference on allocation failure" 2024-11-24 00:23:50 +01:00
most
mtd Revert "mtd: slram: insert break after errors in parsing the map" 2024-11-24 00:23:27 +01:00
muic
mux
net net: arc: fix the device for dma_map_single/dma_unmap_single 2024-11-30 02:33:22 +01:00
nfc nfc: pn533: Add poll mod list filling check 2024-11-23 23:20:55 +01:00
ntb Revert "ntb: intel: Fix the NULL vs IS_ERR() bug for debugfs_create_dir()" 2024-11-24 00:23:20 +01:00
nubus
nvdimm Revert "virtio_pmem: Check device status before requesting flush" 2024-11-24 00:22:58 +01:00
nvme Revert "nvme/pci: Add APST quirk for Lenovo N60z laptop" 2024-11-24 00:23:54 +01:00
nvmem Revert "nvmem: Fix return type of devm_nvmem_device_get() in kerneldoc" 2024-11-24 00:23:38 +01:00
of Revert "of/irq: Prevent device address out-of-bounds read in interrupt map walk" 2024-11-24 00:23:38 +01:00
opp
oprofile
parisc
parport Revert "parport: Proper fix for array out-of-bounds access" 2024-11-24 00:22:51 +01:00
pci Revert "PCI: keystone: Add workaround for Errata #i2037 (AM65x SR 1.0)" 2024-11-24 00:23:42 +01:00
pcmcia Revert "pcmcia: Use resource_size function on resource object" 2024-11-24 00:23:42 +01:00
perf
phy
pinctrl Revert "pinctrl: rockchip: correct RK3328 iomux width flag for GPIO2-B pins" 2024-11-24 00:23:50 +01:00
platform platform/x86: touchscreen_dmi: add nanote-next quirk 2024-11-23 23:21:40 +01:00
pnp
power Revert "power: supply: axp20x_battery: allow disabling battery charging" 2024-11-24 00:23:27 +01:00
powercap Revert "powercap: RAPL: fix invalid initialization for pl4_supported field" 2024-11-24 00:23:18 +01:00
pps Revert "pps: remove usage of the deprecated ida_simple_xx() API" 2024-11-24 00:23:14 +01:00
ps3
ptp
pwm pwm: imx-tpm: Use correct MODULO value for EPWM mode 2024-11-30 02:33:24 +01:00
rapidio
ras
regulator regulator: core: Fix modpost error "regulator_get_regmap" undefined 2024-11-19 14:19:09 +01:00
remoteproc remoteproc: imx_rproc: Skip over memory region when node value is NULL 2024-11-23 23:20:20 +01:00
reset Revert "reset: berlin: fix OF node leak in probe() error path" 2024-11-24 00:23:27 +01:00
rpmsg
rtc Revert "rtc: at91sam9: fix OF node leak in probe() error path" 2024-11-24 00:23:01 +01:00
s390 Revert "s390/zcore: no need to check return value of debugfs_create functions" 2024-11-24 00:22:59 +01:00
samsung
sbus
scsi scsi: sd_zbc: Use kvzalloc() to allocate REPORT ZONES buffer 2024-11-30 02:33:23 +01:00
sensorhub
sensors
sfi
sh
siox
slimbus
soc Revert "soc: versatile: integrator: fix OF node leak in probe() error path" 2024-11-24 00:23:17 +01:00
soundwire Revert "soundwire: stream: fix programming slave ports for non-continous port maps" 2024-11-24 00:23:49 +01:00
spi Revert "spi: nxp-fspi: fix the KASAN report out-of-bounds bug" 2024-11-24 00:23:34 +01:00
spmi
spu_verify
ssb ssb: Fix division by zero issue in ssb_calc_clock_rate 2024-11-23 23:20:44 +01:00
staging Revert "staging: iio: frequency: ad9834: Validate frequency parameter value" 2024-11-24 00:23:38 +01:00
sti
target scsi: target: core: Fix null-ptr-deref in target_alloc_device() 2024-11-23 23:21:59 +01:00
tc
tee
thermal
thunderbolt thunderbolt: Mark XDomain as unplugged when router is removed 2024-11-23 23:20:42 +01:00
tty Revert "tty: rp2: Fix reset with non forgiving PCIe host bridges" 2024-11-24 00:23:16 +01:00
uh
uio Revert "uio_hv_generic: Fix kernel NULL pointer dereference in hv_uio_rescind" 2024-11-24 00:23:37 +01:00
usb Revert "usb: uas: set host status byte on data completion error" 2024-11-24 00:23:42 +01:00
vdpa
vfio
vhost Revert "vdpa: Add eventfd for the vdpa callback" 2024-11-24 00:23:19 +01:00
vibrator
video Revert "fbdev: hpfb: Fix an error handling path in hpfb_dio_probe()" 2024-11-24 00:23:26 +01:00
virt
virtio Revert "vdpa: Add eventfd for the vdpa callback" 2024-11-24 00:23:19 +01:00
vision
vision3
visorbus
vlynq
vme
w1
watchdog watchdog: s3c2410_wdt: Assign s3c_wdt[] until probe complete 2024-11-30 02:18:58 +01:00
xen Revert "xen/swiotlb: add alignment check for dma buffers" 2024-11-24 00:23:24 +01:00
zorro
Kconfig Added KernelSU 2024-11-19 22:44:48 +01:00
Kconfig.variant1
kernelsu Added KernelSU 2024-11-19 22:44:48 +01:00
Makefile Added KernelSU 2024-11-19 22:44:48 +01:00
Makefile.variant1