Skip to content

Commit 6947fa1

Browse files
committed
dm: fix improper splitting for abnormal bios
jira LE-1907 Rebuild_History Non-Buildable kernel-rt-5.14.0-284.30.1.rt14.315.el9_2 commit-author Mike Snitzer <[email protected]> commit f7b58a6 Empty-Commit: Cherry-Pick Conflicts during history rebuild. Will be included in final tarball splat. Ref for failed cherry-pick at: ciq/ciq_backports/kernel-rt-5.14.0-284.30.1.rt14.315.el9_2/f7b58a69.failed "Abnormal" bios include discards, write zeroes and secure erase. By no longer passing the calculated 'len' pointer, commit 7dd06a2 ("dm: allow dm_accept_partial_bio() for dm_io without duplicate bios") took a senseless approach to disallowing dm_accept_partial_bio() from working for duplicate bios processed using __send_duplicate_bios(). It inadvertently and incorrectly stopped the use of 'len' when initializing a target's io (in alloc_tio). As such the resulting tio could address more area of a device than it should. For example, when discarding an entire DM striped device with the following DM table: vg-lvol0: 0 159744 striped 2 128 7:0 2048 7:1 2048 vg-lvol0: 159744 45056 striped 2 128 7:2 2048 7:3 2048 Before this fix: device-mapper: striped: target_stripe=0, bdev=7:0, start=2048 len=102400 blkdiscard: attempt to access beyond end of device loop0: rw=2051, sector=2048, nr_sectors = 102400 limit=81920 device-mapper: striped: target_stripe=1, bdev=7:1, start=2048 len=102400 blkdiscard: attempt to access beyond end of device loop1: rw=2051, sector=2048, nr_sectors = 102400 limit=81920 After this fix; device-mapper: striped: target_stripe=0, bdev=7:0, start=2048 len=79872 device-mapper: striped: target_stripe=1, bdev=7:1, start=2048 len=79872 Fixes: 7dd06a2 ("dm: allow dm_accept_partial_bio() for dm_io without duplicate bios") Cc: [email protected] Reported-by: Orange Kao <[email protected]> Signed-off-by: Mike Snitzer <[email protected]> (cherry picked from commit f7b58a6) Signed-off-by: Jonathan Maple <[email protected]> # Conflicts: # drivers/md/dm.c
1 parent 042f2fb commit 6947fa1

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
dm: fix improper splitting for abnormal bios
2+
3+
jira LE-1907
4+
Rebuild_History Non-Buildable kernel-rt-5.14.0-284.30.1.rt14.315.el9_2
5+
commit-author Mike Snitzer <[email protected]>
6+
commit f7b58a69fad9d2c4c90cab0247811155dd0d48e7
7+
Empty-Commit: Cherry-Pick Conflicts during history rebuild.
8+
Will be included in final tarball splat. Ref for failed cherry-pick at:
9+
ciq/ciq_backports/kernel-rt-5.14.0-284.30.1.rt14.315.el9_2/f7b58a69.failed
10+
11+
"Abnormal" bios include discards, write zeroes and secure erase. By no
12+
longer passing the calculated 'len' pointer, commit 7dd06a2548b2 ("dm:
13+
allow dm_accept_partial_bio() for dm_io without duplicate bios") took a
14+
senseless approach to disallowing dm_accept_partial_bio() from working
15+
for duplicate bios processed using __send_duplicate_bios().
16+
17+
It inadvertently and incorrectly stopped the use of 'len' when
18+
initializing a target's io (in alloc_tio). As such the resulting tio
19+
could address more area of a device than it should.
20+
21+
For example, when discarding an entire DM striped device with the
22+
following DM table:
23+
vg-lvol0: 0 159744 striped 2 128 7:0 2048 7:1 2048
24+
vg-lvol0: 159744 45056 striped 2 128 7:2 2048 7:3 2048
25+
26+
Before this fix:
27+
28+
device-mapper: striped: target_stripe=0, bdev=7:0, start=2048 len=102400
29+
blkdiscard: attempt to access beyond end of device
30+
loop0: rw=2051, sector=2048, nr_sectors = 102400 limit=81920
31+
32+
device-mapper: striped: target_stripe=1, bdev=7:1, start=2048 len=102400
33+
blkdiscard: attempt to access beyond end of device
34+
loop1: rw=2051, sector=2048, nr_sectors = 102400 limit=81920
35+
36+
After this fix;
37+
38+
device-mapper: striped: target_stripe=0, bdev=7:0, start=2048 len=79872
39+
device-mapper: striped: target_stripe=1, bdev=7:1, start=2048 len=79872
40+
41+
Fixes: 7dd06a2548b2 ("dm: allow dm_accept_partial_bio() for dm_io without duplicate bios")
42+
43+
Reported-by: Orange Kao <[email protected]>
44+
Signed-off-by: Mike Snitzer <[email protected]>
45+
(cherry picked from commit f7b58a69fad9d2c4c90cab0247811155dd0d48e7)
46+
Signed-off-by: Jonathan Maple <[email protected]>
47+
48+
# Conflicts:
49+
# drivers/md/dm.c
50+
diff --cc drivers/md/dm.c
51+
index a84025b34305,e67a2757c53e..000000000000
52+
--- a/drivers/md/dm.c
53+
+++ b/drivers/md/dm.c
54+
@@@ -1524,7 -1467,8 +1524,12 @@@ static void setup_split_accounting(stru
55+
}
56+
57+
static void alloc_multiple_bios(struct bio_list *blist, struct clone_info *ci,
58+
++<<<<<<< HEAD
59+
+ struct dm_target *ti, unsigned num_bios)
60+
++=======
61+
+ struct dm_target *ti, unsigned int num_bios,
62+
+ unsigned *len)
63+
++>>>>>>> f7b58a69fad9 (dm: fix improper splitting for abnormal bios)
64+
{
65+
struct bio *bio;
66+
int try;
67+
* Unmerged path drivers/md/dm.c

0 commit comments

Comments
 (0)