This is a note to let you know that I've just added the patch titled fs/ntfs3: Fix case when index is reused during tree transformation to the 6.1-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: fs-ntfs3-fix-case-when-index-is-reused-during-tree-transformation.patch and it can be found in the queue-6.1 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 05afeeebcac850a016ec4fb1f681ceda11963562 Mon Sep 17 00:00:00 2001 From: Konstantin Komarov <almaz.alexandrovich@xxxxxxxxxxxxxxxxxxxx> Date: Tue, 23 Apr 2024 15:31:56 +0300 Subject: fs/ntfs3: Fix case when index is reused during tree transformation From: Konstantin Komarov <almaz.alexandrovich@xxxxxxxxxxxxxxxxxxxx> commit 05afeeebcac850a016ec4fb1f681ceda11963562 upstream. In most cases when adding a cluster to the directory index, they are placed at the end, and in the bitmap, this cluster corresponds to the last bit. The new directory size is calculated as follows: data_size = (u64)(bit + 1) << indx->index_bits; In the case of reusing a non-final cluster from the index, data_size is calculated incorrectly, resulting in the directory size differing from the actual size. A check for cluster reuse has been added, and the size update is skipped. Fixes: 82cae269cfa95 ("fs/ntfs3: Add initialization of super block") Signed-off-by: Konstantin Komarov <almaz.alexandrovich@xxxxxxxxxxxxxxxxxxxx> Cc: stable@xxxxxxxxxxxxxxx Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/ntfs3/index.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/fs/ntfs3/index.c +++ b/fs/ntfs3/index.c @@ -1531,6 +1531,11 @@ static int indx_add_allocate(struct ntfs goto out1; } + if (data_size <= le64_to_cpu(alloc->nres.data_size)) { + /* Reuse index. */ + goto out; + } + /* Increase allocation. */ err = attr_set_size(ni, ATTR_ALLOC, in->name, in->name_len, &indx->alloc_run, data_size, &data_size, true, @@ -1541,6 +1546,7 @@ static int indx_add_allocate(struct ntfs goto out1; } +out: *vbn = bit << indx->idx2vbn_bits; return 0; Patches currently in stable-queue which might be from almaz.alexandrovich@xxxxxxxxxxxxxxxxxxxx are queue-6.1/fs-ntfs3-break-dir-enumeration-if-directory-contents-error.patch queue-6.1/fs-ntfs3-taking-dos-names-into-account-during-link-counting.patch queue-6.1/fs-ntfs3-fix-case-when-index-is-reused-during-tree-transformation.patch queue-6.1/fs-ntfs3-remove-max-link-count-info-display-during-driver-init.patch