From: Luxiao Xu sysv68_partition() reads the on-disk slice count from dkconfig without validation. It then reads a single 512-byte sector to hold the slice table records. Since each struct slice is 8 bytes, a single sector can hold at most SECTOR_SIZE / sizeof(struct slice) = 64 slice records. The parser decrements slices by one (as the last slice represents the whole disk) and then iterates slices entries. A crafted disk image with an out-of-bounds slice count (such as 66) causes the loop to walk past the end of the 512-byte sector buffer, leading to an out-of-bounds read and triggering KASAN warnings when the sector is near the end of a mapped page/folio. Validate that slices is at least 1 and does not exceed the number of struct slice records that fit in a single sector, releasing the sector and returning 0 if the check fails. Fixes: 19d0e8ce856a ("partition: add support for sysv68 partitions") Cc: stable@vger.kernel.org Reported-by: VEGA Assisted-by: LLM Signed-off-by: Luxiao Xu Signed-off-by: Ren Wei --- block/partitions/sysv68.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/block/partitions/sysv68.c b/block/partitions/sysv68.c index 470e0f9de7be..0edf2ff80c5e 100644 --- a/block/partitions/sysv68.c +++ b/block/partitions/sysv68.c @@ -72,6 +72,10 @@ int sysv68_partition(struct parsed_partitions *state) if (!data) return -1; + if (slices < 1 || slices > (int)(SECTOR_SIZE / sizeof(struct slice))) { + put_dev_sector(sect); + return 0; + } slices -= 1; /* last slice is the whole disk */ seq_buf_printf(&state->pp_buf, "sysV68: %s(s%u)", state->name, slices); slice = (struct slice *)data; -- 2.43.0