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 D59EC19F47A; Tue, 30 Jul 2024 12:45:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722343534; cv=none; b=p1GwWAwnqPmkuMpisruKyAIIWZXjUFfcyoxkI4XFJTvxLRWF7ozEgW7fBrU7y5FzTAnBcOB7QHgLadi9wgZ//GleRf3lfhcrlETsaF4W9TtEHFLC7tDAXje0ZtBXwHIho+yxxAyq7bPxk/cK4bizMUoXeoV/4En6WbPIAGtWhLM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722343534; c=relaxed/simple; bh=dj3ZUdCBqrSs5hApOQfY89TE70ROrZ696r/pf9VlDAc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TqunODFsNtqgZW+yDBemLr2bRRQsV/xtJEGOVWxz9hz18gvVydKgdTcNfyYA7zGAwxStFK2S5rVFHv6buKoGeeCgOp5MoRHzJDGlTgUNmMBc/ddDNqfHROgvykfNa12cgDwhcis3Aff2mCS7tOW8rsSexidAtk0v7Sh4ez2cR6M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=crcuVciV; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="crcuVciV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BFB7AC4AF09; Tue, 30 Jul 2024 12:45:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722343534; bh=dj3ZUdCBqrSs5hApOQfY89TE70ROrZ696r/pf9VlDAc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=crcuVciVHq5ToUAF6rseBBn0DKLrnqpVniSsUCDq2vYt4VECYWFp+L37c3SdsUNvL wUthBQvIFuGM2X7ShFi1ypiD8ZwXd32M4Ha/tDJF67E7V4BrfUVnwce4XJ53vBTmrI lvda12X/fXnMRVpkx2Ze+WA5VjeJRkjfLEUdIRTYxZZtEtccibYt0eKLoBRwmsQWWk tHgBfSjuk3kFxFYm7dl+jJD9gmBbv5QIJrW8wIgds/Yk7O0p25ohdmdxtYyGd40QQk qUD4BLYrhcPIyP/iuoLeWNpz2D8xcmA/APsp9tmp58BoOH745S2mdKCShwfz+c1Nfz uiSk8XWeEtejg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Pei Li , syzbot+61be3359d2ee3467e7e4@syzkaller.appspotmail.com, Dave Kleikamp , Sasha Levin , shaggy@kernel.org, ghandatmanas@gmail.com, juntong.deng@outlook.com, osmtendev@gmail.com, jfs-discussion@lists.sourceforge.net Subject: [PATCH AUTOSEL 6.10 6/7] jfs: Fix shift-out-of-bounds in dbDiscardAG Date: Tue, 30 Jul 2024 08:45:12 -0400 Message-ID: <20240730124519.3093607-6-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240730124519.3093607-1-sashal@kernel.org> References: <20240730124519.3093607-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.10.2 Content-Transfer-Encoding: 8bit From: Pei Li [ Upstream commit 7063b80268e2593e58bee8a8d709c2f3ff93e2f2 ] When searching for the next smaller log2 block, BLKSTOL2() returned 0, causing shift exponent -1 to be negative. This patch fixes the issue by exiting the loop directly when negative shift is found. Reported-by: syzbot+61be3359d2ee3467e7e4@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=61be3359d2ee3467e7e4 Signed-off-by: Pei Li Signed-off-by: Dave Kleikamp Signed-off-by: Sasha Levin --- fs/jfs/jfs_dmap.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c index cb3cda1390adb..5713994328cbc 100644 --- a/fs/jfs/jfs_dmap.c +++ b/fs/jfs/jfs_dmap.c @@ -1626,6 +1626,8 @@ s64 dbDiscardAG(struct inode *ip, int agno, s64 minlen) } else if (rc == -ENOSPC) { /* search for next smaller log2 block */ l2nb = BLKSTOL2(nblocks) - 1; + if (unlikely(l2nb < 0)) + break; nblocks = 1LL << l2nb; } else { /* Trim any already allocated blocks */ -- 2.43.0