Skip to content

Commit d35e236

Browse files
mjbommaraxboe
authored andcommitted
partitions: aix: bound the lvd scan to one sector
aix_partition() reads the logical-volume descriptor array as a single sector and then scans it: if (numlvs && (d = read_part_sector(state, vgda_sector + 1, &sect))) { struct lvd *p = (struct lvd *)d; ... for (i = 0; foundlvs < numlvs && i < state->limit; i++) { lvip[i].pps_per_lv = be16_to_cpu(p[i].num_lps); p points at a single 512-byte sector, which holds SECTOR_SIZE / sizeof(struct lvd) = 16 entries, but the loop runs until foundlvs reaches the on-disk numlvs or i reaches state->limit (DISK_MAX_PARTS, 256). numlvs is an on-disk __be16 read straight from the volume group descriptor and is not validated, so a crafted AIX image with numlvs larger than 16 and lvd entries whose num_lps fields are zero (so foundlvs never advances) drives the loop to read p[i] well past the end of the read sector buffer. Commit d97a86c ("partitions: aix.c: off by one bug") hardened the matching write of lvip[lv_ix] in 2014 but left this read loop unbounded. Bound the scan to the number of struct lvd entries that fit in the sector that was actually read. Fixes: 6ceea22 ("partitions: add aix lvm partition support files") Assisted-by: Claude:claude-opus-4-8 Signed-off-by: Michael Bommarito <michael.bommarito@gmail.com> Link: https://patch.msgid.link/20260714114806.3761553-1-michael.bommarito@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent dbbca20 commit d35e236

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

block/partitions/aix.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,14 @@ int aix_partition(struct parsed_partitions *state)
208208
if (n) {
209209
int foundlvs = 0;
210210

211-
for (i = 0; foundlvs < numlvs && i < state->limit; i += 1) {
211+
/*
212+
* The lvd array was read as a single sector; only the
213+
* struct lvd entries that fit in it are valid. Bound the
214+
* scan so an on-disk numlvs larger than that cannot walk
215+
* the read buffer out of bounds.
216+
*/
217+
for (i = 0; foundlvs < numlvs && i < state->limit &&
218+
i < SECTOR_SIZE / (int)sizeof(struct lvd); i++) {
212219
lvip[i].pps_per_lv = be16_to_cpu(p[i].num_lps);
213220
if (lvip[i].pps_per_lv)
214221
foundlvs += 1;

0 commit comments

Comments
 (0)