From nobody Sun Feb 8 11:45:10 2026 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (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 3C5183876A9 for ; Wed, 21 Jan 2026 20:32:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769027525; cv=none; b=ljyJNzckp0h6yY2tHukIPVFntlvWtZAjUeMjpTIkMaxodYldV0ThB74D8KpbXBjU9BdTR9aT1TyWH4H1ss0ms7MxeyDp3dtWoxNXlcvahtWJ2BKO11QrcJcokHP/uKlmLZ5FRk0LoI5RrFGmmGsBTtV12gYSReCU44T6KRzc9sk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769027525; c=relaxed/simple; bh=RinqpC18dD0vPmz3RDm21LSKo/+T6SO7WZrnRI9rOqE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Xyu8yeQEmTrXW81GDTi+2OeUCbNZxgCrHC2/WnPB2j6jJmKTJFbToU79uGCbgty0QseJM8krhEXFVGMNSbm9KaQPxpiyv9UmLuBEw8XtNDuszrhnqG3FNZnVK1LfAF2yM0nxXo5htwLQtbeyye6sSaGtYt2StwJ/KM5CCoBfExs= 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=DmtSkHCj; arc=none smtp.client-ip=209.85.210.175 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="DmtSkHCj" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-81f4ba336b4so274848b3a.1 for ; Wed, 21 Jan 2026 12:32:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769027523; x=1769632323; 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=jFa/fNjvdIQh3CVIwiGWrGESLBSoMJOat8/avU4HWX4=; b=DmtSkHCjhjmhqluQzbk7+5GHHdoa7Hm8OHh1AoyMJzVme9HTePSHoOKmGu+MPba1ei y453TbzcQxblT/2lROyB9BsS3mLDOFPZaqChF0+HjDWGsz+vsP/hlkdGks6IH3Uxo2Uk c0DIBdmaCrAnIS/YbXAOCm09dBXZOh2yB5B7dok2kN7BMrjeQ+0fPk5zJAqgB2wPt574 E3WtXWVHLD+4Ilw3YRFFD8MhUYh3q18pn1u4WB4y9j/OUl8AiKehedjyl1Y+z+QIoJtG ah7xwpANcopifBU518SZzr5A1YvosSlVHZ0JkxQp1K5BJUYLzSDEaJyEuAGu6ObmFyTq 3F3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769027523; x=1769632323; 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=jFa/fNjvdIQh3CVIwiGWrGESLBSoMJOat8/avU4HWX4=; b=K9CAJLl/Xlk0oQ13GA+D4v6VaXj2gyD6PcLGe1+sOmT4ZdXRJd/nQn3e0DI1NSdHTR /2XQYX12+b4dvz2PU1LMzB7qOuW/pg94/L0/zecVSVRkXFsgqKbM4BeNr1U2jVsVx3k5 RLmv8S1j3vhm5Zn7Jahp5up5aORwnXokgt/OmxE/m0Of8O6vtUshGg3rJptkn0OriEa4 WFigFADPY1NN3JsQqkNAzzW8dlk4e22O2uV7boV9KYDYu3m/6qm/LMetZHtjr/utsPvu 0Hq8shdwS5gR0SEjjb5xO+FjHGR8Z52GguQv+9HiftSb4uKK+E9+aBuJhI0VrupDhsRd +hFg== X-Forwarded-Encrypted: i=1; AJvYcCVcHghjz/SMk2VA0kC0f998+R39Q7lNoaQF6V4+cFzU0jLK/u0T0vjFk/hucAN9pVCYqh4UVdAn57RFRhE=@vger.kernel.org X-Gm-Message-State: AOJu0YwZG3ZsncSyJBxXQFZ85LyE6qZzv1P3RWUUkTVTbeXq2j7yeEUc 7TwH2Xqo/bdaEGF84sTR5IWiKAdCsjWzxjHbdaUCc/iaZqZnmyAq+FbxcOE/nzLRqUXItLo= X-Gm-Gg: AZuq6aKdchlm61bMcU6r+6D5fj7LJ1Qpiw/krUYz/DsP+BM17R/duge2R6YiyRfbWHT OA8q05dApOO6Vc7smDMuXdjsNgbuz4X8v+zQBrL+6u0ej7Y9LNA8rEnyWuVzSMqQmd8G5McjGhq 6bMSuSmik87bnEPIW8Mk5B0eQSmeo2avrmg5B89JxMz30m8Djj+ahmYJPNtPOx5UqZAHzQW3H5f QcZAi8CPRyVFsQ1+pmnOoj6RojHK4QCDHCeiHBnnku8N3vflkiF2Ly1qZzzWI94FxJquJIRRrgr oZTc1GpkJLXGkc1uIJscRzkKP1RV+E1TG8ZpuIeg6Q0ysin4iY8rylDzDtvUf3DBE5MRyxhtVlg 0u1CmS0tieaagrvk1qW8d/r4JzKNh7kcBUkfCYq2me4HzOVcPrKJQXJm+HH05/8LMHqWX/9w6PF MqzjfSj9iVyY2YCXCcmzctOU8cvg== X-Received: by 2002:a05:6a00:ac3:b0:81e:f623:b9fe with SMTP id d2e1a72fcca58-81f9f7f61dcmr17548926b3a.4.1769027523419; Wed, 21 Jan 2026 12:32:03 -0800 (PST) Received: from DESKTOP-BKIPFGN ([38.76.140.13]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-81fa129629asm10027765b3a.52.2026.01.21.12.32.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Jan 2026 12:32:03 -0800 (PST) From: Kery Qi To: shaggy@kernel.org Cc: r.smirnov@omp.ru, zheng.yu@northwestern.edu, duttaditya18@gmail.com, jfs-discussion@lists.sourceforge.net, linux-kernel@vger.kernel.org, Kery Qi Subject: [PATCH] jfs: fix array-index-out-of-bounds in dtExtendPage Date: Thu, 22 Jan 2026 04:31:21 +0800 Message-ID: <20260121203121.1867-2-qikeyu2017@gmail.com> X-Mailer: git-send-email 2.50.1.windows.1 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" Similar to the issue fixed in commit 27e56f59bab5 ("UBSAN: array-index-out-of-bounds in dtSplitRoot"), the loop that traverses the freelist in dtExtendPage() uses the condition (fsi !=3D -1) to terminate. However, if the filesystem image is corrupted or maliciously crafted, f->next could contain a value less than -1 (e.g., -2), causing the loop to continue and resulting in an out-of-bounds array access when indexing sp->slot[fsi]. Fix this by changing the loop termination condition from (fsi !=3D -1) to (fsi >=3D 0), so that any negative value will properly terminate the loop. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Kery Qi --- fs/jfs/jfs_dtree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/jfs/jfs_dtree.c b/fs/jfs/jfs_dtree.c index 0ab83bb7bbdf..3e365ccfb33b 100644 --- a/fs/jfs/jfs_dtree.c +++ b/fs/jfs/jfs_dtree.c @@ -1804,7 +1804,7 @@ static int dtExtendPage(tid_t tid, do { f =3D &sp->slot[fsi]; fsi =3D f->next; - } while (fsi !=3D -1); + } while (fsi >=3D 0); =20 f->next =3D n; } --=20 2.34.1