aboutsummaryrefslogtreecommitdiff
path: root/fs/ntfs3
AgeCommit message (Collapse)AuthorFilesLines
2024-10-08Merge tag 'ntfs3_for_6.12' of ↵Linus Torvalds14-197/+410
https://github.com/Paragon-Software-Group/linux-ntfs3 Pull ntfs3 updates from Konstantin Komarov: "New: - implement fallocate for compressed files - add support for the compression attribute - optimize large writes to sparse files Fixes: - fix several potential deadlock scenarios - fix various internal bugs detected by syzbot - add checks before accessing NTFS structures during parsing - correct the format of output messages Refactoring: - replace fsparam_flag_no with fsparam_flag in options parser - remove unused functions and macros" * tag 'ntfs3_for_6.12' of https://github.com/Paragon-Software-Group/linux-ntfs3: (25 commits) fs/ntfs3: Format output messages like others fs in kernel fs/ntfs3: Additional check in ntfs_file_release fs/ntfs3: Fix general protection fault in run_is_mapped_full fs/ntfs3: Sequential field availability check in mi_enum_attr() fs/ntfs3: Additional check in ni_clear() fs/ntfs3: Fix possible deadlock in mi_read ntfs3: Change to non-blocking allocation in ntfs_d_hash fs/ntfs3: Remove unused al_delete_le fs/ntfs3: Rename ntfs3_setattr into ntfs_setattr fs/ntfs3: Replace fsparam_flag_no -> fsparam_flag fs/ntfs3: Add support for the compression attribute fs/ntfs3: Implement fallocate for compressed files fs/ntfs3: Make checks in run_unpack more clear fs/ntfs3: Add rough attr alloc_size check fs/ntfs3: Stale inode instead of bad fs/ntfs3: Refactor enum_rstbl to suppress static checker fs/ntfs3: Fix sparse warning in ni_fiemap fs/ntfs3: Fix warning possible deadlock in ntfs_set_state fs/ntfs3: Fix sparse warning for bigendian fs/ntfs3: Separete common code for file_read/write iter/splice ...
2024-10-02move asm/unaligned.h to linux/unaligned.hAl Viro1-1/+1
asm/unaligned.h is always an include of asm-generic/unaligned.h; might as well move that thing to linux/unaligned.h and include that - there's nothing arch-specific in that header. auto-generated by the following: for i in `git grep -l -w asm/unaligned.h`; do sed -i -e "s/asm\/unaligned.h/linux\/unaligned.h/" $i done for i in `git grep -l -w asm-generic/unaligned.h`; do sed -i -e "s/asm-generic\/unaligned.h/linux\/unaligned.h/" $i done git mv include/asm-generic/unaligned.h include/linux/unaligned.h git mv tools/include/asm-generic/unaligned.h tools/include/linux/unaligned.h sed -i -e "/unaligned.h/d" include/asm-generic/Kbuild sed -i -e "s/__ASM_GENERIC/__LINUX/" include/linux/unaligned.h tools/include/linux/unaligned.h
2024-10-01fs/ntfs3: Format output messages like others fs in kernelKonstantin Komarov1-4/+9
Signed-off-by: Konstantin Komarov <[email protected]>
2024-10-01fs/ntfs3: Additional check in ntfs_file_releaseKonstantin Komarov1-1/+8
Reported-by: [email protected] Signed-off-by: Konstantin Komarov <[email protected]>
2024-10-01fs/ntfs3: Fix general protection fault in run_is_mapped_fullKonstantin Komarov1-1/+4
Fixed deleating of a non-resident attribute in ntfs_create_inode() rollback. Reported-by: [email protected] Signed-off-by: Konstantin Komarov <[email protected]>
2024-10-01fs/ntfs3: Sequential field availability check in mi_enum_attr()Konstantin Komarov1-8/+7
The code is slightly reformatted to consistently check field availability without duplication. Fixes: 556bdf27c2dd ("ntfs3: Add bounds checking to mi_enum_attr()") Signed-off-by: Konstantin Komarov <[email protected]>
2024-10-01fs/ntfs3: Additional check in ni_clear()Konstantin Komarov1-1/+3
Checking of NTFS_FLAGS_LOG_REPLAYING added to prevent access to uninitialized bitmap during replay process. Reported-by: [email protected] Signed-off-by: Konstantin Komarov <[email protected]>
2024-10-01fs/ntfs3: Fix possible deadlock in mi_readKonstantin Komarov1-1/+1
Mutex lock with another subclass used in ni_lock_dir(). Reported-by: [email protected] Signed-off-by: Konstantin Komarov <[email protected]>
2024-10-01ntfs3: Change to non-blocking allocation in ntfs_d_hashDiogo Jahchan Koike1-2/+2
d_hash is done while under "rcu-walk" and should not sleep. __get_name() allocates using GFP_KERNEL, having the possibility to sleep when under memory pressure. Change the allocation to GFP_NOWAIT. Reported-by: [email protected] Closes: https://syzkaller.appspot.com/bug?extid=7f71f79bbfb4427b00e1 Fixes: d392e85fd1e8 ("fs/ntfs3: Fix the format of the "nocase" mount option") Signed-off-by: Diogo Jahchan Koike <[email protected]> Signed-off-by: Konstantin Komarov <[email protected]>
2024-10-01fs/ntfs3: Remove unused al_delete_leDr. David Alan Gilbert2-55/+0
'al_delete_le' was added by: Commit be71b5cba2e6 ("fs/ntfs3: Add attrib operations") but has remained unused; there is an al_remove_le which seems to be being used instead. Remove 'al_delete_le'. Signed-off-by: Dr. David Alan Gilbert <[email protected]>
2024-09-03fs/ntfs3: Rename ntfs3_setattr into ntfs_setattrKonstantin Komarov5-10/+10
Aligning names to a single naming convention. Signed-off-by: Konstantin Komarov <[email protected]>
2024-09-03fs/ntfs3: Replace fsparam_flag_no -> fsparam_flagKonstantin Komarov1-27/+27
Based on the experience with an error related to incorrect parsing of the 'nocase' option, I decided to simplify the list and type of parameters. Signed-off-by: Konstantin Komarov <[email protected]>
2024-09-03fs/ntfs3: Add support for the compression attributeKonstantin Komarov4-1/+156
Support added for empty files and directories only. Signed-off-by: Konstantin Komarov <[email protected]>
2024-09-03fs/ntfs3: Implement fallocate for compressed filesKonstantin Komarov2-11/+17
Signed-off-by: Konstantin Komarov <[email protected]>
2024-09-03fs/ntfs3: Make checks in run_unpack more clearKonstantin Komarov1-3/+5
Signed-off-by: Konstantin Komarov <[email protected]>
2024-09-03fs/ntfs3: Add rough attr alloc_size checkKonstantin Komarov1-0/+3
Reported-by: [email protected] Signed-off-by: Konstantin Komarov <[email protected]>
2024-09-03fs/ntfs3: Stale inode instead of badKonstantin Komarov1-3/+7
Fixed the logic of processing inode with wrong sequence number. Signed-off-by: Konstantin Komarov <[email protected]>
2024-09-03fs/ntfs3: Refactor enum_rstbl to suppress static checkerKonstantin Komarov1-2/+17
Comments and brief description of function enum_rstbl added. Fixes: b46acd6a6a62 ("fs/ntfs3: Add NTFS journal") Reported-by: Dan Carpenter <[email protected]> Signed-off-by: Konstantin Komarov <[email protected]>
2024-09-03fs/ntfs3: Fix sparse warning in ni_fiemapKonstantin Komarov1-13/+8
The interface of fiemap_fill_next_extent_k() was modified to eliminate the sparse warning. Fixes: d57431c6f511 ("fs/ntfs3: Do copy_to_user out of run_lock") Reported-by: kernel test robot <[email protected]> Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/ Signed-off-by: Konstantin Komarov <[email protected]>
2024-09-03fs/ntfs3: Fix warning possible deadlock in ntfs_set_stateKonstantin Komarov1-1/+1
Use non-zero subkey to skip analyzer warnings. Signed-off-by: Konstantin Komarov <[email protected]> Reported-by: [email protected]
2024-09-03fs/ntfs3: Fix sparse warning for bigendianKonstantin Komarov1-2/+1
Fixes: 220cf0498bbf ("fs/ntfs3: Simplify initialization of $AttrDef and $UpCase") Reported-by: kernel test robot <[email protected]> Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/ Signed-off-by: Konstantin Komarov <[email protected]>
2024-09-03fs/ntfs3: Separete common code for file_read/write iter/spliceKonstantin Komarov1-40/+76
The common code for handling encrypted, dedup, and compressed files has been moved to check_read_restriction() and check_write_restriction(). Signed-off-by: Konstantin Komarov <[email protected]>
2024-09-03fs/ntfs3: Optimize large writes into sparse fileKonstantin Komarov1-0/+36
Optimized cluster allocation by allocating a large chunk in advance before writing, instead of allocating during the writing process by clusters. Essentially replicates the logic of fallocate. Fixes: 4342306f0f0d ("fs/ntfs3: Add file operations and implementation") Signed-off-by: Konstantin Komarov <[email protected]>
2024-09-03fs/ntfs3: Do not call file_modified if collapse range failedKonstantin Komarov1-1/+3
Fixes: 4342306f0f0d ("fs/ntfs3: Add file operations and implementation") Signed-off-by: Konstantin Komarov <[email protected]>
2024-09-03fs/ntfs3: Check if more than chunk-size bytes are writtenAndrew Ballance1-0/+3
A incorrectly formatted chunk may decompress into more than LZNT_CHUNK_SIZE bytes and a index out of bounds will occur in s_max_off. Signed-off-by: Andrew Ballance <[email protected]> Signed-off-by: Konstantin Komarov <[email protected]>
2024-09-03ntfs3: Add bounds checking to mi_enum_attr()lei lu1-13/+10
Added bounds checking to make sure that every attr don't stray beyond valid memory region. Signed-off-by: lei lu <[email protected]> Signed-off-by: Konstantin Komarov <[email protected]>
2024-09-03fs/ntfs3: Use swap() to improve codeThorsten Blum1-2/+1
Use the swap() macro to simplify the code and improve its readability. Fixes the following Coccinelle/coccicheck warning reported by swap.cocci: WARNING opportunity for swap() Compile-tested only. Signed-off-by: Thorsten Blum <[email protected]> Signed-off-by: Konstantin Komarov <[email protected]>
2024-08-07fs: Convert aops->write_begin to take a folioMatthew Wilcox (Oracle)3-10/+8
Convert all callers from working on a page to working on one page of a folio (support for working on an entire folio can come later). Removes a lot of folio->page->folio conversions. Reviewed-by: Josef Bacik <[email protected]> Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
2024-08-07fs: Convert aops->write_end to take a folioMatthew Wilcox (Oracle)3-5/+4
Most callers have a folio, and most implementations operate on a folio, so remove the conversion from folio->page->folio to fit through this interface. Reviewed-by: Josef Bacik <[email protected]> Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
2024-08-07ntfs3: Remove reset_log_file()Matthew Wilcox (Oracle)2-40/+0
This function has no callers (which will be why nobody noticed that the page wasn't being unlocked). Reviewed-by: Josef Bacik <[email protected]> Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
2024-07-22Merge tag 'ntfs3_for_6.11' of ↵Linus Torvalds14-309/+480
https://github.com/Paragon-Software-Group/linux-ntfs3 Pull ntfs3 updates from Konstantin Komarov: "New code: - simple fileattr support Fixes: - transform resident to nonresident for compressed files - the format of the "nocase" mount option - getting file type - many other internal bugs Refactoring: - remove unused functions and macros - partial transition from page to folio (suggested by Matthew Wilcox) - legacy ntfs support" * tag 'ntfs3_for_6.11' of https://github.com/Paragon-Software-Group/linux-ntfs3: (42 commits) fs/ntfs3: Fix formatting, change comments, renaming fs/ntfs3: Update log->page_{mask,bits} if log->page_size changed fs/ntfs3: Implement simple fileattr fs/ntfs3: Redesign legacy ntfs support fs/ntfs3: Use function file_inode to get inode from file fs/ntfs3: Minor ntfs_list_ea refactoring fs/ntfs3: Check more cases when directory is corrupted fs/ntfs3: Do copy_to_user out of run_lock fs/ntfs3: Keep runs for $MFT::$ATTR_DATA and $MFT::$ATTR_BITMAP fs/ntfs3: Missed error return fs/ntfs3: Fix the format of the "nocase" mount option fs/ntfs3: Fix field-spanning write in INDEX_HDR ntfs3: Convert attr_wof_frame_info() to use a folio ntfs3: Convert ni_readpage_cmpr() to take a folio ntfs3: Convert ntfs_get_frame_pages() to use a folio ntfs3: Remove calls to set/clear the error flag ntfs3: Convert attr_make_nonresident to use a folio ntfs3: Convert attr_data_write_resident to use a folio ntfs3: Convert ntfs_write_end() to work on a folio ntfs3: Convert attr_data_read_resident() to take a folio ...
2024-07-11fs/ntfs3: Fix formatting, change comments, renamingKonstantin Komarov5-18/+21
Huacai Chen: The label end_reply is obviously a typo. It should be "replay" in this context. So rename end_reply to end_replay. Suggested-by: Huacai Chen <[email protected]> Signed-off-by: Konstantin Komarov <[email protected]>
2024-07-11fs/ntfs3: Update log->page_{mask,bits} if log->page_size changedHuacai Chen1-0/+3
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: b46acd6a6a627d876898e ("fs/ntfs3: Add NTFS journal") Signed-off-by: Huacai Chen <[email protected]> Signed-off-by: Konstantin Komarov <[email protected]>
2024-07-11fs/ntfs3: Implement simple fileattrKonstantin Komarov3-5/+76
fileattr added to support chattr. Supported attributes: compressed and immutable. Signed-off-by: Konstantin Komarov <[email protected]>
2024-07-11fs/ntfs3: Redesign legacy ntfs supportKonstantin Komarov5-18/+23
1) Make is_legacy_ntfs static inline. 2) Put legacy file_operations under #if IS_ENABLED(CONFIG_NTFS_FS). Cc: Matthew Wilcox (Oracle) <[email protected]> Cc: Christian Brauner <[email protected]> Signed-off-by: Konstantin Komarov <[email protected]>
2024-07-11fs/ntfs3: Use function file_inode to get inode from fileKonstantin Komarov1-7/+5
Signed-off-by: Konstantin Komarov <[email protected]>
2024-07-11fs/ntfs3: Minor ntfs_list_ea refactoringKonstantin Komarov1-12/+13
For easy internal debugging. Signed-off-by: Konstantin Komarov <[email protected]>
2024-07-11fs/ntfs3: Check more cases when directory is corruptedKonstantin Komarov1-20/+32
Mark ntfs dirty in this case. Rename ntfs_filldir to ntfs_dir_emit. Signed-off-by: Konstantin Komarov <[email protected]>
2024-07-11fs/ntfs3: Do copy_to_user out of run_lockKonstantin Komarov1-3/+72
In order not to call copy_to_user (from fiemap_fill_next_extent) we allocate memory in the kernel, fill it and copy it to user memory after up_read(run_lock). Reported-by: [email protected] Signed-off-by: Konstantin Komarov <[email protected]>
2024-07-11fs/ntfs3: Keep runs for $MFT::$ATTR_DATA and $MFT::$ATTR_BITMAPKonstantin Komarov1-1/+2
We skip the run_truncate_head call also for $MFT::$ATTR_BITMAP. Otherwise wnd_map()/run_lookup_entry will not find the disk position for the bitmap parts. Fixes: 0e5b044cbf3a ("fs/ntfs3: Refactoring attr_set_size to restore after errors") Signed-off-by: Konstantin Komarov <[email protected]>
2024-07-11fs/ntfs3: Missed error returnKonstantin Komarov1-1/+1
Fixes: 3f3b442b5ad2 ("fs/ntfs3: Add bitmap") Signed-off-by: Konstantin Komarov <[email protected]>
2024-07-11fs/ntfs3: Fix the format of the "nocase" mount optionKonstantin Komarov1-1/+1
The 'nocase' option was mistakenly added as fsparam_flag_no with the 'no' prefix, causing the case-insensitive mode to require the 'nonocase' option to be enabled. Fixes: a3a956c78efa ("fs/ntfs3: Add option "nocase"") Signed-off-by: Konstantin Komarov <[email protected]>
2024-07-02ntfs3: Convert to new uid/gid option parsing helpersEric Sandeen1-8/+4
Convert to new uid/gid option parsing helpers Signed-off-by: Eric Sandeen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christian Brauner <[email protected]>
2024-06-26fs/ntfs3: Fix field-spanning write in INDEX_HDRKonstantin Komarov2-6/+7
Fields flags and res[3] replaced with one 4 byte flags. Fixes: 4534a70b7056 ("fs/ntfs3: Add headers and misc files") Signed-off-by: Konstantin Komarov <[email protected]>
2024-06-26ntfs3: Convert attr_wof_frame_info() to use a folioMatthew Wilcox (Oracle)3-20/+21
This involves converting all users of offs_page to offs_folio, but it's worth it because we get rid of a lot of hidden calls to compound_head(). We continue to use order-0 folios here, and convert back to a struct page to call ntfs_bio_pages(). Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Signed-off-by: Konstantin Komarov <[email protected]>
2024-06-26ntfs3: Convert ni_readpage_cmpr() to take a folioMatthew Wilcox (Oracle)3-8/+9
We still use an array of pages for the decompression, but this removes a few calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Signed-off-by: Konstantin Komarov <[email protected]>
2024-06-26ntfs3: Convert ntfs_get_frame_pages() to use a folioMatthew Wilcox (Oracle)1-8/+9
The function still takes an array of pages, but use a folio internally. This function would deadlock against itself if used with large folios (as it locks each page), so we can be a little sloppy with the conversion back from folio to page for now. Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Signed-off-by: Konstantin Komarov <[email protected]>
2024-06-26ntfs3: Remove calls to set/clear the error flagMatthew Wilcox (Oracle)1-4/+0
Nobody checks the error flag on ntfs3 folios, so stop setting and clearing it. Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Signed-off-by: Konstantin Komarov <[email protected]>
2024-06-26ntfs3: Convert attr_make_nonresident to use a folioMatthew Wilcox (Oracle)1-14/+13
Fetch a folio from the page cache instead of a page and operate on it. Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> [[email protected]: skip using folio_end_read] Signed-off-by: Konstantin Komarov <[email protected]>
2024-06-26ntfs3: Convert attr_data_write_resident to use a folioMatthew Wilcox (Oracle)3-11/+7
Now that both callers of attr_data_write_resident() have a folio, pass it in and use memcpy_from_folio() to handle all the gnarly highmem multi-page problems. Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Signed-off-by: Konstantin Komarov <[email protected]>