aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorKevin Corry <kevcorry@us.ibm.com>2006-03-17 02:04:03 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-17 10:51:25 -0500
commit8ba32fde2c5be52865b2fd7e5e3752a46971fabe (patch)
tree91988d69b76b1d142117b0ed827fc20eb11c9360 /drivers
parent82c3c03a4096badd026c6e337f3c5dde020e9ec6 (diff)
[PATCH] dm stripe: Fix bounds
The dm-stripe target currently does not enforce that the size of a stripe device be a multiple of the chunk-size. Under certain conditions, this can lead to I/O requests going off the end of an underlying device. This test-case shows one example. echo "0 100 linear /dev/hdb1 0" | dmsetup create linear0 echo "0 100 linear /dev/hdb1 100" | dmsetup create linear1 echo "0 200 striped 2 32 /dev/mapper/linear0 0 /dev/mapper/linear1 0" | \ dmsetup create stripe0 dd if=/dev/zero of=/dev/mapper/stripe0 bs=1k This will produce the output: dd: writing '/dev/mapper/stripe0': Input/output error 97+0 records in 96+0 records out And in the kernel log will be: attempt to access beyond end of device dm-0: rw=0, want=104, limit=100 The patch will check that the table size is a multiple of the stripe chunk-size when the table is created, which will prevent the above striped device from being created. This should not affect tools like LVM or EVMS, since in all the cases I can think of, striped devices are always created with the sizes being a multiple of the chunk-size. The size of a stripe device must be a multiple of its chunk-size. (akpm: that typecast is quite gratuitous) Signed-off-by: Kevin Corry <kevcorry@us.ibm.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/md/dm-stripe.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
index ab89278a56bf..697aacafb02a 100644
--- a/drivers/md/dm-stripe.c
+++ b/drivers/md/dm-stripe.c
@@ -103,9 +103,15 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
103 return -EINVAL; 103 return -EINVAL;
104 } 104 }
105 105
106 if (((uint32_t)ti->len) & (chunk_size - 1)) {
107 ti->error = "dm-stripe: Target length not divisible by "
108 "chunk size";
109 return -EINVAL;
110 }
111
106 width = ti->len; 112 width = ti->len;
107 if (sector_div(width, stripes)) { 113 if (sector_div(width, stripes)) {
108 ti->error = "dm-stripe: Target length not divisable by " 114 ti->error = "dm-stripe: Target length not divisible by "
109 "number of stripes"; 115 "number of stripes";
110 return -EINVAL; 116 return -EINVAL;
111 } 117 }