[PATCH v3 -next 13/18] LSM: rename the inode fileattr hooks to path_file_* hooks
From: Cai Xinchen
Date: Tue Oct 27 2026 - 07:50:17 EST
The inode_file_getattr and inode_file_setattr hooks receive a struct
path, so rename them to path_file_getattr and path_file_setattr to
follow the path_* naming convention used for the other hooks that
take a struct path (path_chmod, path_chown, ...). Rename the
security_inode_file_getattr() and security_inode_file_setattr()
inline wrappers and the SELinux implementations
accordingly.
Signed-off-by: Cai Xinchen <caixinchen1@xxxxxxxxxx>
---
fs/file_attr.c | 4 ++--
include/linux/lsm_hook_defs.h | 4 ++--
include/linux/security.h | 20 ++++++++++----------
security/security.c | 16 ++++++++--------
security/selinux/hooks.c | 16 ++++++++--------
5 files changed, 30 insertions(+), 30 deletions(-)
diff --git a/fs/file_attr.c b/fs/file_attr.c
index 08b4cdbef9ff..093cb05ae3c4 100644
--- a/fs/file_attr.c
+++ b/fs/file_attr.c
@@ -112,7 +112,7 @@ int vfs_fileattr_get(const struct path *path, struct file_kattr *fa,
{
int error;
- error = security_inode_file_getattr(path, fa, file);
+ error = security_path_file_getattr(path, fa, file);
if (error)
return error;
@@ -315,7 +315,7 @@ static int do_vfs_fileattr_set(const struct path *const path,
* user-facing path.
*/
if (path) {
- err = security_inode_file_setattr(path, fa, file);
+ err = security_path_file_setattr(path, fa, file);
if (err)
goto out;
}
diff --git a/include/linux/lsm_hook_defs.h b/include/linux/lsm_hook_defs.h
index 7602a3074375..683c4d7a8024 100644
--- a/include/linux/lsm_hook_defs.h
+++ b/include/linux/lsm_hook_defs.h
@@ -169,9 +169,9 @@ LSM_HOOK(int, 0, path_removexattr, const struct mnt_idmap *idmap,
const struct path *path, const char *name, struct file *file)
LSM_HOOK(void, LSM_RET_VOID, inode_post_removexattr, struct dentry *dentry,
const char *name)
-LSM_HOOK(int, 0, inode_file_setattr, const struct path *path,
+LSM_HOOK(int, 0, path_file_setattr, const struct path *path,
struct file_kattr *fa, struct file *file)
-LSM_HOOK(int, 0, inode_file_getattr, const struct path *path,
+LSM_HOOK(int, 0, path_file_getattr, const struct path *path,
struct file_kattr *fa, struct file *file)
LSM_HOOK(int, 0, path_set_acl, const struct mnt_idmap *idmap,
const struct path *path, const char *acl_name,
diff --git a/include/linux/security.h b/include/linux/security.h
index 305b92c0494c..edba134db8f6 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -464,10 +464,10 @@ int security_path_removexattr(const struct mnt_idmap *idmap,
const struct path *path, const char *name,
struct file *file);
void security_inode_post_removexattr(struct dentry *dentry, const char *name);
-int security_inode_file_setattr(const struct path *path,
- struct file_kattr *fa, struct file *file);
-int security_inode_file_getattr(const struct path *path,
- struct file_kattr *fa, struct file *file);
+int security_path_file_setattr(const struct path *path,
+ struct file_kattr *fa, struct file *file);
+int security_path_file_getattr(const struct path *path,
+ struct file_kattr *fa, struct file *file);
int security_inode_need_killpriv(struct dentry *dentry);
int security_inode_killpriv(const struct mnt_idmap *idmap, struct dentry *dentry);
int security_inode_getsecurity(const struct mnt_idmap *idmap,
@@ -1093,16 +1093,16 @@ static inline void security_inode_post_removexattr(struct dentry *dentry,
const char *name)
{ }
-static inline int security_inode_file_setattr(const struct path *path,
- struct file_kattr *fa,
- struct file *file)
+static inline int security_path_file_setattr(const struct path *path,
+ struct file_kattr *fa,
+ struct file *file)
{
return 0;
}
-static inline int security_inode_file_getattr(const struct path *path,
- struct file_kattr *fa,
- struct file *file)
+static inline int security_path_file_getattr(const struct path *path,
+ struct file_kattr *fa,
+ struct file *file)
{
return 0;
}
diff --git a/security/security.c b/security/security.c
index 13778c83fd3a..919763c61994 100644
--- a/security/security.c
+++ b/security/security.c
@@ -2180,7 +2180,7 @@ void security_inode_post_removexattr(struct dentry *dentry, const char *name)
}
/**
- * security_inode_file_setattr() - check if setting fsxattr is allowed
+ * security_path_file_setattr() - check if setting fsxattr is allowed
* @path: file to set filesystem extended attributes on (the VFS makes no
* guarantees with regard to @path->mnt)
* @fa: extended attributes to set on the inode
@@ -2191,14 +2191,14 @@ void security_inode_post_removexattr(struct dentry *dentry, const char *name)
*
* Return: Returns 0 if permission is granted.
*/
-int security_inode_file_setattr(const struct path *path,
- struct file_kattr *fa, struct file *file)
+int security_path_file_setattr(const struct path *path,
+ struct file_kattr *fa, struct file *file)
{
- return call_int_hook(inode_file_setattr, path, fa, file);
+ return call_int_hook(path_file_setattr, path, fa, file);
}
/**
- * security_inode_file_getattr() - check if retrieving fsxattr is allowed
+ * security_path_file_getattr() - check if retrieving fsxattr is allowed
* @path: file to retrieve filesystem extended attributes from (the VFS makes no
* guarantees with regard to @path->mnt)
* @fa: extended attributes to get
@@ -2209,10 +2209,10 @@ int security_inode_file_setattr(const struct path *path,
*
* Return: Returns 0 if permission is granted.
*/
-int security_inode_file_getattr(const struct path *path,
- struct file_kattr *fa, struct file *file)
+int security_path_file_getattr(const struct path *path,
+ struct file_kattr *fa, struct file *file)
{
- return call_int_hook(inode_file_getattr, path, fa, file);
+ return call_int_hook(path_file_getattr, path, fa, file);
}
/**
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index e0aaaee537d1..8bafa530806e 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -3572,16 +3572,16 @@ static int selinux_path_removexattr(const struct mnt_idmap *idmap,
return -EACCES;
}
-static int selinux_inode_file_setattr(const struct path *path,
- struct file_kattr *fa,
- struct file *file)
+static int selinux_path_file_setattr(const struct path *path,
+ struct file_kattr *fa,
+ struct file *file)
{
return dentry_has_perm(current_cred(), path->dentry, FILE__SETATTR);
}
-static int selinux_inode_file_getattr(const struct path *path,
- struct file_kattr *fa,
- struct file *file)
+static int selinux_path_file_getattr(const struct path *path,
+ struct file_kattr *fa,
+ struct file *file)
{
return dentry_has_perm(current_cred(), path->dentry, FILE__GETATTR);
}
@@ -7743,8 +7743,8 @@ static struct security_hook_list selinux_hooks[] __ro_after_init = {
LSM_HOOK_INIT(path_getxattr, selinux_path_getxattr),
LSM_HOOK_INIT(path_listxattr, selinux_path_listxattr),
LSM_HOOK_INIT(path_removexattr, selinux_path_removexattr),
- LSM_HOOK_INIT(inode_file_getattr, selinux_inode_file_getattr),
- LSM_HOOK_INIT(inode_file_setattr, selinux_inode_file_setattr),
+ LSM_HOOK_INIT(path_file_getattr, selinux_path_file_getattr),
+ LSM_HOOK_INIT(path_file_setattr, selinux_path_file_setattr),
LSM_HOOK_INIT(path_set_acl, selinux_path_set_acl),
LSM_HOOK_INIT(path_get_acl, selinux_path_get_acl),
LSM_HOOK_INIT(path_remove_acl, selinux_path_remove_acl),
--
2.18.0.huawei.25