]> www.infradead.org Git - nvme.git/commit
partitions: mac: fix handling of bogus partition table
authorJann Horn <jannh@google.com>
Fri, 14 Feb 2025 01:39:50 +0000 (02:39 +0100)
committerJens Axboe <axboe@kernel.dk>
Fri, 14 Feb 2025 15:38:28 +0000 (08:38 -0700)
commit80e648042e512d5a767da251d44132553fe04ae0
tree4516f9009fa27b77f790cb09c7a44dd6a955ab9e
parent1f47ed294a2bd577d5ae43e6e28e1c9a3be4a833
partitions: mac: fix handling of bogus partition table

Fix several issues in partition probing:

 - The bailout for a bad partoffset must use put_dev_sector(), since the
   preceding read_part_sector() succeeded.
 - If the partition table claims a silly sector size like 0xfff bytes
   (which results in partition table entries straddling sector boundaries),
   bail out instead of accessing out-of-bounds memory.
 - We must not assume that the partition table contains proper NUL
   termination - use strnlen() and strncmp() instead of strlen() and
   strcmp().

Cc: stable@vger.kernel.org
Signed-off-by: Jann Horn <jannh@google.com>
Link: https://lore.kernel.org/r/20250214-partition-mac-v1-1-c1c626dffbd5@google.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/partitions/mac.c