->getprocattr(): attribute name is const char *, TYVM...
authorAl Viro <viro@zeniv.linux.org.uk>
Mon, 31 Jan 2022 00:57:52 +0000 (19:57 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Thu, 1 Sep 2022 21:34:39 +0000 (17:34 -0400)
cast of ->d_name.name to char * is completely wrong - nothing is
allowed to modify its contents.

Reviewed-by: Christian Brauner (Microsoft) <brauner@kernel.org>
Acked-by: Paul Moore <paul@paul-moore.com>
Acked-by: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/proc/base.c
include/linux/lsm_hook_defs.h
include/linux/security.h
security/apparmor/lsm.c
security/security.c
security/selinux/hooks.c
security/smack/smack_lsm.c

index 93f7e3d971e4bbc758165ac09710945a50975af3..e347b8ce140ce16da9898c1280ced1c638509f95 100644 (file)
@@ -2728,7 +2728,7 @@ static ssize_t proc_pid_attr_read(struct file * file, char __user * buf,
                return -ESRCH;
 
        length = security_getprocattr(task, PROC_I(inode)->op.lsm,
-                                     (char*)file->f_path.dentry->d_name.name,
+                                     file->f_path.dentry->d_name.name,
                                      &p);
        put_task_struct(task);
        if (length > 0)
index 8064481730333deb7ac23e1d39541d138dc93b94..03360d27bedfa3bca9e06865a6a9759f75191e49 100644 (file)
@@ -253,7 +253,7 @@ LSM_HOOK(int, 0, sem_semop, struct kern_ipc_perm *perm, struct sembuf *sops,
 LSM_HOOK(int, 0, netlink_send, struct sock *sk, struct sk_buff *skb)
 LSM_HOOK(void, LSM_RET_VOID, d_instantiate, struct dentry *dentry,
         struct inode *inode)
-LSM_HOOK(int, -EINVAL, getprocattr, struct task_struct *p, char *name,
+LSM_HOOK(int, -EINVAL, getprocattr, struct task_struct *p, const char *name,
         char **value)
 LSM_HOOK(int, -EINVAL, setprocattr, const char *name, void *value, size_t size)
 LSM_HOOK(int, 0, ismaclabel, const char *name)
index 1bc362cb413f2ffa4e252d6a0dd75b60b452d0bc..93488c01d9bd3c23f8a23c440c123e75f0133d18 100644 (file)
@@ -461,7 +461,7 @@ int security_sem_semctl(struct kern_ipc_perm *sma, int cmd);
 int security_sem_semop(struct kern_ipc_perm *sma, struct sembuf *sops,
                        unsigned nsops, int alter);
 void security_d_instantiate(struct dentry *dentry, struct inode *inode);
-int security_getprocattr(struct task_struct *p, const char *lsm, char *name,
+int security_getprocattr(struct task_struct *p, const char *lsm, const char *name,
                         char **value);
 int security_setprocattr(const char *lsm, const char *name, void *value,
                         size_t size);
@@ -1301,7 +1301,7 @@ static inline void security_d_instantiate(struct dentry *dentry,
 { }
 
 static inline int security_getprocattr(struct task_struct *p, const char *lsm,
-                                      char *name, char **value)
+                                      const char *name, char **value)
 {
        return -EINVAL;
 }
index e29cade7b6627f2a697e8d1f64b6ede60b4159d3..f56070270c69db19350f868286dc43469a3d35ca 100644 (file)
@@ -614,7 +614,7 @@ static int apparmor_sb_pivotroot(const struct path *old_path,
        return error;
 }
 
-static int apparmor_getprocattr(struct task_struct *task, char *name,
+static int apparmor_getprocattr(struct task_struct *task, const char *name,
                                char **value)
 {
        int error = -ENOENT;
index 14d30fec8a0031d2a2ed32dbd4e61fe1966e1dfb..d8227531e2fd95c81433b40d76b2384d513f1ddb 100644 (file)
@@ -2057,8 +2057,8 @@ void security_d_instantiate(struct dentry *dentry, struct inode *inode)
 }
 EXPORT_SYMBOL(security_d_instantiate);
 
-int security_getprocattr(struct task_struct *p, const char *lsm, char *name,
-                               char **value)
+int security_getprocattr(struct task_struct *p, const char *lsm,
+                        const char *name, char **value)
 {
        struct security_hook_list *hp;
 
index 79573504783bb7f34f698ee9ef1b76c0f063c06a..c8168d19fb9627aa0e601b94055add82e530c1be 100644 (file)
@@ -6327,7 +6327,7 @@ static void selinux_d_instantiate(struct dentry *dentry, struct inode *inode)
 }
 
 static int selinux_getprocattr(struct task_struct *p,
-                              char *name, char **value)
+                              const char *name, char **value)
 {
        const struct task_security_struct *__tsec;
        u32 sid;
index 001831458fa2c895283c1b01e4ec77b58047e827..434b348d8fcd18c55797638a4808a255f932fd82 100644 (file)
@@ -3479,7 +3479,7 @@ static void smack_d_instantiate(struct dentry *opt_dentry, struct inode *inode)
  *
  * Returns the length of the smack label or an error code
  */
-static int smack_getprocattr(struct task_struct *p, char *name, char **value)
+static int smack_getprocattr(struct task_struct *p, const char *name, char **value)
 {
        struct smack_known *skp = smk_of_task_struct_obj(p);
        char *cp;