summaryrefslogtreecommitdiff
path: root/fs/ntfs3
AgeCommit message (Collapse)AuthorFilesLines
2024-11-01fs/ntfs3: Accumulated refactoring changesKonstantin Komarov4-50/+21
Changes made to improve readability and debuggability. Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
2024-11-01fs/ntfs3: Switch to folio to release resourcesKonstantin Komarov1-11/+17
As part of the process of switching from page to folio. Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
2024-11-01fs/ntfs3: Add check in ntfs_extend_initialized_sizeKonstantin Komarov1-1/+3
Check arguments again after lock. Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
2024-11-01fs/ntfs3: Add more checks in mi_enum_attr (part 2)Konstantin Komarov1-3/+13
Add offset check before access to attr->non_res field as mentioned in [1]. [1] https://lore.kernel.org/ntfs3/20241010110005.42792-1-llfamsec@gmail.com/ Suggested-by: lei lu <llfamsec@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
2024-11-01fs/ntfs3: Equivalent transition from page to folioKonstantin Komarov1-1/+1
If using the proposed function folio_zero_range(), should one switch from 'start + end' to 'start + length,' or use folio_zero_segment() Fixes: 1da86618bdce ("fs: Convert aops->write_begin to take a folio") Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
2024-11-01fs/ntfs3: Fix case when unmarked clusters intersect with zoneKonstantin Komarov1-10/+30
Reported-by: syzbot+7f3761b790fa41d0f3d5@syzkaller.appspotmail.com Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
2024-11-01fs/ntfs3: Fix warning in ni_fiemapKonstantin Komarov3-94/+21
Use local runs_tree instead of cached. This way excludes rw_semaphore lock. Reported-by: syzbot+1c25748a40fe79b8a119@syzkaller.appspotmail.com Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
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 <almaz.alexandrovich@paragon-software.com>
2024-10-01fs/ntfs3: Additional check in ntfs_file_releaseKonstantin Komarov1-1/+8
Reported-by: syzbot+8c652f14a0fde76ff11d@syzkaller.appspotmail.com Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
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: syzbot+9af29acd8f27fbce94bc@syzkaller.appspotmail.com Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
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 <almaz.alexandrovich@paragon-software.com>
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: syzbot+3bfd2cc059ab93efcdb4@syzkaller.appspotmail.com Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
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: syzbot+bc7ca0ae4591cb2550f9@syzkaller.appspotmail.com Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
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: syzbot+7f71f79bbfb4427b00e1@syzkaller.appspotmail.com 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 <djahchankoike@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
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 <linux@treblig.org>
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 <almaz.alexandrovich@paragon-software.com>
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 <almaz.alexandrovich@paragon-software.com>
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 <almaz.alexandrovich@paragon-software.com>
2024-09-03fs/ntfs3: Implement fallocate for compressed filesKonstantin Komarov2-11/+17
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
2024-09-03fs/ntfs3: Make checks in run_unpack more clearKonstantin Komarov1-3/+5
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
2024-09-03fs/ntfs3: Add rough attr alloc_size checkKonstantin Komarov1-0/+3
Reported-by: syzbot+c6d94bedd910a8216d25@syzkaller.appspotmail.com Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
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 <almaz.alexandrovich@paragon-software.com>
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 <dan.carpenter@linaro.org> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
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 <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202406271920.hndE8N6D-lkp@intel.com/ Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
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 <almaz.alexandrovich@paragon-software.com> Reported-by: syzbot+c2ada45c23d98d646118@syzkaller.appspotmail.com
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 <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202404181111.Wz8a1qX6-lkp@intel.com/ Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
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 <almaz.alexandrovich@paragon-software.com>
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 <almaz.alexandrovich@paragon-software.com>
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 <almaz.alexandrovich@paragon-software.com>
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 <andrewjballance@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
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 <llfamsec@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
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 <thorsten.blum@toblux.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
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 <josef@toxicpanda.com> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Signed-off-by: Christian Brauner <brauner@kernel.org>
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 <josef@toxicpanda.com> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Signed-off-by: Christian Brauner <brauner@kernel.org>
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 <josef@toxicpanda.com> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Signed-off-by: Christian Brauner <brauner@kernel.org>
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 <chenhuacai@loongson.cn> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
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: 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>
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 <almaz.alexandrovich@paragon-software.com>
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) <willy@infradead.org> Cc: Christian Brauner <brauner@kernel.org> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
2024-07-11fs/ntfs3: Use function file_inode to get inode from fileKonstantin Komarov1-7/+5
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
2024-07-11fs/ntfs3: Minor ntfs_list_ea refactoringKonstantin Komarov1-12/+13
For easy internal debugging. Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
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 <almaz.alexandrovich@paragon-software.com>
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: syzbot+36bb70085ef6edc2ebb9@syzkaller.appspotmail.com Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
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 <almaz.alexandrovich@paragon-software.com>
2024-07-11fs/ntfs3: Missed error returnKonstantin Komarov1-1/+1
Fixes: 3f3b442b5ad2 ("fs/ntfs3: Add bitmap") Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
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 <almaz.alexandrovich@paragon-software.com>
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 <sandeen@redhat.com> Link: https://lore.kernel.org/r/04bf30db-8542-48dc-9060-7f7dc08eda22@redhat.com Signed-off-by: Christian Brauner <brauner@kernel.org>