fs/ntfs3: Update log->page_{mask,bits} if log->page_size changed
authorHuacai Chen <chenhuacai@loongson.cn>
Wed, 29 May 2024 06:40:52 +0000 (14:40 +0800)
committerKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
Thu, 11 Jul 2024 09:19:46 +0000 (12:19 +0300)
If an NTFS file system is mounted to another system with different
PAGE_SIZE from the original system, log->page_size will change in
log_replay(), but log->page_{mask,bits} don't change correspondingly.
This will cause a panic because "u32 bytes = log->page_size - page_off"
will get a negative value in the later read_log_page().

Cc: stable@vger.kernel.org
Fixes: b46acd6a6a627d876898e ("fs/ntfs3: Add NTFS journal")
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
fs/ntfs3/fslog.c

index f8da043be1699941be5bfb6686ea5f3cb74f9e1e..5ee923904b6afb28446a2ad1bb5663e2b9ed2995 100644 (file)
@@ -3922,6 +3922,9 @@ check_restart_area:
                goto out;
        }
 
+       log->page_mask = log->page_size - 1;
+       log->page_bits = blksize_bits(log->page_size);
+
        /* If the file size has shrunk then we won't mount it. */
        if (log->l_size < le64_to_cpu(ra2->l_size)) {
                err = -EINVAL;