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 E7A7730F955; Mon, 13 Oct 2025 15:35:05 +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=1760369706; cv=none; b=XKYU7iJHiJas/7hzEAdZOnHNpfT++kgx2tWSwnCOMZdwk38vNs8o9sC905+HzhpJON1P+v2Cw3fjqYT66URX10THXlnooe1vSQ0/696LE6YuKrAzeD9Zw8F+hu45UUp/ckUrP6Ii0tXURI0B5tLGFu/jqOJnJ6ZQ5XFzHexhHz0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760369706; c=relaxed/simple; bh=W64ANFtBWKmqauUBwHeU/5/T8M6A9VDIl76xHBvRpDs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FLTQgU7f45jNq/yB6yXtaLRyNfo3Ce8u0FVjBG3PLEzKyVfLM96F/hJjkUEE8yXu1k+VjLlwrBmDKkTSFEp2TYQBvipaf3O5RUTQRorBZJw2cKKrbTKFinevgw2OolTCaisxgnPYumERWB8Rq3oarw17B3WSO8RrnZiNdO5Z0PE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=wAQ3N298; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="wAQ3N298" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 66396C4CEE7; Mon, 13 Oct 2025 15:35:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1760369705; bh=W64ANFtBWKmqauUBwHeU/5/T8M6A9VDIl76xHBvRpDs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wAQ3N298UmNlcS9aRi4gqoYJmMBJpMPo4+fpuHjlEmYM9E/7VwkQrq6gRhy04cP/3 BQOknwssC9wKK9WREofeGKsaDUbKJaS2x6g1hBA2nAXSzCQOVBYmqiUeR5s2cIPdtB 6wkcSDFZgWZO7H2ZsxfESe2WrwZ3ydoA9mKj2T3I= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot+b0373017f711c06ada64@syzkaller.appspotmail.com, Moon Hee Lee , Konstantin Komarov , Sasha Levin Subject: [PATCH 6.17 339/563] fs/ntfs3: reject index allocation if $BITMAP is empty but blocks exist Date: Mon, 13 Oct 2025 16:43:20 +0200 Message-ID: <20251013144423.550705949@linuxfoundation.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251013144411.274874080@linuxfoundation.org> References: <20251013144411.274874080@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.17-stable review patch. If anyone has any objections, please let me know. ------------------ From: Moon Hee Lee [ Upstream commit 0dc7117da8f92dd5fe077d712a756eccbe377d40 ] Index allocation requires at least one bit in the $BITMAP attribute to track usage of index entries. If the bitmap is empty while index blocks are already present, this reflects on-disk corruption. syzbot triggered this condition using a malformed NTFS image. During a rename() operation involving a long filename (which spans multiple index entries), the empty bitmap allowed the name to be added without valid tracking. Subsequent deletion of the original entry failed with -ENOENT, due to unexpected index state. Reject such cases by verifying that the bitmap is not empty when index blocks exist. Reported-by: syzbot+b0373017f711c06ada64@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=b0373017f711c06ada64 Fixes: d99208b91933 ("fs/ntfs3: cancle set bad inode after removing name fails") Tested-by: syzbot+b0373017f711c06ada64@syzkaller.appspotmail.com Signed-off-by: Moon Hee Lee Signed-off-by: Konstantin Komarov Signed-off-by: Sasha Levin --- fs/ntfs3/index.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/fs/ntfs3/index.c b/fs/ntfs3/index.c index 1bf2a6593dec6..6d1bf890929d9 100644 --- a/fs/ntfs3/index.c +++ b/fs/ntfs3/index.c @@ -1508,6 +1508,16 @@ static int indx_add_allocate(struct ntfs_index *indx, struct ntfs_inode *ni, bmp_size = bmp_size_v = le32_to_cpu(bmp->res.data_size); } + /* + * Index blocks exist, but $BITMAP has zero valid bits. + * This implies an on-disk corruption and must be rejected. + */ + if (in->name == I30_NAME && + unlikely(bmp_size_v == 0 && indx->alloc_run.count)) { + err = -EINVAL; + goto out1; + } + bit = bmp_size << 3; } -- 2.51.0