[PATCH] dm-stripe: return -EINVAL if stripe count is zero

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If zero is passed as stripe count to the stripe_ctr, it segfaults with
a divide by zero error.

divide error: 0000 [#1] PREEMPT SMP 
last sysfs file: /sys/kernel/uevent_seqnum
CPU 1 
Pid: 3252, comm: dmsetup Not tainted 2.6.33-rc5-9-default #3 /
RIP: 0010:[<ffffffffa00e6ad7>]  [<ffffffffa00e6ad7>] stripe_ctr+0xd5/0x28d [dm_mod]
RSP: 0018:ffff88003cb7dce8  EFLAGS: 00010246
RAX: 0000000000000400 RBX: 0000000000000200 RCX: 0000000000000000
RDX: 0000000000000000 RSI: ffff88003cb7dd08 RDI: ffffc900008fb165
RBP: ffff88003cb7dd38 R08: 0000000000000200 R09: 000000000000000a
R10: ffffffffa00ec630 R11: ffffffffa00ec638 R12: 0000000000000004
R13: 0000000000000200 R14: ffffc900008f0040 R15: 0000000000000000
FS:  00007f9551621780(0000) GS:ffff880003600000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f95514f7000 CR3: 00000000343c9000 CR4: 00000000000006e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
Process dmsetup (pid: 3252, threadinfo ffff88003cb7c000, task ffff880034004f40)
Stack:
 ffff88003cb7dd38 ffff88003d8d0400 ffff88003cb7dd60 ffffc900008f0040
<0> ffffc900008fb165 0000000000000400 ffffc900008f0040 0000000000000000
<0> ffff88003d8d0200 ffffc900008fb150 ffff88003cb7dd98 ffffffffa00e5dec
Call Trace:
 [<ffffffffa00e5dec>] dm_table_add_target+0x152/0x1cf [dm_mod]
 [<ffffffffa00e7cca>] table_load+0x257/0x266 [dm_mod]
 [<ffffffffa00e7a73>] ? table_load+0x0/0x266 [dm_mod]
 [<ffffffffa00e89c6>] ctl_ioctl+0x1ce/0x226 [dm_mod]
 [<ffffffff8106a218>] ? sched_clock_cpu+0xe3/0xeb
 [<ffffffffa00e8a2c>] dm_ctl_ioctl+0xe/0x12 [dm_mod]
 [<ffffffff81117c08>] vfs_ioctl+0x2a/0x9e
 [<ffffffff811181bd>] do_vfs_ioctl+0x4b7/0x4f4
 [<ffffffff81306b3a>] ? _raw_spin_unlock_irqrestore+0x76/0x92
 [<ffffffff811bbe57>] ? __up_write+0x12d/0x13c
 [<ffffffff81306f39>] ? retint_swapgs+0x13/0x1b
 [<ffffffff8111824f>] sys_ioctl+0x55/0x77
 [<ffffffff81002d82>] system_call_fastpath+0x16/0x1b
Code: 07 77 0a 49 c7 46 38 14 b2 0e a0 eb 9f 49 8b 56 18 8d 43 ff 48 85 d0 74 0a 49 c7 46 38 27 b2 0e a0 eb 89 48 89 d0 44 89 f9 31 d2 <48> f7 f1 44 89 7d c4 48 85 d2 48 
89 45 b0 74 0d 49 c7 46 38 51 
RIP  [<ffffffffa00e6ad7>] stripe_ctr+0xd5/0x28d [dm_mod]
 RSP <ffff88003cb7dce8>
---[ end trace fa87918cd9541274 ]---

This patch returns -EINVAL, if zero is passed as stripe count.
 
With this patch we get the following error message.
device-mapper: table: 253:0: striped: Invalid stripe count
device-mapper: ioctl: error adding target to table

And dmsetup exits gracefully with following error message.
device-mapper: reload ioctl failed: Invalid argument
Command failed

Signed-off-by: Nikanth Karthikesan <knikanth@xxxxxxx>

---

diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
index e0efc1a..bd58703 100644
--- a/drivers/md/dm-stripe.c
+++ b/drivers/md/dm-stripe.c
@@ -110,7 +110,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
 	}
 
 	stripes = simple_strtoul(argv[0], &end, 10);
-	if (*end) {
+	if (!stripes || *end) {
 		ti->error = "Invalid stripe count";
 		return -EINVAL;
 	}

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel

[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux