The inode_setattr hook receives a struct path, so rename it to path_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_setattr() inline wrapper to security_path_setattr() and the SELinux, Smack, EVM and Landlock implementations accordingly.
Assisted-by: opencode: glm-5.3 Signed-off-by: Cai Xinchen <[email protected]> --- fs/attr.c | 4 ++-- fs/bpf_fs_kfuncs.c | 2 +- fs/exfat/file.c | 2 +- fs/fat/file.c | 2 +- include/linux/lsm_hook_defs.h | 2 +- include/linux/security.h | 4 ++-- kernel/bpf/bpf_lsm.c | 2 +- security/integrity/evm/evm_main.c | 6 +++--- security/landlock/fs.c | 4 ++-- security/security.c | 8 ++++---- security/selinux/hooks.c | 4 ++-- security/smack/smack_lsm.c | 6 +++--- 12 files changed, 23 insertions(+), 23 deletions(-) diff --git a/fs/attr.c b/fs/attr.c index 3a05e50d9c51..c8bf69e60971 100644 --- a/fs/attr.c +++ b/fs/attr.c @@ -518,7 +518,7 @@ static int do_notify_change(const struct path *const path, * filesystem, were already checked on the user-facing path. */ if (path) { - error = security_inode_setattr(path, attr); + error = security_path_setattr(path, attr); if (error) return error; } @@ -555,7 +555,7 @@ static int do_notify_change(const struct path *const path, * @attr: new attributes * @delegated_inode: returns inode, if the inode is delegated * - * Like notify_change(), but no security_inode_setattr() hook is called: + * Like notify_change(), but no security_path_setattr() hook is called: * this is the variant to use for internal forwards, where the LSM * checks were already performed on the user-facing path. * diff --git a/fs/bpf_fs_kfuncs.c b/fs/bpf_fs_kfuncs.c index 35ccd98a4de6..6500d8419bc1 100644 --- a/fs/bpf_fs_kfuncs.c +++ b/fs/bpf_fs_kfuncs.c @@ -568,7 +568,7 @@ BTF_ID(func, bpf_lsm_inode_post_setattr) BTF_ID(func, bpf_lsm_inode_post_setxattr) BTF_ID(func, bpf_lsm_inode_removexattr) BTF_ID(func, bpf_lsm_inode_rmdir) -BTF_ID(func, bpf_lsm_inode_setattr) +BTF_ID(func, bpf_lsm_path_setattr) BTF_ID(func, bpf_lsm_inode_setxattr) BTF_ID(func, bpf_lsm_inode_unlink) BTF_SET_END(d_inode_locked_hooks) diff --git a/fs/exfat/file.c b/fs/exfat/file.c index 0d431c0b595b..51ed20e27429 100644 --- a/fs/exfat/file.c +++ b/fs/exfat/file.c @@ -551,7 +551,7 @@ static int exfat_ioctl_set_attributes(struct file *file, u32 __user *user_attr) * out the RO attribute for checking by the security * module, just because it maps to a file mode. */ - err = security_inode_setattr(&file->f_path, &ia); + err = security_path_setattr(&file->f_path, &ia); if (err) goto out_unlock_inode; diff --git a/fs/fat/file.c b/fs/fat/file.c index 4f8dbca28667..5178561906dd 100644 --- a/fs/fat/file.c +++ b/fs/fat/file.c @@ -92,7 +92,7 @@ static int fat_ioctl_set_attributes(struct file *file, u32 __user *user_attr) * out the RO attribute for checking by the security * module, just because it maps to a file mode. */ - err = security_inode_setattr(&file->f_path, &ia); + err = security_path_setattr(&file->f_path, &ia); if (err) goto out_unlock_inode; diff --git a/include/linux/lsm_hook_defs.h b/include/linux/lsm_hook_defs.h index ea1df85b5fd4..b0dd9f4a6a38 100644 --- a/include/linux/lsm_hook_defs.h +++ b/include/linux/lsm_hook_defs.h @@ -142,7 +142,7 @@ LSM_HOOK(int, 0, inode_follow_link, struct dentry *dentry, struct inode *inode, bool rcu) LSM_HOOK(int, 0, inode_permission, const struct mnt_idmap *idmap, struct inode *inode, int mask) -LSM_HOOK(int, 0, inode_setattr, const struct path *path, +LSM_HOOK(int, 0, path_setattr, const struct path *path, struct iattr *attr) LSM_HOOK(void, LSM_RET_VOID, inode_post_setattr, const struct mnt_idmap *idmap, struct dentry *dentry, int ia_valid) diff --git a/include/linux/security.h b/include/linux/security.h index 630a19a63291..340eb2d0c1a2 100644 --- a/include/linux/security.h +++ b/include/linux/security.h @@ -428,7 +428,7 @@ int security_inode_follow_link(struct dentry *dentry, struct inode *inode, bool rcu); int security_inode_permission(const struct mnt_idmap *idmap, struct inode *inode, int mask); -int security_inode_setattr(const struct path *path, struct iattr *attr); +int security_path_setattr(const struct path *path, struct iattr *attr); void security_inode_post_setattr(const struct mnt_idmap *idmap, struct dentry *dentry, int ia_valid); int security_path_getattr(const struct path *path); @@ -996,7 +996,7 @@ static inline int security_inode_permission(const struct mnt_idmap *idmap, return 0; } -static inline int security_inode_setattr(const struct path *path, +static inline int security_path_setattr(const struct path *path, struct iattr *attr) { return 0; diff --git a/kernel/bpf/bpf_lsm.c b/kernel/bpf/bpf_lsm.c index 293f849879e2..32f84356933e 100644 --- a/kernel/bpf/bpf_lsm.c +++ b/kernel/bpf/bpf_lsm.c @@ -345,7 +345,7 @@ BTF_ID(func, bpf_lsm_inode_readlink) BTF_ID(func, bpf_lsm_inode_removexattr) BTF_ID(func, bpf_lsm_inode_rename) BTF_ID(func, bpf_lsm_inode_rmdir) -BTF_ID(func, bpf_lsm_inode_setattr) +BTF_ID(func, bpf_lsm_path_setattr) BTF_ID(func, bpf_lsm_inode_setxattr) BTF_ID(func, bpf_lsm_inode_symlink) BTF_ID(func, bpf_lsm_inode_unlink) diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c index 0d8d82536151..a44776e5f1a7 100644 --- a/security/integrity/evm/evm_main.c +++ b/security/integrity/evm/evm_main.c @@ -951,14 +951,14 @@ static int evm_attr_change(const struct mnt_idmap *idmap, } /** - * evm_inode_setattr - prevent updating an invalid EVM extended attribute + * evm_path_setattr - prevent updating an invalid EVM extended attribute * @path: pointer to the affected object * @attr: iattr structure containing the new file attributes * * Permit update of file attributes when files have a valid EVM signature, * except in the case of them having an immutable portable signature. */ -static int evm_inode_setattr(const struct path *path, +static int evm_path_setattr(const struct path *path, struct iattr *attr) { unsigned int ia_valid = attr->ia_valid; @@ -1199,7 +1199,7 @@ static int __init init_evm(void) } static struct security_hook_list evm_hooks[] __ro_after_init = { - LSM_HOOK_INIT(inode_setattr, evm_inode_setattr), + LSM_HOOK_INIT(path_setattr, evm_path_setattr), LSM_HOOK_INIT(inode_post_setattr, evm_inode_post_setattr), LSM_HOOK_INIT(inode_copy_up_xattr, evm_inode_copy_up_xattr), LSM_HOOK_INIT(inode_setxattr, evm_inode_setxattr), diff --git a/security/landlock/fs.c b/security/landlock/fs.c index 439a6159e24a..0ec923c9cbd9 100644 --- a/security/landlock/fs.c +++ b/security/landlock/fs.c @@ -1691,7 +1691,7 @@ static int hook_inode_file_getattr(const struct path *const path, LANDLOCK_ACCESS_FS_READ_METADATA); } -static int hook_inode_setattr(const struct path *const path, +static int hook_path_setattr(const struct path *const path, struct iattr *const attr) { unsigned int ia_valid = attr->ia_valid; @@ -2217,7 +2217,7 @@ static struct security_hook_list landlock_hooks[] __ro_after_init = { 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(inode_setattr, hook_inode_setattr), + LSM_HOOK_INIT(path_setattr, hook_path_setattr), LSM_HOOK_INIT(inode_file_setattr, hook_inode_file_setattr), LSM_HOOK_INIT(inode_setxattr, hook_inode_setxattr), LSM_HOOK_INIT(inode_getxattr, hook_inode_getxattr), diff --git a/security/security.c b/security/security.c index c7cb96db7299..f008f127b6f2 100644 --- a/security/security.c +++ b/security/security.c @@ -1890,7 +1890,7 @@ int security_inode_permission(const struct mnt_idmap *idmap, struct inode *inode } /** - * security_inode_setattr() - Check if setting file attributes is allowed + * security_path_setattr() - Check if setting file attributes is allowed * @path: file * @attr: new attributes * @@ -1901,13 +1901,13 @@ int security_inode_permission(const struct mnt_idmap *idmap, struct inode *inode * * Return: Returns 0 if permission is granted. */ -int security_inode_setattr(const struct path *path, struct iattr *attr) +int security_path_setattr(const struct path *path, struct iattr *attr) { if (unlikely(IS_PRIVATE(d_backing_inode(path->dentry)))) return 0; - return call_int_hook(inode_setattr, path, attr); + return call_int_hook(path_setattr, path, attr); } -EXPORT_SYMBOL_GPL(security_inode_setattr); +EXPORT_SYMBOL_GPL(security_path_setattr); /** * security_inode_post_setattr() - Update the inode after a setattr operation diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 93e3d9223e34..44c7fe660bdb 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -3346,7 +3346,7 @@ static int selinux_inode_permission(const struct mnt_idmap *idmap, return rc; } -static int selinux_inode_setattr(const struct path *path, +static int selinux_path_setattr(const struct path *path, struct iattr *iattr) { const struct cred *cred = current_cred(); @@ -7755,7 +7755,7 @@ static struct security_hook_list selinux_hooks[] __ro_after_init = { LSM_HOOK_INIT(inode_readlink, selinux_inode_readlink), LSM_HOOK_INIT(inode_follow_link, selinux_inode_follow_link), LSM_HOOK_INIT(inode_permission, selinux_inode_permission), - LSM_HOOK_INIT(inode_setattr, selinux_inode_setattr), + LSM_HOOK_INIT(path_setattr, selinux_path_setattr), LSM_HOOK_INIT(path_getattr, selinux_path_getattr), LSM_HOOK_INIT(inode_xattr_skipcap, selinux_inode_xattr_skipcap), LSM_HOOK_INIT(inode_setxattr, selinux_inode_setxattr), diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c index 43b9877d6a00..2cf786ee3752 100644 --- a/security/smack/smack_lsm.c +++ b/security/smack/smack_lsm.c @@ -1265,14 +1265,14 @@ static int smack_inode_permission(const struct mnt_idmap *idmap, struct inode *i } /** - * smack_inode_setattr - Smack check for setting attributes + * smack_path_setattr - Smack check for setting attributes * @idmap: idmap of the mount * @dentry: the object * @iattr: for the force flag * * Returns 0 if access is permitted, an error code otherwise */ -static int smack_inode_setattr(const struct path *path, +static int smack_path_setattr(const struct path *path, struct iattr *iattr) { struct smk_audit_info ad; @@ -5178,7 +5178,7 @@ static struct security_hook_list smack_hooks[] __ro_after_init = { LSM_HOOK_INIT(inode_rmdir, smack_inode_rmdir), LSM_HOOK_INIT(inode_rename, smack_inode_rename), LSM_HOOK_INIT(inode_permission, smack_inode_permission), - LSM_HOOK_INIT(inode_setattr, smack_inode_setattr), + LSM_HOOK_INIT(path_setattr, smack_path_setattr), LSM_HOOK_INIT(path_getattr, smack_path_getattr), LSM_HOOK_INIT(inode_xattr_skipcap, smack_inode_xattr_skipcap), LSM_HOOK_INIT(inode_setxattr, smack_inode_setxattr), -- 2.18.0.huawei.25
