From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oa1-f71.google.com (mail-oa1-f71.google.com [209.85.160.71]) (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 2ACCB3AE71D for ; Fri, 17 Apr 2026 10:12:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.71 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776420721; cv=none; b=CfdcOmCU34GKTabYcnvaJiMBAypPN4XoATqRnrG8ho9BeUz5vCxCjnEnFUVcCxZHhgEhwXCymzvPmgy2+xumIsobhm9xb4leEFCBJnQdtXM1VTVyHeS0maJvbHxqT3XTy6mF3gd+hK+T0tpeN6lpathgdEu7Kj6tKSS5ZwKD6L8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776420721; c=relaxed/simple; bh=+yqEFSVE1hrKi54+OFkAgU6+yIDev7+dOdAkqSgkJ5s=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=ryvWCYshwyDODyAYxpSIycr+LcCSglg8LY4MwxJMOexg8o3rvn9ynV7WPYXvhUtnv2NSq4db7bCF6PRP0fs2B9Xb/ta31lc1iVc1K46bKFzrl2rLFd8l6GG96Ql/L9jL4QQxBS1WwIRMoq/REO3v8iLVBwO9oksvLEuhboV2SWg= 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.160.71 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-oa1-f71.google.com with SMTP id 586e51a60fabf-40ee506cf49so735021fac.2 for ; Fri, 17 Apr 2026 03:11:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776420719; x=1777025519; 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=XxaOnaiKb+Kw3L30II9S3JN9ofCpBZiX6awwfhbYUiQ=; b=Fzqwz4UbWXOfIznvpSxVw09c+gIxNLTwreU4ivLRrKxAo8E7sz3P41YNFhiaG6QJtV AI96YPnM9/tqV6GQsenwQya20m47EmLBMtwv3VJtgxAJfh2qqgCXQYKcVR3zF8UbTwR7 8WeL+6CUV7JWDXT4Cp85TtMmeSxeE9HAFWeixhXUQGwjUnKmO+BrErcnKy1ofafiTVx1 GKXsbLLvfjVTdKjhxqmEPpi3RUe071Yv0S4zQrqzuY14EDiS9OsLDpXKAUz4Ia+RipXR a8JJyAgoeTExP+63A43/JiVCuD6QlTChRf3oDln2FdtE7pqUSlqxWS1JnZ57l4gjBny/ +9Vw== X-Gm-Message-State: AOJu0YxunOVvKH1gPIPfjgbMBRaw0mJyRpRdUETgKWuN+lO7OYuLoYTs GMC9dnzi6JSfH9sqEpWlfLzj5aNGLyIgKCZeOFF4jS2VAkAn8UdpKfETKHPbpaulZoJFoTNV27r BTQNpP3jVGWhmnrR+KjkAVybFnwMYpbr4+LMlD4ibHHJpQOHAd4U1b5Myel4= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Received: by 2002:a05:6820:c0d1:20b0:684:bf61:ed25 with SMTP id 006d021491bc7-69462e3a1d9mr777760eaf.19.1776420719201; Fri, 17 Apr 2026 03:11:59 -0700 (PDT) Date: Fri, 17 Apr 2026 03:11:59 -0700 In-Reply-To: <69345a63.a70a0220.38f243.0031.GAE@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <69e2076f.a00a0220.1cdc.0007.GAE@google.com> Subject: Forwarded: [PATCH] jfs: fix shift-out-of-bounds in dbJoin From: syzbot To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com 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 shift-out-of-bounds in dbJoin Author: tristmd@gmail.com From: Tristan Madani #syz test: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master dbJoin() computes a buddy size via BUDSIZE(newval, budmin), which expands to 1 << (newval - budmin). If the on-disk tree metadata is corrupted such that the leaf values or free counts are inconsistent, newval can exceed budmin + 31, causing a shift-out-of-bounds: UBSAN: shift-out-of-bounds in fs/jfs/jfs_dmap.c:2882:11 shift exponent 132 is too large for 32-bit type 'int' The maximum meaningful newval for a given tree is budmin + l2nleafs, since BUDSIZE at that point equals nleafs and the while loop would not execute. Any value beyond that indicates corrupted metadata. Add a sanity check before the BUDSIZE call: if newval exceeds budmin + l2nleafs, return -EIO. Reported-by: syzbot+fa603ae6b02658401ca7@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=fa603ae6b02658401ca7 Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org Signed-off-by: Tristan Madani --- fs/jfs/jfs_dmap.c | 8 ++++++++ 1 file changed, 8 insertions(+) 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 @@ -2864,6 +2864,14 @@ static int dbJoin(dmtree_t *tp, int leafno, int newval, bool is_ctl) if (newval >= tp->dmt_budmin) { /* pickup a pointer to the leaves of the tree. */ + + /* Validate newval to prevent shift-out-of-bounds in + * BUDSIZE. The maximum meaningful value is budmin + + * l2nleafs; anything beyond indicates corrupted metadata. + */ + if (newval > tp->dmt_budmin + + le32_to_cpu(tp->dmt_l2nleafs)) + return -EIO; leaf = tp->dmt_stree + le32_to_cpu(tp->dmt_leafidx); /* try to join the specified leaf into a large binary -- 2.39.5