Skip to content

Commit

Permalink
->getprocattr(): attribute name is const char *, TYVM...
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Al Viro committed Sep 1, 2022
1 parent 568035b commit c8e477c
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion fs/proc/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion include/linux/lsm_hook_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions include/linux/security.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion security/apparmor/lsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions security/security.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion security/selinux/hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion security/smack/smack_lsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c8e477c

Please sign in to comment.