Skip to content

Commit

Permalink
fs/ntfs3: Update log->page_{mask,bits} if log->page_size changed
Browse files Browse the repository at this point in the history
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: [email protected]
Fixes: b46acd6 ("fs/ntfs3: Add NTFS journal")
Signed-off-by: Huacai Chen <[email protected]>
  • Loading branch information
chenhuacai authored and MingcongBai committed Aug 6, 2024
1 parent 9304409 commit 43cdd36
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions fs/ntfs3/fslog.c
Original file line number Diff line number Diff line change
Expand Up @@ -3915,6 +3915,9 @@ int log_replay(struct ntfs_inode *ni, bool *initialized)
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;
Expand Down

0 comments on commit 43cdd36

Please sign in to comment.