[PATCH 7/9] fuse_trace: let the kernel handle KILL_SUID/KILL_SGID for iomap filesystems

Darrick J. Wong
2025-09-16T00:37:53Z

Add tracepoints for the previous patch.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
fs/fuse/fuse_trace.h | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++
fs/fuse/dir.c | 5 ++++
2 files changed, 63 insertions(+)

diff --git a/fs/fuse/fuse_trace.h b/fs/fuse/fuse_trace.h
index 2aff78a30503ee..1f900580b14937 100644
--- a/fs/fuse/fuse_trace.h
+++ b/fs/fuse/fuse_trace.h
@@ -205,6 +205,64 @@ DEFINE_EVENT(fuse_fileattr_class, name, \
DEFINE_FUSE_FILEATTR_EVENT(fuse_fileattr_update_inode);
DEFINE_FUSE_FILEATTR_EVENT(fuse_fileattr_init);

+TRACE_EVENT(fuse_setattr_fill,
+ TP_PROTO(const struct inode *inode,
+ const struct fuse_setattr_in *inarg),
+ TP_ARGS(inode, inarg),
+
+ TP_STRUCT__entry(
+ FUSE_INODE_FIELDS
+ __field(umode_t, mode)
+ __field(uint32_t, valid)
+ __field(umode_t, new_mode)
+ __field(uint64_t, new_size)
+ ),
+
+ TP_fast_assign(
+ FUSE_INODE_ASSIGN(inode, fi, fm);
+ __entry->mode = inode->i_mode;
+ __entry->valid = inarg->valid;
+ __entry->new_mode = inarg->mode;
+ __entry->new_size = inarg->size;
+ ),
+
+ TP_printk(FUSE_INODE_FMT " mode 0%o valid 0x%x new_mode 0%o new_size 0x%llx",
+ FUSE_INODE_PRINTK_ARGS,
+ __entry->mode,
+ __entry->valid,
+ __entry->new_mode,
+ __entry->new_size)
+);
+
+TRACE_EVENT(fuse_setattr,
+ TP_PROTO(const struct inode *inode,
+ const struct iattr *inarg),
+ TP_ARGS(inode, inarg),
+
+ TP_STRUCT__entry(
+ FUSE_INODE_FIELDS
+ __field(umode_t, mode)
+ __field(uint32_t, valid)
+ __field(umode_t, new_mode)
+ __field(uint64_t, new_size)
+ ),
+
+ TP_fast_assign(
+ FUSE_INODE_ASSIGN(inode, fi, fm);
+ __entry->mode = inode->i_mode;
+ __entry->valid = inarg->ia_valid;
+ __entry->new_mode = inarg->ia_mode;
+ __entry->new_size = inarg->ia_size;
+ ),
+
+ TP_printk(FUSE_INODE_FMT " mode 0%o valid 0x%x new_mode 0%o new_size 0x%llx",
+ FUSE_INODE_PRINTK_ARGS,
+ __entry->mode,
+ __entry->valid,
+ __entry->new_mode,
+ __entry->new_size)
+);
+
#ifdef CONFIG_FUSE_BACKING
#define FUSE_BACKING_FLAG_STRINGS \
{ FUSE_BACKING_TYPE_PASSTHROUGH, "pass" }, \
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 2e1837b2363e83..58106f49395697 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -7,6 +7,7 @@
*/

#include "fuse_i.h"
+#include "fuse_trace.h"

#include <linux/pagemap.h>
#include <linux/file.h>
@@ -2002,6 +2003,8 @@ static void fuse_setattr_fill(struct fuse_conn *fc, struct fuse_args *args,
struct fuse_setattr_in *inarg_p,
struct fuse_attr_out *outarg_p)
{
+ trace_fuse_setattr_fill(inode, inarg_p);
+
args->opcode = FUSE_SETATTR;
args->nodeid = get_node_id(inode);
args->in_numargs = 1;
@@ -2277,6 +2280,8 @@ static int fuse_setattr(struct mnt_idmap *idmap, struct dentry *entry,
if (!fuse_allow_current_process(get_fuse_conn(inode)))
return -EACCES;

+ trace_fuse_setattr(inode, attr);
+
if (!is_iomap &&
(attr->ia_valid & (ATTR_KILL_SUID | ATTR_KILL_SGID))) {
attr->ia_valid &= ~(ATTR_KILL_SUID | ATTR_KILL_SGID |