blk: add an upper sanity check on partition adding

65536 should be ludicrous anyway but without it we overflow the
memory computation doing the allocation and badness occurs.

Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Alan Cox 2012-09-17 11:47:13 +01:00 committed by Jens Axboe
parent 97651ea687
commit 2bd6efad25

View file

@ -41,7 +41,7 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user
sizeof(long long) > sizeof(long)) {
long pstart = start, plength = length;
if (pstart != start || plength != length
|| pstart < 0 || plength < 0)
|| pstart < 0 || plength < 0 || partno > 65535)
return -EINVAL;
}