Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2bd6efad authored by Alan Cox's avatar Alan Cox Committed by Jens Axboe
Browse files

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: default avatarAlan Cox <alan@linux.intel.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 97651ea6
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -41,7 +41,7 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user
			    sizeof(long long) > sizeof(long)) {
			    sizeof(long long) > sizeof(long)) {
				long pstart = start, plength = length;
				long pstart = start, plength = length;
				if (pstart != start || plength != length
				if (pstart != start || plength != length
				    || pstart < 0 || plength < 0)
				    || pstart < 0 || plength < 0 || partno > 65535)
					return -EINVAL;
					return -EINVAL;
			}
			}