Skip to content

Commit 7af85d5

Browse files
popcornmixpelwell
authored andcommitted
fs/ntfs3: Fix memory corruption when page_size changes
The rework in fs/ntfs3: Reduce stack usage changes log->page_size but doesn't change the associated log->page_mask and log->page_bits. That results in the bytes value in read_log_page getting a negative value, which is bad when it is passed to memcpy. The kernel panic can be observed when connecting an ntfs formatted drive that has previously been connected to a Windows machine to a Raspberry Pi 5, which by defauilt uses a 16K kernel pagesize. Fixes: 865e7a7 ("fs/ntfs3: Reduce stack usage") Signed-off-by: Dom Cobley <[email protected]>
1 parent 47dce8e commit 7af85d5

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

fs/ntfs3/fslog.c

+2
Original file line numberDiff line numberDiff line change
@@ -3907,6 +3907,8 @@ int log_replay(struct ntfs_inode *ni, bool *initialized)
39073907
log->l_size = log->orig_file_size;
39083908
log->page_size = norm_file_page(t32, &log->l_size,
39093909
t32 == DefaultLogPageSize);
3910+
log->page_mask = log->page_size - 1;
3911+
log->page_bits = blksize_bits(log->page_size);
39103912
}
39113913

39123914
if (log->page_size != t32 ||

0 commit comments

Comments
 (0)