[PATCH 2/5] block: partitions: aix: avoid 32-bit wrap in the LV start sector
From: shao.mingyin
Date: Thu Dec 03 2026 - 09:17:11 EST
From: Shao Mingyin <shao.mingyin@xxxxxxxxxx>
aix_partition() computes the start sector of an LV as
(i + 1 - lp_ix) * pp_blocks_size + psn_part1
where the first term is an unsigned int and psn_part1 is an int read
from the pvd. The sum is evaluated in 32-bit arithmetic, so it wraps
when the offset of the LV's first physical partition plus psn_part1
exceeds 2^32 sectors (2 TiB with 512-byte logical blocks). The LV is
then created at a small, in-range start sector instead of being
ignored.
Keep psn_part1 in u32 and compute the start and the size in sector_t so
that the existing capacity check sees the real values.
Fixes: 6ceea22bbbc8 ("partitions: add aix lvm partition support files")
Cc: stable@xxxxxxxxxx
Signed-off-by: Shao Mingyin <shao.mingyin@xxxxxxxxxx>
---
Tested on 7.4.0-rc5-next-20261130 (QEMU/TCG guest) with a 1 MiB
loop-backed disk carrying an AIX LVM image whose first LV uses a
2^31-byte (2^22-sector) physical partition and whose psn_part1 is
37748836. The computed start is 2^32 + 100 sectors, which 32-bit
arithmetic truncates to 100:
unpatched patched
loop0p1 start 100, size 1948 no loop0p1
block/partitions/aix.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/block/partitions/aix.c b/block/partitions/aix.c
index b01b2c62162d..cb74720a8164 100644
--- a/block/partitions/aix.c
+++ b/block/partitions/aix.c
@@ -231,7 +231,7 @@ int aix_partition(struct parsed_partitions *state)
}
if (pvd) {
int numpps = be16_to_cpu(pvd->pp_count);
- int psn_part1 = be32_to_cpu(pvd->psn_part1);
+ u32 psn_part1 = be32_to_cpu(pvd->psn_part1);
int i;
int cur_lv_ix = -1;
int next_lp_ix = 1;
@@ -270,8 +270,10 @@ int aix_partition(struct parsed_partitions *state)
}
if (lp_ix == lvip[lv_ix].pps_per_lv) {
put_partition(state, lv_ix + 1,
- (i + 1 - lp_ix) * pp_blocks_size + psn_part1,
- lvip[lv_ix].pps_per_lv * pp_blocks_size);
+ (sector_t)(i + 1 - lp_ix) * pp_blocks_size +
+ psn_part1,
+ (sector_t)lvip[lv_ix].pps_per_lv *
+ pp_blocks_size);
seq_buf_printf(&state->pp_buf, " <%s>\n",
n[lv_ix].name);
lvip[lv_ix].lv_is_contiguous = 1;
--
2.34.1