From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DAC2B41C92; Tue, 16 Jan 2024 00:26:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NCm3aRXs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4CD83C433C7; Tue, 16 Jan 2024 00:26:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705364780; bh=VJdzakrW+kXBQk7/3tiYc2BgFP8I61qRKCB690jnnrw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NCm3aRXsa1KIVhikJPbOmNhwVJl/Ol+jqoGdIeVnKBTB9s/xNs8c/Rz+AokvRXASw 0BTfnT/WIS+c3Y2SUCfRg30zVP6FjnO+1R78l1Nd5RN2n5/vElWcBOnc4FF4Vhil69 mH4aeYY+J8HfQOqzDFEs3Cjwfq/jsGBL/o8JEhhznmRad5yuyStBT+yTnCVgSojsWx rfjTQFbUQm3gBd/gr9+HQ79O6I3AQwODPpSz9WHldbweZiLtMO3wNfIl9FPajQ++CY Lddiy8zCgHRm1kKn9PLcYxGpxmqVgllGGekrLXmHJKI9JOH6xI5l99bo++/FDZpDEa 4ZnimLUEGAmhA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Manas Ghandat , syzbot+411debe54d318eaed386@syzkaller.appspotmail.com, Dave Kleikamp , Sasha Levin , shaggy@kernel.org, juntong.deng@outlook.com, wonguk.lee1023@gmail.com, code@siddh.me, yogi.kernel@gmail.com, andrew.kanner@gmail.com, osmtendev@gmail.com, jfs-discussion@lists.sourceforge.net Subject: [PATCH AUTOSEL 5.15 06/13] jfs: fix shift-out-of-bounds in dbJoin Date: Mon, 15 Jan 2024 19:25:42 -0500 Message-ID: <20240116002603.215942-6-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240116002603.215942-1-sashal@kernel.org> References: <20240116002603.215942-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 5.15.147 Content-Transfer-Encoding: 8bit From: Manas Ghandat [ Upstream commit cca974daeb6c43ea971f8ceff5a7080d7d49ee30 ] Currently while joining the leaf in a buddy system there is shift out of bound error in calculation of BUDSIZE. Added the required check to the BUDSIZE and fixed the documentation as well. Reported-by: syzbot+411debe54d318eaed386@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=411debe54d318eaed386 Signed-off-by: Manas Ghandat Signed-off-by: Dave Kleikamp Signed-off-by: Sasha Levin --- fs/jfs/jfs_dmap.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c index 3f5c14315719..c1290e7a8d24 100644 --- a/fs/jfs/jfs_dmap.c +++ b/fs/jfs/jfs_dmap.c @@ -2831,7 +2831,9 @@ static int dbBackSplit(dmtree_t *tp, int leafno, bool is_ctl) * leafno - the number of the leaf to be updated. * newval - the new value for the leaf. * - * RETURN VALUES: none + * RETURN VALUES: + * 0 - success + * -EIO - i/o error */ static int dbJoin(dmtree_t *tp, int leafno, int newval, bool is_ctl) { @@ -2858,6 +2860,10 @@ static int dbJoin(dmtree_t *tp, int leafno, int newval, bool is_ctl) * get the buddy size (number of words covered) of * the new value. */ + + if ((newval - tp->dmt_budmin) > BUDMIN) + return -EIO; + budsz = BUDSIZE(newval, tp->dmt_budmin); /* try to join. -- 2.43.0