Rename the inode_file_getattr and inode_file_setattr hooks to
path_file_getattr and path_file_setattr, as they take a struct path, and
rename security_inode_file_*() and the SELinux implementations
accordingly.

Update the BPF selftests and the strong definitions in
kernel/bpf/bpf_lsm_proto.c.

Signed-off-by: Cai Xinchen <[email protected]>
---
 fs/file_attr.c                |  4 ++--
 include/linux/lsm_hook_defs.h |  4 ++--
 include/linux/security.h      | 20 ++++++++++----------
 kernel/bpf/bpf_lsm_proto.c    | 16 ++++++++--------
 security/security.c           | 16 ++++++++--------
 security/selinux/hooks.c      | 16 ++++++++--------
 6 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/fs/file_attr.c b/fs/file_attr.c
index 846847e64ad3..3b8eb92feade 100644
--- a/fs/file_attr.c
+++ b/fs/file_attr.c
@@ -129,7 +129,7 @@ int vfs_fileattr_get(const struct path *path, struct 
file_kattr *fa,
        if (!inode->i_op->fileattr_get)
                return -ENOIOCTLCMD;
 
-       error = security_inode_file_getattr(path, fa, file);
+       error = security_path_file_getattr(path, fa, file);
        if (error)
                return error;
 
@@ -325,7 +325,7 @@ static int do_vfs_fileattr_set(const struct path *const 
path,
                err = fileattr_set_prepare(inode, &old_ma, fa);
                if (err)
                        goto out;
-               err = security_inode_file_setattr(path, fa, file);
+               err = security_path_file_setattr(path, fa, file);
                if (err)
                        goto out;
                err = inode->i_op->fileattr_set(idmap, dentry, fa);
diff --git a/include/linux/lsm_hook_defs.h b/include/linux/lsm_hook_defs.h
index 0db95ec9d1d1..2680972b2c50 100644
--- a/include/linux/lsm_hook_defs.h
+++ b/include/linux/lsm_hook_defs.h
@@ -180,9 +180,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 3dbdfe77d9c3..e625564ada1f 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,
@@ -1094,16 +1094,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/kernel/bpf/bpf_lsm_proto.c b/kernel/bpf/bpf_lsm_proto.c
index 1bc90fd53388..d359ca8ab3cd 100644
--- a/kernel/bpf/bpf_lsm_proto.c
+++ b/kernel/bpf/bpf_lsm_proto.c
@@ -94,20 +94,20 @@ noinline int bpf_lsm_path_removexattr(const struct 
mnt_idmap *idmap,
 }
 
 /*
- * 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
+ * Strong definitions of the path 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_file_setattr(const struct path *path,
-                                       struct file_kattr *fa,
-                                       struct file *file__nullable)
+noinline int bpf_lsm_path_file_setattr(const struct path *path,
+                                      struct file_kattr *fa,
+                                      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_file_getattr(const struct path *path,
+                                      struct file_kattr *fa,
+                                      struct file *file__nullable)
 {
        return 0;
 }
diff --git a/security/security.c b/security/security.c
index 95d3e890e841..314c7736f0dd 100644
--- a/security/security.c
+++ b/security/security.c
@@ -2189,7 +2189,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
@@ -2200,14 +2200,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
@@ -2218,10 +2218,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 e0f384bb7ca6..02fa9bbf7ea3 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -3573,16 +3573,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);
 }
@@ -7749,8 +7749,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


Reply via email to