]> 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>
Thu, 13 Mar 2025 11:50:41 +0000 (12:50 +0100)
commit40a35d14f3c0dc72b689061ec72fc9b193f37d1f
treea544e8d2b2111a8f566740f65ecf30274ac0492b
parent4647cb4e001341aa0ed8b1e371ca2f95a904b018
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