From nobody Mon Jun 8 05:25:23 2026 Received: from mail-qt1-f177.google.com (mail-qt1-f177.google.com [209.85.160.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3B97723505E for ; Sat, 6 Jun 2026 17:07:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780765648; cv=none; b=rkrguDcjBwS/mR5kJuCKDm9NmRaREtStLObCJfyNs+fEL77fry1kSf/pLrkQ8JgZVABSixnIonvLIyQ40oB9P2ysUeAP4kBU/pINtK61uhVYFIrPnqTVK+N/8mHzl1MTvUndPOleTyfKE8nSLflhDKISIwz7H9znx4/fOCxLWis= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780765648; c=relaxed/simple; bh=R0YMzvYxYQr3sOqAegDmCBFMN7Q/gO2TST48W2S5s4M=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=jO3p9Db/cgBju5iZkVQwtRuPvg/z+pGVizGGsg+JOXFfEmprEov8uW/5IxQO5SM6gHaZt839yxJiZSRdf0V66S7GMW3VAujNYQUQEdtjr1LF73dl3obnwzW9ZW9MwQsS9Wu8q0jt+9NxdIRNl8hqvZQN9g7vK5OzuZzdUATyhHw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=WPAQVUAE; arc=none smtp.client-ip=209.85.160.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WPAQVUAE" Received: by mail-qt1-f177.google.com with SMTP id d75a77b69052e-5177b1a7441so43593561cf.3 for ; Sat, 06 Jun 2026 10:07:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780765646; x=1781370446; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=o80LmnK0uzkX+1KFSI8PVtao/YEOY0eT+m27hFPkzZk=; b=WPAQVUAEhoXFRDw+oiwX+Ltr/x+oT4gtZEeleU77TcDCthaB97T7lQxpPxZn+FL1JO r5GAa2WHgha5zoXwzJ4plMeX+qfQ2kDLSMqAiVZMrnWNvGqAkncbcaYitIYJsi6FHXow +pReRCYX0tP9nRDIP/nY7b3Qpk84PoC5BiiRnTtmChXOMK0yoEV8Xfz8IKYt+v+X2QnE pwpJLsRy9u8uYnkBBSUBnwRpy97+dHkrPCZksh1bk37jy9Hbx0kRfIcmJ+3mSbPDtwkF ARsFiz85oVSycw0F5x2V6dGO5pXMWt0s5bmj2kRbhWyqZ71h9J3BazJKyGPZHr2fEUxg TF3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780765646; x=1781370446; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=o80LmnK0uzkX+1KFSI8PVtao/YEOY0eT+m27hFPkzZk=; b=PbsPSdfu5NuA8UoQv3oEkntaIm0edFNLlFHKHGHuQfoUBDkEBvjLh5X5gBJMlzIMOh c3m9XfHHHY7F90Ufg3n/2tiri5tRmZR50X2NjxZxtOtPFhWxo9jJ5/Br9kwjyG/GbOR+ BhnuMScdTdagLOPPoGCYuLldlgwY8GdU7Cv72xOf6Qzlk+Tib5q9yc+zrQot72T2bsyD pJKlSxN+gQ1/L3I3eMH4J46yVtxUX6wnqhs9kAuKVlFHzN8GYfrLwY1s+jPpKH8GZm8O +TyuIJne1wEFD5khg3+9a9XfAeaF4Ye/E/vzhpYxD7qAlefSiqCuJ3oszPEIanbx38tR 727A== X-Forwarded-Encrypted: i=1; AFNElJ/KMUNGo2V4iIDzAn9gTQr4Rr3pInzgdiMpzeL/xpGR5j4UVJsVD0EHQ2jNKTX2Frfq1MDcJSPJvpggPqg=@vger.kernel.org X-Gm-Message-State: AOJu0Yw5oGngEq+ibYMoW5P2Mectd/adocmMxcpDM15Nh+L2IIFbtf+1 2VVBw+0XcDlEoBNRINXYy79cUiZGWnKhbFovKcbFC1JXUq3+cE3hI+Dy X-Gm-Gg: Acq92OHu7d9VTjidVnveyOKlKWViw9KRAJKv2DB7QFidVT0fvQGEgNNLuUTAQ7zdBqd CZAOWIETnI86W/xXcZez4R1IZz30XiHnDtzWTlndmgJPJp9HR2FCJNTVEQspv84Xvgp8bmnUvQg UCxI7PQ67uBgKPBVIpKIEMOqHO6uw0DNJsHs9fEdIPdpbzwI7/qxBp1DK+rRi8PtkeciKDnNERU jdSFGvrV7MCeCFcf3zgauR7jfRPoGaRNlrCzRJLow0zyjoFF4vcPvIZqfSMuT6X1pL0rz72O93b JRVMAXeZp833VJfDI1NcR9g1MSBFWf9Z4u/DS6FaXVvNyOWktqkEwNvgR3glmC6SqRH1CoDUsqh QFLV8lZO5hrp8ozX0yThuYn5pLeMo0n+hihO+prnqdPKACAbM8MwoPwkc33Mmd7jdKMxKjni7p7 YG/AuPFCkVkqFo7QRWUMrSPwPR4jjp/41jFj7c4UeJdZ6b2TnuSuuT/Whor5V+fjpkpjfLN68c9 xrL7arBClu8XCPSb1zpPxjO54f1yQg= X-Received: by 2002:a05:622a:1808:b0:517:96f0:5658 with SMTP id d75a77b69052e-51796f06eadmr119777501cf.14.1780765646160; Sat, 06 Jun 2026 10:07:26 -0700 (PDT) Received: from server0 (c-68-48-65-54.hsd1.mi.comcast.net. [68.48.65.54]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8cecd0556c0sm112907536d6.25.2026.06.06.10.07.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Jun 2026 10:07:25 -0700 (PDT) From: Michael Bommarito To: Jens Axboe Cc: Kees Cook , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] partitions: aix: bound the lvd scan to one sector Date: Sat, 6 Jun 2026 13:07:21 -0400 Message-ID: <20260606170721.1530005-1-michael.bommarito@gmail.com> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" aix_partition() reads the logical-volume descriptor array as a single sector and then scans it: if (numlvs && (d =3D read_part_sector(state, vgda_sector + 1, §))) { struct lvd *p =3D (struct lvd *)d; ... for (i =3D 0; foundlvs < numlvs && i < state->limit; i +=3D 1) { lvip[i].pps_per_lv =3D be16_to_cpu(p[i].num_lps); p points at a single 512-byte sector, which holds 512 / sizeof(struct lvd) =3D 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. The 2014 off-by-one fix d97a86c170b4 hardened the matching write of lvip[lv_ix] 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: 6ceea22bbbc8 ("partitions: add aix lvm partition support files") Assisted-by: Claude:claude-opus-4-8 Signed-off-by: Michael Bommarito --- block/partitions/aix.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/block/partitions/aix.c b/block/partitions/aix.c index 29b8f4cebb63d..6679e825ba329 100644 --- a/block/partitions/aix.c +++ b/block/partitions/aix.c @@ -208,7 +208,14 @@ int aix_partition(struct parsed_partitions *state) if (n) { int foundlvs =3D 0; =20 - for (i =3D 0; foundlvs < numlvs && i < state->limit; i +=3D 1) { + /* + * The lvd array was read as a single sector; only the + * struct lvd entries that fit in it are valid. Bound the + * scan so an on-disk numlvs larger than that cannot walk + * the read buffer out of bounds. + */ + for (i =3D 0; foundlvs < numlvs && i < state->limit && + i < 512 / (int)sizeof(struct lvd); i +=3D 1) { lvip[i].pps_per_lv =3D be16_to_cpu(p[i].num_lps); if (lvip[i].pps_per_lv) foundlvs +=3D 1; base-commit: 5200f5f493f79f14bbdc349e402a40dfb32f23c8 --=20 2.53.0