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 and Landlock implementations accordingly.
Assisted-by: opencode: glm-5.3 Signed-off-by: Cai Xinchen <[email protected]> --- fs/file_attr.c | 4 ++-- include/linux/lsm_hook_defs.h | 4 ++-- include/linux/security.h | 8 ++++---- security/landlock/fs.c | 8 ++++---- security/security.c | 12 ++++++------ security/selinux/hooks.c | 8 ++++---- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/fs/file_attr.c b/fs/file_attr.c index 1e555aebd815..ea56843450f7 100644 --- a/fs/file_attr.c +++ b/fs/file_attr.c @@ -110,7 +110,7 @@ int vfs_fileattr_get(const struct path *path, struct file_kattr *fa) { int error; - error = security_inode_file_getattr(path, fa); + error = security_path_file_getattr(path, fa); if (error) return error; @@ -312,7 +312,7 @@ static int do_vfs_fileattr_set(const struct path *const path, * user-facing path. */ if (path) { - err = security_inode_file_setattr(path, fa); + err = security_path_file_setattr(path, fa); if (err) goto out; } diff --git a/include/linux/lsm_hook_defs.h b/include/linux/lsm_hook_defs.h index 867a43e5c771..da490923cdcd 100644 --- a/include/linux/lsm_hook_defs.h +++ b/include/linux/lsm_hook_defs.h @@ -158,9 +158,9 @@ LSM_HOOK(int, 0, path_removexattr, const struct path *path, const char *name) 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) -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) LSM_HOOK(int, 0, path_set_acl, const struct path *path, const char *acl_name, struct posix_acl *kacl) diff --git a/include/linux/security.h b/include/linux/security.h index d695f963fae0..4f1c26c75093 100644 --- a/include/linux/security.h +++ b/include/linux/security.h @@ -451,9 +451,9 @@ int security_path_listxattr(const struct path *path); int security_path_removexattr(const struct path *path, const char *name); void security_inode_post_removexattr(struct dentry *dentry, const char *name); -int security_inode_file_setattr(const struct path *path, +int security_path_file_setattr(const struct path *path, struct file_kattr *fa); -int security_inode_file_getattr(const struct path *path, +int security_path_file_getattr(const struct path *path, struct file_kattr *fa); int security_inode_need_killpriv(struct dentry *dentry); int security_inode_killpriv(const struct mnt_idmap *idmap, struct dentry *dentry); @@ -1072,13 +1072,13 @@ static inline void security_inode_post_removexattr(struct dentry *dentry, const char *name) { } -static inline int security_inode_file_setattr(const struct path *path, +static inline int security_path_file_setattr(const struct path *path, struct file_kattr *fa) { return 0; } -static inline int security_inode_file_getattr(const struct path *path, +static inline int security_path_file_getattr(const struct path *path, struct file_kattr *fa) { return 0; diff --git a/security/landlock/fs.c b/security/landlock/fs.c index 380a80247b6d..1bca7558ea9f 100644 --- a/security/landlock/fs.c +++ b/security/landlock/fs.c @@ -1684,7 +1684,7 @@ static int hook_path_getattr(const struct path *const path) LANDLOCK_ACCESS_FS_READ_METADATA); } -static int hook_inode_file_getattr(const struct path *const path, +static int hook_path_file_getattr(const struct path *const path, struct file_kattr *const fa) { return current_check_access_path(path, @@ -1726,7 +1726,7 @@ static int hook_path_setattr(const struct path *const path, LANDLOCK_ACCESS_FS_WRITE_METADATA); } -static int hook_inode_file_setattr(const struct path *const path, +static int hook_path_file_setattr(const struct path *const path, struct file_kattr *const fa) { /* @@ -2216,9 +2216,9 @@ static struct security_hook_list landlock_hooks[] __ro_after_init = { LSM_HOOK_INIT(path_rmdir, hook_path_rmdir), LSM_HOOK_INIT(path_truncate, hook_path_truncate), LSM_HOOK_INIT(path_getattr, hook_path_getattr), - LSM_HOOK_INIT(inode_file_getattr, hook_inode_file_getattr), + LSM_HOOK_INIT(path_file_getattr, hook_path_file_getattr), LSM_HOOK_INIT(path_setattr, hook_path_setattr), - LSM_HOOK_INIT(inode_file_setattr, hook_inode_file_setattr), + LSM_HOOK_INIT(path_file_setattr, hook_path_file_setattr), LSM_HOOK_INIT(path_setxattr, hook_path_setxattr), LSM_HOOK_INIT(path_getxattr, hook_path_getxattr), LSM_HOOK_INIT(path_listxattr, hook_path_listxattr), diff --git a/security/security.c b/security/security.c index 0a8ffc97d679..f04a7bb311ea 100644 --- a/security/security.c +++ b/security/security.c @@ -2177,7 +2177,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 * @fa: extended attributes to set on the inode * @@ -2186,13 +2186,13 @@ 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) +int security_path_file_setattr(const struct path *path, struct file_kattr *fa) { - return call_int_hook(inode_file_setattr, path, fa); + return call_int_hook(path_file_setattr, path, fa); } /** - * 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 * @fa: extended attributes to get * @@ -2201,9 +2201,9 @@ int security_inode_file_setattr(const struct path *path, struct file_kattr *fa) * * Return: Returns 0 if permission is granted. */ -int security_inode_file_getattr(const struct path *path, struct file_kattr *fa) +int security_path_file_getattr(const struct path *path, struct file_kattr *fa) { - return call_int_hook(inode_file_getattr, path, fa); + return call_int_hook(path_file_getattr, path, fa); } /** diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index e1d3dc4f063f..ee0d6c12de37 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -3593,13 +3593,13 @@ static int selinux_path_removexattr(const struct path *path, return -EACCES; } -static int selinux_inode_file_setattr(const struct path *path, +static int selinux_path_file_setattr(const struct path *path, struct file_kattr *fa) { return dentry_has_perm(current_cred(), path->dentry, FILE__SETATTR); } -static int selinux_inode_file_getattr(const struct path *path, +static int selinux_path_file_getattr(const struct path *path, struct file_kattr *fa) { return dentry_has_perm(current_cred(), path->dentry, FILE__GETATTR); @@ -7763,8 +7763,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
