From nobody Sat Jun 20 08:25:31 2026 Received: from mail-oo1-f70.google.com (mail-oo1-f70.google.com [209.85.161.70]) (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 AA69A35F607 for ; Fri, 17 Apr 2026 10:11:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.70 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776420717; cv=none; b=GTQ0LxjIwKpI8i03+/E/VfjvUpEgVC8U7ND/oapLjuGVNUOU6ZMtHqxauhA9xQphOLLhu3vGMHPBFeBt5lVGQ7O1GltcTKEjt6Lq8pC3+mewrbcjzI2/80nMum3z6uPWZEczv4upHPL3CszrZWaUjk+ZuAMgzzDiq1dMfx/PFko= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776420717; c=relaxed/simple; bh=OzkeFeO8YVS3re2LCA0Kjs2PdmI9cBeyc761uqvr1Vo=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=ZzDn13SqRot1Pddspq6mqmYLZ1nV8iQCy0rpSG/PYnpGpD1ucbpILW+45pfu9mjIh6gUSiKRwjkQA4glHNp0JG8vPqAsBzhOY9AUT6RNJc1nN4ayMiVD6IJpW3U2IIUbmakyzeyphzjKk9b8HdGDWS8IpLXRWl66FsoO4GPKSt0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com; arc=none smtp.client-ip=209.85.161.70 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com Received: by mail-oo1-f70.google.com with SMTP id 006d021491bc7-66b612efb4aso882271eaf.0 for ; Fri, 17 Apr 2026 03:11:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776420715; x=1777025515; h=to:from:subject:message-id:in-reply-to:date:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=kk48p8jZHEee+WciV824R/9RNCt+ZtGsWTrStyYkX5w=; b=brHgYF/GwRJv0PNpi5r99c1D+gqIVcwzQEiexpFMdNn28ZXg8Br2UQgpgnJVBbtUaf LhD3geDzmLLKx6ZJ1M3cRPd5h7Az3utDrDa2/wtTmuuX+PuTsvHunD7xsOtf3Dc64tm8 1vJyHu5rkJfOjNYFB6MHRWzh4zoM8qQcijzVPcJw1U1wTIvJIaqhUg97k+XkfMqXUFQn +eD7VQewPwMUxE4BTkSXu9UatbD3B+TxcFYmgLlNGW5UMb+qJ3Wtj70uM1Cn3jLaM0++ c72skY/q0NNJGU67Efnnd1BUeWYAWO1vCgVQmYObVgRZMlVE7tkcMNMYBe6xVBaUdjlC ZPHA== X-Gm-Message-State: AOJu0YwGcQ0fR8EsI4+1MUH0j3dXafjO2CQX2cebg5Rl+zTHNSPSE75M dNkV/D28h/2EpvsiYhb3rVIS9x+nSbuo2rpjyiMavbcpmYYEfxB5jWs4pMjlwtlUnNYnx8GyHMC qOHEbixTRrVvcsNjjz2KnBfAQVo1TiDpDcyK99HRti+2mPdwA7vmClgQnV+M= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Received: by 2002:a4a:b30b:0:b0:693:7a6f:b311 with SMTP id 006d021491bc7-694637d78e7mr624974eaf.22.1776420715644; Fri, 17 Apr 2026 03:11:55 -0700 (PDT) Date: Fri, 17 Apr 2026 03:11:55 -0700 In-Reply-To: <695faa63.050a0220.1c677c.039a.GAE@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <69e2076b.050a0220.1de265.000d.GAE@google.com> Subject: Forwarded: [PATCH] jfs: fix off-by-one in dbFindLeaf tree bounds check From: syzbot To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" For archival purposes, forwarding an incoming command email to linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com. *** Subject: [PATCH] jfs: fix off-by-one in dbFindLeaf tree bounds check Author: tristmd@gmail.com From: Tristan Madani #syz test: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.g= it master The bounds check in dbFindLeaf() uses a strict greater-than comparison (x + n > max_size) to guard access to the dmt_stree[] array. However, max_size is set to the array size itself (TREESIZE or CTLTREESIZE), so valid indices are 0 through max_size-1. When x + n equals max_size, the check passes but the subsequent array access tp->dmt_stree[x + n] reads one element past the end of the array. This is reached when a corrupted filesystem image has an invalid dmt_height value that causes the tree walk loop to descend beyond the actual tree depth, pushing the starting index ti to exactly max_size. For the dmapctl case (CTLTREESIZE =3D 1365), a height of 6 instead of the valid maximum of 5 produces: ti =3D 1 -> 5 -> 21 -> 85 -> 341 -> 1365, and the access at stree[1365] is one past the s8[1365] array. UBSAN reports: UBSAN: array-index-out-of-bounds in fs/jfs/jfs_dmap.c:2976:16 index 1365 is out of range for type 's8[1365]' (aka 'signed char[1365]') Fix the off-by-one by changing '>' to '>=3D' so that the boundary index is correctly treated as out-of-bounds. Reported-by: syzbot+1afe7ef2d0062e19eeb3@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3D1afe7ef2d0062e19eeb3 Fixes: 22cad8bc1d36 ("jfs: fix array-index-out-of-bounds in dbFindLeaf") Cc: stable@vger.kernel.org Signed-off-by: Tristan Madani --- fs/jfs/jfs_dmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c index XXXXXXX..XXXXXXX 100644 --- a/fs/jfs/jfs_dmap.c +++ b/fs/jfs/jfs_dmap.c @@ -3058,7 +3058,7 @@ static int dbFindLeaf(dmtree_t *tp, int l2nb, int *le= afidx, bool is_ctl) /* sufficient free space found. move to the next * level (or quit if this is the last level). */ - if (x + n > max_size) + if (x + n >=3D max_size) return -ENOSPC; if (l2nb <=3D tp->dmt_stree[x + n]) break; -- 2.43.0