Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge patch series "Add traces and file attributes for fs-verity"

Andrey Albershteyn <aalbersh@kernel.org> says:

This two small patches grew from fs-verity XFS patchset. I think they're
self-contained improvements which could go without XFS implementation.

* patches from https://patch.msgid.link/20260126115658.27656-1-aalbersh@kernel.org:
fsverity: add tracepoints
fs: add FS_XFLAG_VERITY for fs-verity files

Link: https://patch.msgid.link/20260126115658.27656-1-aalbersh@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>

+187 -3
+16
Documentation/filesystems/fsverity.rst
··· 341 341 FS_IOC_GETFLAGS and FS_IOC_MEASURE_VERITY because it doesn't require 342 342 opening the file, and opening verity files can be expensive. 343 343 344 + FS_IOC_FSGETXATTR 345 + ----------------- 346 + 347 + Since Linux v7.0, the FS_IOC_FSGETXATTR ioctl sets FS_XFLAG_VERITY (0x00020000) 348 + in the returned flags when the file has verity enabled. Note that this attribute 349 + cannot be set with FS_IOC_FSSETXATTR as enabling verity requires input 350 + parameters. See FS_IOC_ENABLE_VERITY. 351 + 352 + file_getattr 353 + ------------ 354 + 355 + Since Linux v7.0, the file_getattr() syscall sets FS_XFLAG_VERITY (0x00020000) 356 + in the returned flags when the file has verity enabled. Note that this attribute 357 + cannot be set with file_setattr() as enabling verity requires input parameters. 358 + See FS_IOC_ENABLE_VERITY. 359 + 344 360 .. _accessing_verity_files: 345 361 346 362 Accessing verity files
+1
MAINTAINERS
··· 10311 10311 F: Documentation/filesystems/fsverity.rst 10312 10312 F: fs/verity/ 10313 10313 F: include/linux/fsverity.h 10314 + F: include/trace/events/fsverity.h 10314 10315 F: include/uapi/linux/fsverity.h 10315 10316 10316 10317 FT260 FTDI USB-HID TO I2C BRIDGE DRIVER
+4
fs/file_attr.c
··· 36 36 fa->flags |= FS_DAX_FL; 37 37 if (fa->fsx_xflags & FS_XFLAG_PROJINHERIT) 38 38 fa->flags |= FS_PROJINHERIT_FL; 39 + if (fa->fsx_xflags & FS_XFLAG_VERITY) 40 + fa->flags |= FS_VERITY_FL; 39 41 } 40 42 EXPORT_SYMBOL(fileattr_fill_xflags); 41 43 ··· 68 66 fa->fsx_xflags |= FS_XFLAG_DAX; 69 67 if (fa->flags & FS_PROJINHERIT_FL) 70 68 fa->fsx_xflags |= FS_XFLAG_PROJINHERIT; 69 + if (fa->flags & FS_VERITY_FL) 70 + fa->fsx_xflags |= FS_XFLAG_VERITY; 71 71 } 72 72 EXPORT_SYMBOL(fileattr_fill_flags); 73 73
+4
fs/verity/enable.c
··· 222 222 if (err) 223 223 goto out; 224 224 225 + trace_fsverity_enable(inode, &params); 226 + 225 227 /* 226 228 * Start enabling verity on this file, serialized by the inode lock. 227 229 * Fail if verity is already enabled or is already being enabled. ··· 265 263 err = PTR_ERR(vi); 266 264 goto rollback; 267 265 } 266 + 267 + trace_fsverity_tree_done(inode, vi, &params); 268 268 269 269 /* 270 270 * Tell the filesystem to finish enabling verity on the file.
+2
fs/verity/fsverity_private.h
··· 161 161 162 162 void __init fsverity_init_workqueue(void); 163 163 164 + #include <trace/events/fsverity.h> 165 + 164 166 #endif /* _FSVERITY_PRIVATE_H */
+1
fs/verity/init.c
··· 5 5 * Copyright 2019 Google LLC 6 6 */ 7 7 8 + #define CREATE_TRACE_POINTS 8 9 #include "fsverity_private.h" 9 10 10 11 #include <linux/ratelimit.h>
+9
fs/verity/verify.c
··· 135 135 /* Byte offset of the wanted hash relative to @addr */ 136 136 unsigned int hoffset; 137 137 } hblocks[FS_VERITY_MAX_LEVELS]; 138 + 139 + trace_fsverity_verify_data_block(inode, params, data_pos); 140 + 138 141 /* 139 142 * The index of the previous level's block within that level; also the 140 143 * index of that block's hash within the current level. ··· 217 214 want_hash = _want_hash; 218 215 kunmap_local(haddr); 219 216 put_page(hpage); 217 + trace_fsverity_merkle_hit(inode, data_pos, hblock_idx, 218 + level, 219 + hoffset >> params->log_digestsize); 220 220 goto descend; 221 221 } 222 222 hblocks[level].page = hpage; ··· 237 231 const void *haddr = hblocks[level - 1].addr; 238 232 unsigned long hblock_idx = hblocks[level - 1].index; 239 233 unsigned int hoffset = hblocks[level - 1].hoffset; 234 + 235 + trace_fsverity_verify_merkle_block(inode, hblock_idx, 236 + level, hoffset >> params->log_digestsize); 240 237 241 238 fsverity_hash_block(params, haddr, real_hash); 242 239 if (memcmp(want_hash, real_hash, hsize) != 0)
+3 -3
include/linux/fileattr.h
··· 7 7 #define FS_COMMON_FL \ 8 8 (FS_SYNC_FL | FS_IMMUTABLE_FL | FS_APPEND_FL | \ 9 9 FS_NODUMP_FL | FS_NOATIME_FL | FS_DAX_FL | \ 10 - FS_PROJINHERIT_FL) 10 + FS_PROJINHERIT_FL | FS_VERITY_FL) 11 11 12 12 #define FS_XFLAG_COMMON \ 13 13 (FS_XFLAG_SYNC | FS_XFLAG_IMMUTABLE | FS_XFLAG_APPEND | \ 14 14 FS_XFLAG_NODUMP | FS_XFLAG_NOATIME | FS_XFLAG_DAX | \ 15 - FS_XFLAG_PROJINHERIT) 15 + FS_XFLAG_PROJINHERIT | FS_XFLAG_VERITY) 16 16 17 17 /* Read-only inode flags */ 18 18 #define FS_XFLAG_RDONLY_MASK \ 19 - (FS_XFLAG_PREALLOC | FS_XFLAG_HASATTR) 19 + (FS_XFLAG_PREALLOC | FS_XFLAG_HASATTR | FS_XFLAG_VERITY) 20 20 21 21 /* Flags to indicate valid value of fsx_ fields */ 22 22 #define FS_XFLAG_VALUES_MASK \
+146
include/trace/events/fsverity.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #undef TRACE_SYSTEM 3 + #define TRACE_SYSTEM fsverity 4 + 5 + #if !defined(_TRACE_FSVERITY_H) || defined(TRACE_HEADER_MULTI_READ) 6 + #define _TRACE_FSVERITY_H 7 + 8 + #include <linux/tracepoint.h> 9 + 10 + struct fsverity_descriptor; 11 + struct merkle_tree_params; 12 + struct fsverity_info; 13 + 14 + TRACE_EVENT(fsverity_enable, 15 + TP_PROTO(const struct inode *inode, 16 + const struct merkle_tree_params *params), 17 + TP_ARGS(inode, params), 18 + TP_STRUCT__entry( 19 + __field(ino_t, ino) 20 + __field(u64, data_size) 21 + __field(u64, tree_size) 22 + __field(unsigned int, merkle_block) 23 + __field(unsigned int, num_levels) 24 + ), 25 + TP_fast_assign( 26 + __entry->ino = inode->i_ino; 27 + __entry->data_size = i_size_read(inode); 28 + __entry->tree_size = params->tree_size; 29 + __entry->merkle_block = params->block_size; 30 + __entry->num_levels = params->num_levels; 31 + ), 32 + TP_printk("ino %lu data_size %llu tree_size %llu merkle_block %u levels %u", 33 + (unsigned long) __entry->ino, 34 + __entry->data_size, 35 + __entry->tree_size, 36 + __entry->merkle_block, 37 + __entry->num_levels) 38 + ); 39 + 40 + TRACE_EVENT(fsverity_tree_done, 41 + TP_PROTO(const struct inode *inode, const struct fsverity_info *vi, 42 + const struct merkle_tree_params *params), 43 + TP_ARGS(inode, vi, params), 44 + TP_STRUCT__entry( 45 + __field(ino_t, ino) 46 + __field(u64, data_size) 47 + __field(u64, tree_size) 48 + __field(unsigned int, merkle_block) 49 + __field(unsigned int, levels) 50 + __dynamic_array(u8, root_hash, params->digest_size) 51 + __dynamic_array(u8, file_digest, params->digest_size) 52 + ), 53 + TP_fast_assign( 54 + __entry->ino = inode->i_ino; 55 + __entry->data_size = i_size_read(inode); 56 + __entry->tree_size = params->tree_size; 57 + __entry->merkle_block = params->block_size; 58 + __entry->levels = params->num_levels; 59 + memcpy(__get_dynamic_array(root_hash), vi->root_hash, __get_dynamic_array_len(root_hash)); 60 + memcpy(__get_dynamic_array(file_digest), vi->file_digest, __get_dynamic_array_len(file_digest)); 61 + ), 62 + TP_printk("ino %lu data_size %llu tree_size %lld merkle_block %u levels %u root_hash %s digest %s", 63 + (unsigned long) __entry->ino, 64 + __entry->data_size, 65 + __entry->tree_size, 66 + __entry->merkle_block, 67 + __entry->levels, 68 + __print_hex_str(__get_dynamic_array(root_hash), __get_dynamic_array_len(root_hash)), 69 + __print_hex_str(__get_dynamic_array(file_digest), __get_dynamic_array_len(file_digest))) 70 + ); 71 + 72 + TRACE_EVENT(fsverity_verify_data_block, 73 + TP_PROTO(const struct inode *inode, 74 + const struct merkle_tree_params *params, 75 + u64 data_pos), 76 + TP_ARGS(inode, params, data_pos), 77 + TP_STRUCT__entry( 78 + __field(ino_t, ino) 79 + __field(u64, data_pos) 80 + __field(unsigned int, merkle_block) 81 + ), 82 + TP_fast_assign( 83 + __entry->ino = inode->i_ino; 84 + __entry->data_pos = data_pos; 85 + __entry->merkle_block = params->block_size; 86 + ), 87 + TP_printk("ino %lu data_pos %llu merkle_block %u", 88 + (unsigned long) __entry->ino, 89 + __entry->data_pos, 90 + __entry->merkle_block) 91 + ); 92 + 93 + TRACE_EVENT(fsverity_merkle_hit, 94 + TP_PROTO(const struct inode *inode, u64 data_pos, 95 + unsigned long hblock_idx, unsigned int level, 96 + unsigned int hidx), 97 + TP_ARGS(inode, data_pos, hblock_idx, level, hidx), 98 + TP_STRUCT__entry( 99 + __field(ino_t, ino) 100 + __field(u64, data_pos) 101 + __field(unsigned long, hblock_idx) 102 + __field(unsigned int, level) 103 + __field(unsigned int, hidx) 104 + ), 105 + TP_fast_assign( 106 + __entry->ino = inode->i_ino; 107 + __entry->data_pos = data_pos; 108 + __entry->hblock_idx = hblock_idx; 109 + __entry->level = level; 110 + __entry->hidx = hidx; 111 + ), 112 + TP_printk("ino %lu data_pos %llu hblock_idx %lu level %u hidx %u", 113 + (unsigned long) __entry->ino, 114 + __entry->data_pos, 115 + __entry->hblock_idx, 116 + __entry->level, 117 + __entry->hidx) 118 + ); 119 + 120 + TRACE_EVENT(fsverity_verify_merkle_block, 121 + TP_PROTO(const struct inode *inode, unsigned long hblock_idx, 122 + unsigned int level, unsigned int hidx), 123 + TP_ARGS(inode, hblock_idx, level, hidx), 124 + TP_STRUCT__entry( 125 + __field(ino_t, ino) 126 + __field(unsigned long, hblock_idx) 127 + __field(unsigned int, level) 128 + __field(unsigned int, hidx) 129 + ), 130 + TP_fast_assign( 131 + __entry->ino = inode->i_ino; 132 + __entry->hblock_idx = hblock_idx; 133 + __entry->level = level; 134 + __entry->hidx = hidx; 135 + ), 136 + TP_printk("ino %lu hblock_idx %lu level %u hidx %u", 137 + (unsigned long) __entry->ino, 138 + __entry->hblock_idx, 139 + __entry->level, 140 + __entry->hidx) 141 + ); 142 + 143 + #endif /* _TRACE_FSVERITY_H */ 144 + 145 + /* This part must be outside protection */ 146 + #include <trace/define_trace.h>
+1
include/uapi/linux/fs.h
··· 253 253 #define FS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */ 254 254 #define FS_XFLAG_DAX 0x00008000 /* use DAX for IO */ 255 255 #define FS_XFLAG_COWEXTSIZE 0x00010000 /* CoW extent size allocator hint */ 256 + #define FS_XFLAG_VERITY 0x00020000 /* fs-verity enabled */ 256 257 #define FS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */ 257 258 258 259 /* the read-only stuff doesn't really belong here, but any other place is