]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 21 Feb 2025 12:50:05 +0000 (13:50 +0100)
commit27a39d006f85e869be68c1d5d2ce05e5d6445bf5
treea9f120b50bd04c695e4c8a56af21ecff16a32363
parent1819802e2931f977e5f18b3ecd3b34b3065a7826
partitions: mac: fix handling of bogus partition table

commit 80e648042e512d5a767da251d44132553fe04ae0 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
block/partitions/mac.c