From nobody Sat Feb 7 09:29:33 2026 Received: from cstnet.cn (smtp21.cstnet.cn [159.226.251.21]) (using TLSv1.2 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1F5A327732 for ; Wed, 31 Dec 2025 03:33:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.226.251.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767152017; cv=none; b=j6IET3/USQTCMcj6v+NnQ/vi9/tIf+UAJ4Gr0Qy3WgX2TW6vzFLbFn/NfxL0lyKbS57u5Y275hXVv/fv5HRfaQFXJDbnFpfycbw19orcUXLDJ4lr+I5sdA2utm3D5NUmlpDVL8bdfOCmulXIjYrywuD0Ur6H6jtfOO42Qkur5Ag= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767152017; c=relaxed/simple; bh=kY+YCj+9CwSUTh2PKfDWKP4WPxfO6p9nypjN382PxBk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=EdZz5NSo/QPSzwcJXYek1iobOVXe664hkUT9csglxZVbkCBTQj14gqkvbmoTq1JLNCciWULmnXR7dMxdVActXIGAdtjETN/sk/4+9AzX13TlWpIO/VIImTUL+SYh3ldIbk82fl8eqHm8cmGacMJz8n6qOQ0+zML26TfprO87tH4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn; spf=pass smtp.mailfrom=iscas.ac.cn; arc=none smtp.client-ip=159.226.251.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=iscas.ac.cn Received: from DESKTOP-L0HPE2S.localdomain (unknown [124.16.141.245]) by APP-01 (Coremail) with SMTP id qwCowACnTGh6mVRpjwB6Ag--.18768S2; Wed, 31 Dec 2025 11:33:15 +0800 (CST) From: Haotian Zhang To: shaggy@kernel.org Cc: aha310510@gmail.com, jfs-discussion@lists.sourceforge.net, linux-kernel@vger.kernel.org, syzbot+015483fc71d1413f40ee@syzkaller.appspotmail.com, syzkaller-bugs@googlegroups.com, Haotian Zhang Subject: [PATCH] jfs: fix array-index-out-of-bounds in diAllocBit() Date: Wed, 31 Dec 2025 11:31:26 +0800 Message-ID: <20251231033126.64087-1-vulab@iscas.ac.cn> X-Mailer: git-send-email 2.43.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 X-CM-TRANSID: qwCowACnTGh6mVRpjwB6Ag--.18768S2 X-Coremail-Antispam: 1UD129KBjvJXoWrKw18WFyfuw4fKrWfAFykAFb_yoW8JrWUp3 92kF47K39Yq3yrAFn7tF1UXayYk3s5trW8JryFqrW0yw18Kr17C3W0qF93WF1DGr4Fq34Y 9F4UKFn5uF4UZ3DanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkG14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26ryj6F1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4j 6F4UM28EF7xvwVC2z280aVAFwI0_Cr1j6rxdM28EF7xvwVC2z280aVCY1x0267AKxVW0oV Cq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0 I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r 4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY1x0262kKe7AKxVWU AVWUtwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14 v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkG c2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI 0_Jr0_Gr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4U MIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUBVbkUUU UU= X-CM-SenderInfo: pyxotu46lvutnvoduhdfq/1tbiDAYNA2lUhg9A2QAAsp Content-Type: text/plain; charset="utf-8" syzbot reported an array-index-out-of-bounds access in diAllocBit(), where im_agctl[] is indexed by agno derived from on-disk agstart without validation. agno is computed via BLKTOAG() and may become negative or exceed MAXAG when the filesystem metadata is corrupted, leading to an out-of-bounds access to imap->im_agctl[]. Validate agno before using it and abort the operation if the value is invalid. Reported-by: syzbot+015483fc71d1413f40ee@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3D015483fc71d1413f40ee Signed-off-by: Haotian Zhang --- fs/jfs/jfs_imap.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c index ecb8e05b8b84..cc72fcaa94e2 100644 --- a/fs/jfs/jfs_imap.c +++ b/fs/jfs/jfs_imap.c @@ -2044,6 +2044,14 @@ static int diAllocBit(struct inomap * imap, struct i= ag * iagp, int ino) * the extent. */ agno =3D BLKTOAG(le64_to_cpu(iagp->agstart), JFS_SBI(imap->im_ipimap->i_s= b)); + if (agno >=3D MAXAG || agno < 0) { + if (amp) + release_metapage(amp); + if (bmp) + release_metapage(bmp); + return -EIO; + } + extno =3D ino >> L2INOSPEREXT; bitno =3D ino & (INOSPEREXT - 1); =20 --=20 2.43.0