WSL2-Linux-Kernel/drivers
Jason Baron 4f61488541 md/raid0: add discard support for the 'original' layout
commit e836007089 upstream.

We've found that using raid0 with the 'original' layout and discard
enabled with different disk sizes (such that at least two zones are
created) can result in data corruption. This is due to the fact that
the discard handling in 'raid0_handle_discard()' assumes the 'alternate'
layout. We've seen this corruption using ext4 but other filesystems are
likely susceptible as well.

More specifically, while multiple zones are necessary to create the
corruption, the corruption may not occur with multiple zones if they
layout in such a way the layout matches what the 'alternate' layout
would have produced. Thus, not all raid0 devices with the 'original'
layout, different size disks and discard enabled will encounter this
corruption.

The 3.14 kernel inadvertently changed the raid0 disk layout for different
size disks. Thus, running a pre-3.14 kernel and post-3.14 kernel on the
same raid0 array could corrupt data. This lead to the creation of the
'original' layout (to match the pre-3.14 layout) and the 'alternate' layout
(to match the post 3.14 layout) in the 5.4 kernel time frame and an option
to tell the kernel which layout to use (since it couldn't be autodetected).
However, when the 'original' layout was added back to 5.4 discard support
for the 'original' layout was not added leading this issue.

I've been able to reliably reproduce the corruption with the following
test case:

1. create raid0 array with different size disks using original layout
2. mkfs
3. mount -o discard
4. create lots of files
5. remove 1/2 the files
6. fstrim -a (or just the mount point for the raid0 array)
7. umount
8. fsck -fn /dev/md0 (spews all sorts of corruptions)

Let's fix this by adding proper discard support to the 'original' layout.
The fix 'maps' the 'original' layout disks to the order in which they are
read/written such that we can compare the disks in the same way that the
current 'alternate' layout does. A 'disk_shift' field is added to
'struct strip_zone'. This could be computed on the fly in
raid0_handle_discard() but by adding this field, we save some computation
in the discard path.

Note we could also potentially fix this by re-ordering the disks in the
zones that follow the first one, and then always read/writing them using
the 'alternate' layout. However, that is seen as a more substantial change,
and we are attempting the least invasive fix at this time to remedy the
corruption.

I've verified the change using the reproducer mentioned above. Typically,
the corruption is seen after less than 3 iterations, while the patch has
run 500+ iterations.

Cc: NeilBrown <neilb@suse.de>
Cc: Song Liu <song@kernel.org>
Fixes: c84a1372df ("md/raid0: avoid RAID0 data corruption due to layout confusion.")
Cc: stable@vger.kernel.org
Signed-off-by: Jason Baron <jbaron@akamai.com>
Signed-off-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20230623180523.1901230-1-jbaron@akamai.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-07-23 13:47:51 +02:00
..
accessibility
acpi ACPI: sleep: Avoid breaking S3 wakeup due to might_sleep() 2023-06-28 10:29:42 +02:00
amba
android binder: fix UAF of alloc->vma in race with munmap() 2023-06-05 09:21:25 +02:00
ata ata: ahci: fix enum constants for gcc-13 2023-06-14 11:12:59 +02:00
atm atm: idt77252: fix kmemleak when rmmod idt77252 2023-03-30 12:47:48 +02:00
auxdisplay
base PM: domains: fix integer overflow issues in genpd_parse_state() 2023-07-23 13:46:46 +02:00
bcma
block xen/blkfront: Only check REQ_FUA for writes 2023-06-21 15:59:13 +02:00
bluetooth Bluetooth: hci_qca: fix debugfs registration 2023-06-14 11:13:06 +02:00
bus bus: ti-sysc: Fix dispc quirk masking bool variables 2023-07-23 13:46:59 +02:00
cdrom
char hwrng: imx-rngc - fix the timeout for init and self check 2023-07-23 13:47:49 +02:00
clk clk: qcom: ipq6018: fix networking resets 2023-07-23 13:47:22 +02:00
clocksource clocksource/drivers/cadence-ttc: Fix memory leak in ttc_timer_probe 2023-07-23 13:46:45 +02:00
comedi
connector
counter counter: 104-quad-8: Fix race condition between FLAG and CNTR reads 2023-04-26 13:51:55 +02:00
cpufreq cpufreq: intel_pstate: Fix energy_performance_preference for passive 2023-07-23 13:46:46 +02:00
cpuidle cpuidle: psci: Iterate backwards over list in psci_pd_remove() 2023-03-22 13:31:36 +01:00
crypto crypto: qat - unmap buffers before free for RSA 2023-07-23 13:47:16 +02:00
cxl
dax dax/kmem: Pass valid argument to memory_group_register_static 2023-07-23 13:47:17 +02:00
dca
devfreq
dio
dma dmaengine: pl330: rename _start to prevent build error 2023-06-09 10:32:15 +02:00
dma-buf
edac EDAC/skx: Fix overflows on the DRAM row address mapping arrays 2023-05-11 23:00:20 +09:00
eisa
extcon extcon: usbc-tusb320: Convert to i2c's .probe_new() 2023-07-23 13:47:31 +02:00
firewire
firmware efi/libstub: Disable PCI DMA before grabbing the EFI memory map 2023-07-23 13:47:17 +02:00
fpga fpga: bridge: fix kernel-doc parameter description 2023-05-11 23:00:31 +09:00
fsi
gnss
gpio gpio: sifive: add missing check for platform_get_irq 2023-06-28 10:29:50 +02:00
gpu drm/i915: Fix one wrong caching mode enum usage 2023-07-23 13:47:44 +02:00
greybus
hid HID: logitech-hidpp: add HIDPP_QUIRK_DELAYED_INIT for the T651. 2023-07-05 18:25:05 +01:00
hsi
hv Drivers: hv: vmbus: Fix vmbus_wait_for_unload() to scan present CPUs 2023-06-28 10:29:42 +02:00
hwmon hwmon: (pmbus/adm1275) Fix problems with temperature monitoring on ADM1272 2023-07-23 13:47:06 +02:00
hwspinlock
hwtracing coresight: Fix loss of connection info when a module is unloaded 2023-07-23 13:47:23 +02:00
i2c i2c: qup: Add missing unwind goto in qup_i2c_probe() 2023-07-23 13:47:31 +02:00
i3c
idle
iio iio: accel: fxls8962af: fixup buffer scan element type 2023-07-23 13:47:19 +02:00
infiniband RDMA/bnxt_re: Avoid calling wake_up threads from spin_lock context 2023-07-23 13:47:07 +02:00
input Input: adxl34x - do not hardcode interrupt trigger type 2023-07-23 13:46:59 +02:00
interconnect interconnect: qcom: osm-l3: fix icc_onecell_data allocation 2023-03-30 12:47:41 +02:00
iommu iommu/amd: Fix domain flush size when syncing iotlb 2023-06-09 10:32:31 +02:00
ipack
irqchip irqchip/jcore-aic: Fix missing allocation of IRQ descriptors 2023-07-23 13:46:45 +02:00
isdn
leds leds: trigger: netdev: Recheck NETDEV_LED_MODE_LINKUP on dev rename 2023-07-23 13:47:36 +02:00
macintosh macintosh: via-pmu-led: requires ATA to be set 2023-05-11 23:00:34 +09:00
mailbox mailbox: ti-msgmgr: Fill non-message tx data fields with 0x0 2023-07-23 13:47:28 +02:00
mcb mcb-pci: Reallocate memory region to avoid memory overlapping 2023-05-24 17:36:47 +01:00
md md/raid0: add discard support for the 'original' layout 2023-07-23 13:47:51 +02:00
media media: cec: i2c: ch7322: also select REGMAP 2023-07-23 13:47:27 +02:00
memory memory: brcmstb_dpfe: fix testing array offset after use 2023-07-23 13:47:03 +02:00
memstick memstick r592: make memstick_debug_get_tpc_name() static 2023-07-23 13:46:52 +02:00
message scsi: message: mptlan: Fix use after free bug in mptlan_remove() due to race condition 2023-05-24 17:36:45 +01:00
mfd mfd: pm8008: Fix module autoloading 2023-07-23 13:47:51 +02:00
misc misc: pci_endpoint_test: Re-init completion for every test 2023-07-23 13:47:51 +02:00
mmc mmc: sdhci: fix DMA configure compatibility issue when 64bit DMA mode is used. 2023-07-23 13:47:32 +02:00
most
mtd mtd: rawnand: meson: fix unaligned DMA buffers handling 2023-07-23 13:47:47 +02:00
mux
net net: bcmgenet: Ensure MDIO unregistration has clocks enabled 2023-07-23 13:47:47 +02:00
nfc nfcsim.c: Fix error checking for debugfs_create_dir 2023-06-28 10:29:51 +02:00
ntb NTB: ntb_tool: Add check for devm_kcalloc 2023-07-23 13:47:42 +02:00
nubus nubus: Partially revert proc_create_single_data() conversion 2023-07-05 18:25:05 +01:00
nvdimm
nvme nvme-pci: fix DMA direction of unmapping integrity data 2023-07-23 13:47:46 +02:00
nvmem nvmem: rmem: Use NVMEM_DEVID_AUTO 2023-07-23 13:47:25 +02:00
of of: overlay: add entry to of_overlay_action_name[] 2023-06-21 15:59:19 +02:00
opp
parisc parisc: Replace regular spinlock with spin_trylock on panic path 2023-05-24 17:36:48 +01:00
parport
pci PCI: rockchip: Set address alignment for endpoint mode 2023-07-23 13:47:51 +02:00
pcmcia
perf perf/arm-cmn: Fix DTC reset 2023-07-23 13:46:46 +02:00
phy phy: tegra: xusb: check return value of devm_kzalloc() 2023-07-23 13:47:26 +02:00
pinctrl pinctrl: amd: Only use special debounce behavior for GPIO 0 2023-07-23 13:47:46 +02:00
platform platform/x86: wmi: Break possible infinite loop when parsing GUID 2023-07-23 13:47:43 +02:00
pnp
power power: supply: Fix logic checking if system is running from battery 2023-06-21 15:59:13 +02:00
powercap powercap: RAPL: Fix CONFIG_IOSF_MBI dependency 2023-07-23 13:46:46 +02:00
pps
ps3
ptp ptp_qoriq: fix memory leak in probe() 2023-04-05 11:24:55 +02:00
pwm pwm: mtk_disp: Fix the disable flow of disp_pwm 2023-07-23 13:47:27 +02:00
rapidio
ras
regulator regulator: core: Streamline debugfs operations 2023-07-23 13:46:50 +02:00
remoteproc remoteproc: stm32_rproc: Add mutex protection for workqueue 2023-05-24 17:36:44 +01:00
reset
rpmsg
rtc rtc: st-lpc: Release some resources in st_rtc_probe() in case of error 2023-07-23 13:47:27 +02:00
s390 s390/qeth: Fix vipa deletion 2023-07-23 13:47:30 +02:00
sbus
scsi scsi: qla2xxx: Fix error code in qla2x00_start_sp() 2023-07-23 13:47:40 +02:00
sh
siox
slimbus
soc drivers: meson: secure-pwrc: always enable DMA domain 2023-07-23 13:47:09 +02:00
soundwire soundwire: dmi-quirks: add new mapping for HP Spectre x360 2023-06-28 10:29:52 +02:00
spi spi: bcm-qspi: return error if neither hif_mspi nor mspi is available 2023-07-23 13:47:28 +02:00
spmi spmi: Add a check for remove callback when removing a SPMI driver 2023-05-11 23:00:34 +09:00
ssb
staging media: atomisp: gmin_platform: fix out_len in gmin_get_config_dsm_var() 2023-07-23 13:47:24 +02:00
target scsi: target: iscsi: Prevent login threads from racing between each other 2023-06-28 10:29:50 +02:00
tc
tee tee: amdtee: Add return_origin to 'struct tee_cmd_load_ta' 2023-06-14 11:13:06 +02:00
thermal thermal/drivers/sun8i: Fix some error handling paths in sun8i_ths_probe() 2023-07-23 13:46:46 +02:00
thunderbolt thunderbolt: Mask ring interrupt on Intel hardware as well 2023-06-21 15:59:15 +02:00
tty tty: serial: fsl_lpuart: add earlycon for imx8ulp platform 2023-07-23 13:47:37 +02:00
uio
usb Revert "usb: common: usb-conn-gpio: Set last role to unknown before initial detection" 2023-07-23 13:47:25 +02:00
vdpa vduse: avoid empty string for dev name 2023-06-14 11:13:09 +02:00
vfio
vhost vhost_net: revert upend_idx only on retriable error 2023-06-28 10:29:53 +02:00
video fbdev: omapfb: lcd_mipid: Fix an error handling path in mipid_spi_probe() 2023-07-23 13:47:05 +02:00
virt
virtio virtio_ring: don't update event idx on get_buf 2023-05-11 23:00:34 +09:00
visorbus
vlynq
vme
w1 w1: fix loop in w1_fini() 2023-07-23 13:47:20 +02:00
watchdog watchdog: menz069_wdt: fix watchdog initialisation 2023-06-09 10:32:19 +02:00
xen xen/pvcalls-back: fix double frees with pvcalls_new_active_socket() 2023-05-30 13:55:32 +01:00
zorro
Kconfig
Makefile