linux/fs/btrfs
Eric Biggers c349b233d6 fsverity: Set S_VERITY only after rollback is no longer possible
Commit f77f281b61 ("fsverity: use a hashtable to find the
fsverity_info") changed the implementation of FS_IOC_ENABLE_VERITY to
make concurrent reads start going through fsverity verification slightly
earlier than they did before.

Instead of it happening when enable_verity() calls fsverity_set_info(),
it now happens when ->end_enable_verity() sets S_VERITY.

However, ext4 and btrfs can roll back verity after they set S_VERITY,
causing a use-after-free.

Fix that by making ext4 and btrfs set S_VERITY only after rollback is no
longer possible.  On failure, don't roll back S_VERITY, but do roll back
the filesystem-specific verity flag.

Also update enable_verity() to handle any future instances of this bug
more safely by warning and *not* freeing the fsverity_info.

Finally, tweak some comments.  Clarify one, and move information from
another to its proper place in the comment for ->end_enable_verity().

Fixes: f77f281b61 ("fsverity: use a hashtable to find the fsverity_info")
Cc: stable@vger.kernel.org
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://patch.msgid.link/20261025204807.122875-1-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
2026-10-28 10:53:43 -07:00
..
tests btrfs: move __TRANS_* and TRANS_* flags out of transaction.h 2026-10-12 19:16:23 +02:00
accessors.c btrfs: fix off-by-one end offset check in report_setget_bounds() 2026-10-12 19:16:23 +02:00
accessors.h
acl.c fs: port ->set_acl() to pass const mnt_idmap 2026-09-23 09:19:49 +02:00
acl.h fs: port ->set_acl() to pass const mnt_idmap 2026-09-23 09:19:49 +02:00
async-thread.c
async-thread.h
backref.c btrfs: move __TRANS_* and TRANS_* flags out of transaction.h 2026-10-12 19:16:23 +02:00
backref.h btrfs: use on stack backref iterator in build_backref_tree() 2026-06-08 15:53:32 +02:00
bio.c btrfs: replace is_data_bbio() with is_data_inode() for direct usage 2026-10-12 19:16:20 +02:00
bio.h btrfs: use bio::remaining for async checksumming synchronization 2026-10-12 19:16:20 +02:00
block-group.c btrfs: remove btrfs_disk_cache_state 2026-10-16 19:10:45 +02:00
block-group.h btrfs: remove btrfs_disk_cache_state 2026-10-16 19:10:45 +02:00
block-rsv.c btrfs: remove pointless qgroup assignment in block_rsv_release_bytes() 2026-10-12 19:16:24 +02:00
block-rsv.h btrfs: remove fs_info argument from btrfs_block_rsv_refill() 2026-10-12 19:16:23 +02:00
btrfs_inode.h for-7.4-part2-tag 2026-10-25 16:15:22 -10:00
compression.c btrfs: simplify heuristic_collect_sample() to handle large folios better 2026-10-12 19:16:21 +02:00
compression.h btrfs: prevent direct reclaim during compressed readahead 2026-04-07 18:56:08 +02:00
ctree.c btrfs: use kvmalloc() for b-tree split_item() 2026-10-12 19:16:20 +02:00
ctree.h btrfs: qgroup: fix swapped blocks existence check when tracing after COW 2026-10-12 19:16:24 +02:00
defrag.c btrfs: defrag: fix check to see if next extent can be defragged too 2026-10-12 19:16:25 +02:00
defrag.h
delalloc-space.c btrfs: remove BTRFS_RESERVE_FLUSH_FREE_SPACE_INODE 2026-10-16 19:10:45 +02:00
delalloc-space.h
delayed-inode.c btrfs: remove fs_info argument from btrfs_block_rsv_add() 2026-10-12 19:16:23 +02:00
delayed-inode.h btrfs: pre-allocate delayed dir index before btree modification 2026-10-12 19:16:20 +02:00
delayed-ref.c btrfs: lift assertions to beginning of insert_delayed_ref() 2026-06-08 15:53:28 +02:00
delayed-ref.h
dev-replace.c btrfs: free unlinked replace target on initialization failure 2026-10-12 19:16:19 +02:00
dev-replace.h
dir-item.c btrfs: simplify dir item location setup in btrfs_insert_xattr_item() 2026-10-12 19:16:22 +02:00
dir-item.h btrfs: pre-allocate delayed dir index before btree modification 2026-10-12 19:16:20 +02:00
direct-io.c btrfs: downgrade the reflink source inode lock for tree walking 2026-10-12 19:16:21 +02:00
direct-io.h
discard.c
discard.h
disk-io.c btrfs: replace btrfs_set_free_space_cache_v1_active() with a cleanup helper 2026-10-16 19:10:45 +02:00
disk-io.h btrfs: add struct btrfs_eb_prealloc 2026-08-07 19:17:19 +02:00
export.c
export.h
extent_io.c btrfs: cleanup and rename submit_extent_folio() 2026-10-12 19:16:21 +02:00
extent_io.h btrfs: enable unlocked NOFAIL retry for eb allocations 2026-08-07 19:17:19 +02:00
extent_map.c btrfs: skip extent tree lock in the shrinker for inodes without extent maps 2026-10-12 19:16:19 +02:00
extent_map.h
extent-io-tree.c btrfs: fix typos and repeated words in comments 2026-10-12 19:16:20 +02:00
extent-io-tree.h
extent-tree.c btrfs: qgroup: make btrfs_record_squota_delta() return void 2026-10-12 19:16:24 +02:00
extent-tree.h
fiemap.c btrfs: use aligned range for locking in extent_fiemap() 2026-08-07 19:17:18 +02:00
fiemap.h
file-item.c btrfs: stop reading free space inodes from the commit root 2026-10-16 19:10:46 +02:00
file-item.h
file.c btrfs: abort transaction on failure to update inode for hole punching and reflinking 2026-09-17 19:39:41 +02:00
file.h
free-space-cache.c btrfs: remove the free space cache trimming ranges 2026-10-16 19:10:45 +02:00
free-space-cache.h btrfs: remove the free space cache trimming ranges 2026-10-16 19:10:45 +02:00
free-space-tree.c btrfs: clear free space tree creation state on rebuild failure 2026-09-17 19:32:11 +02:00
free-space-tree.h
fs.c btrfs: fix typos and repeated words in comments 2026-10-12 19:16:20 +02:00
fs.h btrfs: remove the SPACE_CACHE mount option flag 2026-10-16 19:10:45 +02:00
inode-item.c
inode-item.h
inode.c for-7.4-part2-tag 2026-10-25 16:15:22 -10:00
ioctl.c for-7.4-tag 2026-10-20 15:53:24 -10:00
ioctl.h fs: port ->fileattr_set() to pass const mnt_idmap 2026-09-23 09:19:49 +02:00
Kconfig btrfs: disable bs > ps support if no transparent hugepage support 2026-07-31 16:55:50 +02:00
locking.c
locking.h
lru_cache.c
lru_cache.h
lzo.c btrfs: lzo: reject inline extents without valid headers 2026-07-31 16:54:58 +02:00
Makefile
messages.c btrfs: avoid overhead when logging messages if fs state is clean 2026-10-12 19:16:23 +02:00
messages.h
misc.h block: rename bi_bvec_done 2026-08-06 06:47:33 -06:00
ordered-data.c btrfs: remove the free space inode ordered extent special cases 2026-10-16 19:10:45 +02:00
ordered-data.h btrfs: fix false IO failure after falling back to buffered write 2026-06-09 18:22:46 +02:00
orphan.c
orphan.h
print-tree.c btrfs: print-tree: print header owner as signed 2026-06-30 02:02:03 +02:00
print-tree.h
props.c btrfs: remove fs_info argument from btrfs_block_rsv_add() 2026-10-12 19:16:23 +02:00
props.h
qgroup.c btrfs: fix use-after-free on quota enable allocation failure 2026-10-12 23:59:21 +02:00
qgroup.h btrfs: qgroup: make btrfs_record_squota_delta() return void 2026-10-12 19:16:24 +02:00
raid-stripe-tree.c btrfs: return proper negative error code for update_raid_extent_item() 2026-09-02 22:19:29 +02:00
raid-stripe-tree.h btrfs: fix the possible bioc_list memory leak during error 2026-09-02 22:19:29 +02:00
raid56.c btrfs: raid56: do not verify the content if there is no data checksum 2026-10-12 19:16:24 +02:00
raid56.h btrfs: use kvmalloc() for stripe buffer of scrub_stripe 2026-08-07 19:17:16 +02:00
ref-verify.c
ref-verify.h
reflink.c btrfs: downgrade the reflink source inode lock for tree walking 2026-10-12 19:16:21 +02:00
reflink.h
relocation.c btrfs: remove the v1 space cache write path 2026-10-16 19:10:45 +02:00
relocation.h btrfs: move locking into btrfs_get_reloc_bg_bytenr() 2026-06-09 18:22:47 +02:00
root-tree.c btrfs: remove fs_info argument from btrfs_block_rsv_add() 2026-10-12 19:16:23 +02:00
root-tree.h
scrub.c btrfs: scrub: fix local_root reference leak in scrub_print_warning_inode() 2026-10-05 16:05:43 +02:00
scrub.h
send.c btrfs: fix typos and repeated words in comments 2026-10-12 19:16:20 +02:00
send.h
space-info.c btrfs: remove BTRFS_RESERVE_FLUSH_FREE_SPACE_INODE 2026-10-16 19:10:45 +02:00
space-info.h btrfs: remove BTRFS_RESERVE_FLUSH_FREE_SPACE_INODE 2026-10-16 19:10:45 +02:00
subpage.c btrfs: enable unlocked NOFAIL retry for eb allocations 2026-08-07 19:17:19 +02:00
subpage.h btrfs: enable unlocked NOFAIL retry for eb allocations 2026-08-07 19:17:19 +02:00
super.c btrfs: remove the SPACE_CACHE mount option flag 2026-10-16 19:10:45 +02:00
super.h
sysfs.c btrfs: use assign_bit() where applicable 2026-10-12 19:16:22 +02:00
sysfs.h
transaction.c btrfs: remove TRANS_JOIN_NOLOCK 2026-10-16 19:10:46 +02:00
transaction.h btrfs: remove the free space inode ordered extent special cases 2026-10-16 19:10:45 +02:00
tree-checker.c btrfs: add missing unlikely to a couple error checks during sys chunk array validation 2026-10-12 19:16:21 +02:00
tree-checker.h
tree-log.c btrfs: increment extent count once when logging extents during fast fsync 2026-10-12 19:16:21 +02:00
tree-log.h btrfs: use a named enum for the log mode in inode log functions 2026-06-08 15:53:34 +02:00
tree-mod-log.c btrfs: fix dangling nodes in tree-mod-log after error in btrfs_tree_mod_log_insert_root() 2026-10-12 19:16:22 +02:00
tree-mod-log.h
ulist.c
ulist.h
uuid-tree.c btrfs: prefer IS_ERR_OR_NULL() over manual NULL check 2026-04-07 18:56:02 +02:00
uuid-tree.h
verity.c fsverity: Set S_VERITY only after rollback is no longer possible 2026-10-28 10:53:43 -07:00
verity.h
volumes.c btrfs: use assign_bit() where applicable 2026-10-12 19:16:22 +02:00
volumes.h btrfs: remove unnecessary forward struct declarations in volumes.h 2026-10-12 19:16:24 +02:00
xattr.c vfs-7.4-rc1.idmap 2026-10-19 17:57:49 -10:00
xattr.h
zlib.c btrfs: use kvmalloc() to allocate compression workspace buffer for zlib and zstd 2026-10-12 19:16:20 +02:00
zoned.c btrfs: remove the SPACE_CACHE mount option flag 2026-10-16 19:10:45 +02:00
zoned.h
zstd.c btrfs: use kvmalloc() to allocate compression workspace buffer for zlib and zstd 2026-10-12 19:16:20 +02:00