Rename the inode_{set,get,remove}_acl hooks to path_{set,get,remove}_acl, as they take a struct path, and rename security_inode_*_acl() and the SELinux, Smack, EVM and IMA implementations accordingly. The inode_post_set_acl and inode_post_remove_acl notification hooks still take a dentry and keep their names. Update the BPF selftests, the strong definitions in kernel/bpf/bpf_lsm_proto.c and the Smack audit function names. Signed-off-by: Cai Xinchen --- fs/posix_acl.c | 6 ++-- include/linux/lsm_hook_defs.h | 6 ++-- include/linux/security.h | 44 ++++++++++++------------ kernel/bpf/bpf_lsm_proto.c | 48 +++++++++++++-------------- security/integrity/evm/evm_main.c | 26 +++++++-------- security/integrity/ima/ima_appraise.c | 20 +++++------ security/security.c | 32 +++++++++--------- security/selinux/hooks.c | 26 +++++++-------- security/smack/smack_lsm.c | 32 +++++++++--------- 9 files changed, 120 insertions(+), 120 deletions(-) diff --git a/fs/posix_acl.c b/fs/posix_acl.c index 4de0ad023df8..39a1153eecae 100644 --- a/fs/posix_acl.c +++ b/fs/posix_acl.c @@ -1133,7 +1133,7 @@ int vfs_set_acl(const struct mnt_idmap *idmap, const struct path *path, if (error) goto out_inode_unlock; - error = security_inode_set_acl(idmap, path, acl_name, kacl, file); + error = security_path_set_acl(idmap, path, acl_name, kacl, file); if (error) goto out_inode_unlock; @@ -1195,7 +1195,7 @@ struct posix_acl *vfs_get_acl(const struct mnt_idmap *idmap, * The VFS has no restrictions on reading POSIX ACLs so calling * something like xattr_permission() isn't needed. Only LSMs get a say. */ - error = security_inode_get_acl(idmap, path, acl_name, file); + error = security_path_get_acl(idmap, path, acl_name, file); if (error) return ERR_PTR(error); @@ -1252,7 +1252,7 @@ int vfs_remove_acl(const struct mnt_idmap *idmap, const struct path *path, if (error) goto out_inode_unlock; - error = security_inode_remove_acl(idmap, path, acl_name, file); + error = security_path_remove_acl(idmap, path, acl_name, file); if (error) goto out_inode_unlock; diff --git a/include/linux/lsm_hook_defs.h b/include/linux/lsm_hook_defs.h index 3c43ec49bee8..0db95ec9d1d1 100644 --- a/include/linux/lsm_hook_defs.h +++ b/include/linux/lsm_hook_defs.h @@ -184,15 +184,15 @@ LSM_HOOK(int, 0, inode_file_setattr, const struct path *path, struct file_kattr *fa, struct file *file) LSM_HOOK(int, 0, inode_file_getattr, const struct path *path, struct file_kattr *fa, struct file *file) -LSM_HOOK(int, 0, inode_set_acl, const struct mnt_idmap *idmap, +LSM_HOOK(int, 0, path_set_acl, const struct mnt_idmap *idmap, const struct path *path, const char *acl_name, struct posix_acl *kacl, struct file *file) LSM_HOOK(void, LSM_RET_VOID, inode_post_set_acl, struct dentry *dentry, const char *acl_name, struct posix_acl *kacl) -LSM_HOOK(int, 0, inode_get_acl, const struct mnt_idmap *idmap, +LSM_HOOK(int, 0, path_get_acl, const struct mnt_idmap *idmap, const struct path *path, const char *acl_name, struct file *file) -LSM_HOOK(int, 0, inode_remove_acl, const struct mnt_idmap *idmap, +LSM_HOOK(int, 0, path_remove_acl, const struct mnt_idmap *idmap, const struct path *path, const char *acl_name, struct file *file) LSM_HOOK(void, LSM_RET_VOID, inode_post_remove_acl, const struct mnt_idmap *idmap, diff --git a/include/linux/security.h b/include/linux/security.h index 2784420d6c3d..3dbdfe77d9c3 100644 --- a/include/linux/security.h +++ b/include/linux/security.h @@ -440,17 +440,17 @@ int security_path_setxattr(const struct mnt_idmap *idmap, const struct path *path, const char *name, const void *value, size_t size, int flags, struct file *file); -int security_inode_set_acl(const struct mnt_idmap *idmap, - const struct path *path, const char *acl_name, - struct posix_acl *kacl, struct file *file); +int security_path_set_acl(const struct mnt_idmap *idmap, + const struct path *path, const char *acl_name, + struct posix_acl *kacl, struct file *file); void security_inode_post_set_acl(struct dentry *dentry, const char *acl_name, struct posix_acl *kacl); -int security_inode_get_acl(const struct mnt_idmap *idmap, - const struct path *path, const char *acl_name, - struct file *file); -int security_inode_remove_acl(const struct mnt_idmap *idmap, - const struct path *path, const char *acl_name, - struct file *file); +int security_path_get_acl(const struct mnt_idmap *idmap, + const struct path *path, const char *acl_name, + struct file *file); +int security_path_remove_acl(const struct mnt_idmap *idmap, + const struct path *path, const char *acl_name, + struct file *file); void security_inode_post_remove_acl(const struct mnt_idmap *idmap, struct dentry *dentry, const char *acl_name); @@ -1031,11 +1031,11 @@ static inline int security_path_setxattr(const struct mnt_idmap *idmap, return cap_inode_setxattr(path, name, value, size, flags, file); } -static inline int security_inode_set_acl(const struct mnt_idmap *idmap, - const struct path *path, - const char *acl_name, - struct posix_acl *kacl, - struct file *file) +static inline int security_path_set_acl(const struct mnt_idmap *idmap, + const struct path *path, + const char *acl_name, + struct posix_acl *kacl, + struct file *file) { return 0; } @@ -1045,18 +1045,18 @@ static inline void security_inode_post_set_acl(struct dentry *dentry, struct posix_acl *kacl) { } -static inline int security_inode_get_acl(const struct mnt_idmap *idmap, - const struct path *path, - const char *acl_name, - struct file *file) +static inline int security_path_get_acl(const struct mnt_idmap *idmap, + const struct path *path, + const char *acl_name, + struct file *file) { return 0; } -static inline int security_inode_remove_acl(const struct mnt_idmap *idmap, - const struct path *path, - const char *acl_name, - struct file *file) +static inline int security_path_remove_acl(const struct mnt_idmap *idmap, + const struct path *path, + const char *acl_name, + struct file *file) { return 0; } diff --git a/kernel/bpf/bpf_lsm_proto.c b/kernel/bpf/bpf_lsm_proto.c index c2d51e05a1db..1bc90fd53388 100644 --- a/kernel/bpf/bpf_lsm_proto.c +++ b/kernel/bpf/bpf_lsm_proto.c @@ -94,49 +94,49 @@ noinline int bpf_lsm_path_removexattr(const struct mnt_idmap *idmap, } /* - * Strong definitions of the inode POSIX ACL BPF LSM hooks. The file argument + * Strong definitions of the inode fileattr BPF LSM hooks. The file argument * is only set for file descriptor-based operations and is NULL for path-based * and in-kernel callers, so mark it as PTR_MAYBE_NULL. */ -noinline int bpf_lsm_inode_set_acl(const struct mnt_idmap *idmap, - const struct path *path, - const char *acl_name, struct posix_acl *kacl, - struct file *file__nullable) -{ - return 0; -} - -noinline int bpf_lsm_inode_get_acl(const struct mnt_idmap *idmap, - const struct path *path, - const char *acl_name, - struct file *file__nullable) +noinline int bpf_lsm_inode_file_setattr(const struct path *path, + struct file_kattr *fa, + struct file *file__nullable) { return 0; } -noinline int bpf_lsm_inode_remove_acl(const struct mnt_idmap *idmap, - const struct path *path, - const char *acl_name, - struct file *file__nullable) +noinline int bpf_lsm_inode_file_getattr(const struct path *path, + struct file_kattr *fa, + struct file *file__nullable) { return 0; } /* - * Strong definitions of the inode fileattr BPF LSM hooks. The file argument + * Strong definitions of the path POSIX ACL BPF LSM hooks. The file argument * is only set for file descriptor-based operations and is NULL for path-based * and in-kernel callers, so mark it as PTR_MAYBE_NULL. */ -noinline int bpf_lsm_inode_file_setattr(const struct path *path, - struct file_kattr *fa, - struct file *file__nullable) +noinline int bpf_lsm_path_set_acl(const struct mnt_idmap *idmap, + const struct path *path, + const char *acl_name, struct posix_acl *kacl, + struct file *file__nullable) { return 0; } -noinline int bpf_lsm_inode_file_getattr(const struct path *path, - struct file_kattr *fa, - struct file *file__nullable) +noinline int bpf_lsm_path_get_acl(const struct mnt_idmap *idmap, + const struct path *path, + const char *acl_name, + struct file *file__nullable) +{ + return 0; +} + +noinline int bpf_lsm_path_remove_acl(const struct mnt_idmap *idmap, + const struct path *path, + const char *acl_name, + struct file *file__nullable) { return 0; } diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c index 64119591c900..2cdf765d51dd 100644 --- a/security/integrity/evm/evm_main.c +++ b/security/integrity/evm/evm_main.c @@ -8,7 +8,7 @@ * * File: evm_main.c * implements evm_path_setxattr, evm_inode_post_setxattr, - * evm_path_removexattr, evm_verifyxattr, and evm_inode_set_acl. + * evm_path_removexattr, evm_verifyxattr, and evm_path_set_acl. */ #define pr_fmt(fmt) "EVM: "fmt @@ -709,7 +709,7 @@ static inline int evm_inode_set_acl_change(const struct mnt_idmap *idmap, #endif /** - * evm_inode_set_acl - protect the EVM extended attribute from posix acls + * evm_path_set_acl - protect the EVM extended attribute from posix acls * @idmap: idmap of the mount * @path: pointer to the affected object * @acl_name: name of the posix acl @@ -722,10 +722,10 @@ static inline int evm_inode_set_acl_change(const struct mnt_idmap *idmap, * * Return: zero on success, -EPERM on failure. */ -static int evm_inode_set_acl(const struct mnt_idmap *idmap, - const struct path *path, - const char *acl_name, struct posix_acl *kacl, - struct file *file) +static int evm_path_set_acl(const struct mnt_idmap *idmap, + const struct path *path, + const char *acl_name, struct posix_acl *kacl, + struct file *file) { enum integrity_status evm_status; struct dentry *dentry = path->dentry; @@ -766,7 +766,7 @@ static int evm_inode_set_acl(const struct mnt_idmap *idmap, } /** - * evm_inode_remove_acl - Protect the EVM extended attribute from posix acls + * evm_path_remove_acl - Protect the EVM extended attribute from posix acls * @idmap: idmap of the mount * @path: pointer to the affected object * @acl_name: name of the posix acl @@ -778,11 +778,11 @@ static int evm_inode_set_acl(const struct mnt_idmap *idmap, * * Return: zero on success, -EPERM on failure. */ -static int evm_inode_remove_acl(const struct mnt_idmap *idmap, - const struct path *path, - const char *acl_name, struct file *file) +static int evm_path_remove_acl(const struct mnt_idmap *idmap, + const struct path *path, + const char *acl_name, struct file *file) { - return evm_inode_set_acl(idmap, path, acl_name, NULL, file); + return evm_path_set_acl(idmap, path, acl_name, NULL, file); } static void evm_reset_status(struct inode *inode) @@ -1237,9 +1237,9 @@ static struct security_hook_list evm_hooks[] __ro_after_init = { LSM_HOOK_INIT(inode_copy_up_xattr, evm_inode_copy_up_xattr), LSM_HOOK_INIT(path_setxattr, evm_path_setxattr), LSM_HOOK_INIT(inode_post_setxattr, evm_inode_post_setxattr), - LSM_HOOK_INIT(inode_set_acl, evm_inode_set_acl), + LSM_HOOK_INIT(path_set_acl, evm_path_set_acl), LSM_HOOK_INIT(inode_post_set_acl, evm_inode_post_set_acl), - LSM_HOOK_INIT(inode_remove_acl, evm_inode_remove_acl), + LSM_HOOK_INIT(path_remove_acl, evm_path_remove_acl), LSM_HOOK_INIT(inode_post_remove_acl, evm_inode_post_remove_acl), LSM_HOOK_INIT(path_removexattr, evm_path_removexattr), LSM_HOOK_INIT(inode_post_removexattr, evm_inode_post_removexattr), diff --git a/security/integrity/ima/ima_appraise.c b/security/integrity/ima/ima_appraise.c index 991982c97726..bad0a597cc29 100644 --- a/security/integrity/ima/ima_appraise.c +++ b/security/integrity/ima/ima_appraise.c @@ -795,10 +795,10 @@ static int ima_path_setxattr(const struct mnt_idmap *idmap, return result; } -static int ima_inode_set_acl(const struct mnt_idmap *idmap, - const struct path *path, - const char *acl_name, struct posix_acl *kacl, - struct file *file) +static int ima_path_set_acl(const struct mnt_idmap *idmap, + const struct path *path, + const char *acl_name, struct posix_acl *kacl, + struct file *file) { if (evm_revalidate_status(acl_name)) ima_reset_appraise_flags(d_backing_inode(path->dentry), -1); @@ -823,19 +823,19 @@ static int ima_path_removexattr(const struct mnt_idmap *idmap, return result; } -static int ima_inode_remove_acl(const struct mnt_idmap *idmap, - const struct path *path, - const char *acl_name, struct file *file) +static int ima_path_remove_acl(const struct mnt_idmap *idmap, + const struct path *path, + const char *acl_name, struct file *file) { - return ima_inode_set_acl(idmap, path, acl_name, NULL, file); + return ima_path_set_acl(idmap, path, acl_name, NULL, file); } static struct security_hook_list ima_appraise_hooks[] __ro_after_init = { LSM_HOOK_INIT(inode_post_setattr, ima_inode_post_setattr), LSM_HOOK_INIT(path_setxattr, ima_path_setxattr), - LSM_HOOK_INIT(inode_set_acl, ima_inode_set_acl), + LSM_HOOK_INIT(path_set_acl, ima_path_set_acl), LSM_HOOK_INIT(path_removexattr, ima_path_removexattr), - LSM_HOOK_INIT(inode_remove_acl, ima_inode_remove_acl), + LSM_HOOK_INIT(path_remove_acl, ima_path_remove_acl), }; void __init init_ima_appraise_lsm(const struct lsm_id *lsmid) diff --git a/security/security.c b/security/security.c index 470cff4ac24d..95d3e890e841 100644 --- a/security/security.c +++ b/security/security.c @@ -1972,7 +1972,7 @@ int security_path_setxattr(const struct mnt_idmap *idmap, } /** - * security_inode_set_acl() - Check if setting posix acls is allowed + * security_path_set_acl() - Check if setting posix acls is allowed * @idmap: idmap of the mount * @path: the object the posix acls are set on (the VFS makes no guarantees * with regard to @path->mnt) @@ -1986,14 +1986,14 @@ int security_path_setxattr(const struct mnt_idmap *idmap, * * Return: Returns 0 if permission is granted. */ -int security_inode_set_acl(const struct mnt_idmap *idmap, - const struct path *path, const char *acl_name, - struct posix_acl *kacl, struct file *file) +int security_path_set_acl(const struct mnt_idmap *idmap, + const struct path *path, const char *acl_name, + struct posix_acl *kacl, struct file *file) { if (unlikely(IS_PRIVATE(d_backing_inode(path->dentry)))) return 0; - return call_int_hook(inode_set_acl, idmap, path, acl_name, kacl, - file); + return call_int_hook(path_set_acl, idmap, path, acl_name, kacl, + file); } /** @@ -2014,7 +2014,7 @@ void security_inode_post_set_acl(struct dentry *dentry, const char *acl_name, } /** - * security_inode_get_acl() - Check if reading posix acls is allowed + * security_path_get_acl() - Check if reading posix acls is allowed * @idmap: idmap of the mount * @path: the object the posix acls are retrieved from (the VFS makes no * guarantees with regard to @path->mnt) @@ -2027,17 +2027,17 @@ void security_inode_post_set_acl(struct dentry *dentry, const char *acl_name, * * Return: Returns 0 if permission is granted. */ -int security_inode_get_acl(const struct mnt_idmap *idmap, - const struct path *path, const char *acl_name, - struct file *file) +int security_path_get_acl(const struct mnt_idmap *idmap, + const struct path *path, const char *acl_name, + struct file *file) { if (unlikely(IS_PRIVATE(d_backing_inode(path->dentry)))) return 0; - return call_int_hook(inode_get_acl, idmap, path, acl_name, file); + return call_int_hook(path_get_acl, idmap, path, acl_name, file); } /** - * security_inode_remove_acl() - Check if removing a posix acl is allowed + * security_path_remove_acl() - Check if removing a posix acl is allowed * @idmap: idmap of the mount * @path: the object the posix acl is removed from (the VFS makes no * guarantees with regard to @path->mnt) @@ -2050,13 +2050,13 @@ int security_inode_get_acl(const struct mnt_idmap *idmap, * * Return: Returns 0 if permission is granted. */ -int security_inode_remove_acl(const struct mnt_idmap *idmap, - const struct path *path, const char *acl_name, - struct file *file) +int security_path_remove_acl(const struct mnt_idmap *idmap, + const struct path *path, const char *acl_name, + struct file *file) { if (unlikely(IS_PRIVATE(d_backing_inode(path->dentry)))) return 0; - return call_int_hook(inode_remove_acl, idmap, path, acl_name, file); + return call_int_hook(path_remove_acl, idmap, path, acl_name, file); } /** diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index a49c97498619..e0f384bb7ca6 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -3478,24 +3478,24 @@ static int selinux_path_setxattr(const struct mnt_idmap *idmap, &ad); } -static int selinux_inode_set_acl(const struct mnt_idmap *idmap, - const struct path *path, - const char *acl_name, struct posix_acl *kacl, - struct file *file) +static int selinux_path_set_acl(const struct mnt_idmap *idmap, + const struct path *path, + const char *acl_name, struct posix_acl *kacl, + struct file *file) { return dentry_has_perm(current_cred(), path->dentry, FILE__SETATTR); } -static int selinux_inode_get_acl(const struct mnt_idmap *idmap, - const struct path *path, - const char *acl_name, struct file *file) +static int selinux_path_get_acl(const struct mnt_idmap *idmap, + const struct path *path, + const char *acl_name, struct file *file) { return dentry_has_perm(current_cred(), path->dentry, FILE__GETATTR); } -static int selinux_inode_remove_acl(const struct mnt_idmap *idmap, - const struct path *path, - const char *acl_name, struct file *file) +static int selinux_path_remove_acl(const struct mnt_idmap *idmap, + const struct path *path, + const char *acl_name, struct file *file) { return dentry_has_perm(current_cred(), path->dentry, FILE__SETATTR); } @@ -7751,9 +7751,9 @@ static struct security_hook_list selinux_hooks[] __ro_after_init = { 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(inode_set_acl, selinux_inode_set_acl), - LSM_HOOK_INIT(inode_get_acl, selinux_inode_get_acl), - LSM_HOOK_INIT(inode_remove_acl, selinux_inode_remove_acl), + 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), LSM_HOOK_INIT(inode_getsecurity, selinux_inode_getsecurity), LSM_HOOK_INIT(inode_setsecurity, selinux_inode_setsecurity), LSM_HOOK_INIT(inode_listsecurity, selinux_inode_listsecurity), diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c index 2e4250cc31a2..f301757ab2b7 100644 --- a/security/smack/smack_lsm.c +++ b/security/smack/smack_lsm.c @@ -1552,7 +1552,7 @@ static int smack_path_removexattr(const struct mnt_idmap *idmap, } /** - * smack_inode_set_acl - Smack check for setting posix acls + * smack_path_set_acl - Smack check for setting posix acls * @idmap: idmap of the mnt this request came from * @path: the object * @acl_name: name of the posix acl @@ -1561,10 +1561,10 @@ static int smack_path_removexattr(const struct mnt_idmap *idmap, * * Returns 0 if access is permitted, an error code otherwise */ -static int smack_inode_set_acl(const struct mnt_idmap *idmap, - const struct path *path, - const char *acl_name, struct posix_acl *kacl, - struct file *file) +static int smack_path_set_acl(const struct mnt_idmap *idmap, + const struct path *path, + const char *acl_name, struct posix_acl *kacl, + struct file *file) { struct smk_audit_info ad; int rc; @@ -1579,7 +1579,7 @@ static int smack_inode_set_acl(const struct mnt_idmap *idmap, } /** - * smack_inode_get_acl - Smack check for getting posix acls + * smack_path_get_acl - Smack check for getting posix acls * @idmap: idmap of the mnt this request came from * @path: the object * @acl_name: name of the posix acl @@ -1587,9 +1587,9 @@ static int smack_inode_set_acl(const struct mnt_idmap *idmap, * * Returns 0 if access is permitted, an error code otherwise */ -static int smack_inode_get_acl(const struct mnt_idmap *idmap, - const struct path *path, - const char *acl_name, struct file *file) +static int smack_path_get_acl(const struct mnt_idmap *idmap, + const struct path *path, + const char *acl_name, struct file *file) { struct smk_audit_info ad; int rc; @@ -1604,7 +1604,7 @@ static int smack_inode_get_acl(const struct mnt_idmap *idmap, } /** - * smack_inode_remove_acl - Smack check for getting posix acls + * smack_path_remove_acl - Smack check for removing posix acls * @idmap: idmap of the mnt this request came from * @path: the object * @acl_name: name of the posix acl @@ -1612,9 +1612,9 @@ static int smack_inode_get_acl(const struct mnt_idmap *idmap, * * Returns 0 if access is permitted, an error code otherwise */ -static int smack_inode_remove_acl(const struct mnt_idmap *idmap, - const struct path *path, - const char *acl_name, struct file *file) +static int smack_path_remove_acl(const struct mnt_idmap *idmap, + const struct path *path, + const char *acl_name, struct file *file) { struct smk_audit_info ad; int rc; @@ -5213,9 +5213,9 @@ static struct security_hook_list smack_hooks[] __ro_after_init = { LSM_HOOK_INIT(inode_post_setxattr, smack_inode_post_setxattr), LSM_HOOK_INIT(path_getxattr, smack_path_getxattr), LSM_HOOK_INIT(path_removexattr, smack_path_removexattr), - LSM_HOOK_INIT(inode_set_acl, smack_inode_set_acl), - LSM_HOOK_INIT(inode_get_acl, smack_inode_get_acl), - LSM_HOOK_INIT(inode_remove_acl, smack_inode_remove_acl), + LSM_HOOK_INIT(path_set_acl, smack_path_set_acl), + LSM_HOOK_INIT(path_get_acl, smack_path_get_acl), + LSM_HOOK_INIT(path_remove_acl, smack_path_remove_acl), LSM_HOOK_INIT(inode_getsecurity, smack_inode_getsecurity), LSM_HOOK_INIT(inode_setsecurity, smack_inode_setsecurity), LSM_HOOK_INIT(inode_listsecurity, smack_inode_listsecurity), -- 2.18.0.huawei.25