]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
block: fix an integer overflow in logical block size
authorMikulas Patocka <mpatocka@redhat.com>
Wed, 15 Jan 2020 13:35:25 +0000 (08:35 -0500)
committerBen Hutchings <ben@decadent.org.uk>
Tue, 28 Apr 2020 18:03:28 +0000 (19:03 +0100)
commitf042797e7c9dd3d3bef34ad547c4516e3a191741
tree5f078737f016678f12fe860a054f4aec15b9deb1
parentcd854f82f9613aed317c92844bbfb70060d6491d
block: fix an integer overflow in logical block size

commit ad6bf88a6c19a39fb3b0045d78ea880325dfcf15 upstream.

Logical block size has type unsigned short. That means that it can be at
most 32768. However, there are architectures that can run with 64k pages
(for example arm64) and on these architectures, it may be possible to
create block devices with 64k block size.

For exmaple (run this on an architecture with 64k pages):

Mount will fail with this error because it tries to read the superblock using 2-sector
access:
  device-mapper: writecache: I/O is not aligned, sector 2, size 1024, block size 65536
  EXT4-fs (dm-0): unable to read superblock

This patch changes the logical block size from unsigned short to unsigned
int to avoid the overflow.

Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
[bwh: Backported to 3.16: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
block/blk-settings.c
drivers/md/dm-snap-persistent.c
drivers/md/raid0.c
include/linux/blkdev.h