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 8E1721863 for ; Wed, 28 Dec 2022 15:37:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16A5EC433D2; Wed, 28 Dec 2022 15:37:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1672241865; bh=NHTW7g8YDXVengTimg9WZo8+RBxdAodiEvHs3vTBHYo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q9p4FlCGzKex3CY0n4gwj4ryou7LqmcrqavpwYo198r8ziFWL/NPHkC4aHXZTuxFW SLaJPFXJRMPv7zO/QMFg5aiXXpuIu5TSZhM1OydMzeYN4f4TO7EzOz0UddT75g72gX xm12snTLYQzmBo1yZW9uhtE7DPEdrgT6iSoakt6o= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot+b892240eac461e488d51@syzkaller.appspotmail.com, Abdun Nihaal , Konstantin Komarov , Sasha Levin Subject: [PATCH 5.15 536/731] fs/ntfs3: Fix slab-out-of-bounds read in ntfs_trim_fs Date: Wed, 28 Dec 2022 15:40:43 +0100 Message-Id: <20221228144312.082147609@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20221228144256.536395940@linuxfoundation.org> References: <20221228144256.536395940@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Abdun Nihaal [ Upstream commit 557d19675a470bb0a98beccec38c5dc3735c20fa ] Syzbot reports an out of bound access in ntfs_trim_fs. The cause of this is using a loop termination condition that compares window index (iw) with wnd->nbits instead of wnd->nwnd, due to which the index used for wnd->free_bits exceeds the size of the array allocated. Fix the loop condition. Fixes: 3f3b442b5ad2 ("fs/ntfs3: Add bitmap") Link: https://syzkaller.appspot.com/bug?extid=b892240eac461e488d51 Reported-by: syzbot+b892240eac461e488d51@syzkaller.appspotmail.com Signed-off-by: Abdun Nihaal Signed-off-by: Konstantin Komarov Signed-off-by: Sasha Levin --- fs/ntfs3/bitmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ntfs3/bitmap.c b/fs/ntfs3/bitmap.c index aa184407520f..7f2055b7427a 100644 --- a/fs/ntfs3/bitmap.c +++ b/fs/ntfs3/bitmap.c @@ -1432,7 +1432,7 @@ int ntfs_trim_fs(struct ntfs_sb_info *sbi, struct fstrim_range *range) down_read_nested(&wnd->rw_lock, BITMAP_MUTEX_CLUSTERS); - for (; iw < wnd->nbits; iw++, wbit = 0) { + for (; iw < wnd->nwnd; iw++, wbit = 0) { CLST lcn_wnd = iw * wbits; struct buffer_head *bh; -- 2.35.1