diff options
author | Akinobu Mita <akinobu.mita@gmail.com> | 2014-05-25 21:43:33 +0900 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2014-07-01 10:43:07 -0600 |
commit | 63f264965947ac6299452711f614f086955b2515 (patch) | |
tree | 20050c8d77eb14fbb1439eb9af85916bf87f7dd2 /block/ioctl.c | |
parent | 16e1556526241b893d40b01d1c1b14a4e83ee499 (diff) | |
download | linux-63f264965947ac6299452711f614f086955b2515.tar.gz linux-63f264965947ac6299452711f614f086955b2515.tar.bz2 linux-63f264965947ac6299452711f614f086955b2515.zip |
block: fix BLKSECTGET ioctl when max_sectors is greater than USHRT_MAX
BLKSECTGET ioctl loads the request queue's max_sectors as unsigned
short value to the argument pointer. So if the max_sector is greater
than USHRT_MAX, the upper 16 bits of that is just discarded.
In such case, USHRT_MAX is more preferable than the lower 16 bits of
max_sectors.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: "James E.J. Bottomley" <JBottomley@parallels.com>
Cc: Douglas Gilbert <dgilbert@interlog.com>
Cc: linux-scsi@vger.kernel.org
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'block/ioctl.c')
-rw-r--r-- | block/ioctl.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/block/ioctl.c b/block/ioctl.c index 7d5c3b20af45..d6cda8147c91 100644 --- a/block/ioctl.c +++ b/block/ioctl.c @@ -278,6 +278,7 @@ int blkdev_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd, struct backing_dev_info *bdi; loff_t size; int ret, n; + unsigned int max_sectors; switch(cmd) { case BLKFLSBUF: @@ -375,7 +376,9 @@ int blkdev_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd, case BLKDISCARDZEROES: return put_uint(arg, bdev_discard_zeroes_data(bdev)); case BLKSECTGET: - return put_ushort(arg, queue_max_sectors(bdev_get_queue(bdev))); + max_sectors = min_t(unsigned int, USHRT_MAX, + queue_max_sectors(bdev_get_queue(bdev))); + return put_ushort(arg, max_sectors); case BLKROTATIONAL: return put_ushort(arg, !blk_queue_nonrot(bdev_get_queue(bdev))); case BLKRASET: |