Skip to content

Commit ccf1641

Browse files
khazhykaxboe
authored andcommitted
block/compat_ioctl: fix range check in BLKGETSIZE
kernel ulong and compat_ulong_t may not be same width. Use type directly to eliminate mismatches. This would result in truncation rather than EFBIG for 32bit mode for large disks. Reviewed-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Khazhismel Kumykov <khazhy@google.com> Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com> Link: https://lore.kernel.org/r/20220414224056.2875681-1-khazhy@google.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 3e3876d commit ccf1641

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

block/ioctl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ long compat_blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg)
629629
return compat_put_long(argp,
630630
(bdev->bd_disk->bdi->ra_pages * PAGE_SIZE) / 512);
631631
case BLKGETSIZE:
632-
if (bdev_nr_sectors(bdev) > ~0UL)
632+
if (bdev_nr_sectors(bdev) > ~(compat_ulong_t)0)
633633
return -EFBIG;
634634
return compat_put_ulong(argp, bdev_nr_sectors(bdev));
635635

0 commit comments

Comments
 (0)