Skip to content

Commit fd94a77

Browse files
bryamzxzgregkh
authored andcommitted
partitions: aix: bound the pp_count scan to the ppe array
commit 2dc0bfd upstream. aix_partition() reads the physical volume descriptor into a fixed-size struct pvd and then scans its physical-partition-extent array: int numpps = be16_to_cpu(pvd->pp_count); ... for (i = 0; i < numpps; i += 1) { struct ppe *p = pvd->ppe + i; ... lp_ix = be16_to_cpu(p->lp_ix); pvd points at a single kmalloc()'d struct pvd whose ppe[] member holds a fixed ARRAY_SIZE(pvd->ppe) (1016) entries, but the loop runs up to the on-disk pp_count. pp_count is an unvalidated __be16 read straight from the descriptor, so a crafted AIX image with pp_count larger than 1016 drives the loop to read pvd->ppe[i] past the end of the allocation (up to 65535 entries, ~2 MB out of bounds). The partition scan runs without mounting anything, when a block device with a crafted AIX/IBM partition table appears (an attacker-supplied image attached with losetup -P, or a device auto-scanned by udev), via msdos_partition() -> aix_partition(). Clamp the scan to the number of entries the ppe[] array can hold. Fixes: 6ceea22 ("partitions: add aix lvm partition support files") Cc: stable@vger.kernel.org Signed-off-by: Bryam Vargas <hexlabsecurity@proton.me> Acked-by: Philippe De Muyter <phdm@macqel.be> Link: https://patch.msgid.link/20260607064137.302574-1-hexlabsecurity@proton.me Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 9c89415 commit fd94a77

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

block/partitions/aix.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,15 @@ int aix_partition(struct parsed_partitions *state)
228228
int next_lp_ix = 1;
229229
int lp_ix;
230230

231+
/*
232+
* pvd was read into a fixed-size struct pvd whose ppe[] array
233+
* holds ARRAY_SIZE(pvd->ppe) entries. pp_count is an
234+
* unvalidated on-disk __be16, so clamp the scan to the array
235+
* size to avoid walking past the allocation.
236+
*/
237+
if (numpps > ARRAY_SIZE(pvd->ppe))
238+
numpps = ARRAY_SIZE(pvd->ppe);
239+
231240
for (i = 0; i < numpps; i += 1) {
232241
struct ppe *p = pvd->ppe + i;
233242
unsigned int lv_ix;

0 commit comments

Comments
 (0)