proc,security: move restriction on writing /proc/pid/attr nodes to proc
Processes can only alter their own security attributes via /proc/pid/attr nodes. This is presently enforced by each individual security module and is also imposed by the Linux credentials implementation, which only allows a task to alter its own credentials. Move the check enforcing this restriction from the individual security modules to proc_pid_attr_write() before calling the security hook, and drop the unnecessary task argument to the security hook since it can only ever be the current task. Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov> Acked-by: Casey Schaufler <casey@schaufler-ca.com> Acked-by: John Johansen <john.johansen@canonical.com> Signed-off-by: Paul Moore <paul@paul-moore.com>
This commit is contained in:

committed by
Paul Moore

parent
be0554c9bf
commit
b21507e272
@@ -5862,8 +5862,7 @@ bad:
|
||||
return error;
|
||||
}
|
||||
|
||||
static int selinux_setprocattr(struct task_struct *p,
|
||||
char *name, void *value, size_t size)
|
||||
static int selinux_setprocattr(const char *name, void *value, size_t size)
|
||||
{
|
||||
struct task_security_struct *tsec;
|
||||
struct cred *new;
|
||||
@@ -5871,16 +5870,6 @@ static int selinux_setprocattr(struct task_struct *p,
|
||||
int error;
|
||||
char *str = value;
|
||||
|
||||
if (current != p) {
|
||||
/*
|
||||
* A task may only alter its own credentials.
|
||||
* SELinux has always enforced this restriction,
|
||||
* and it is now mandated by the Linux credentials
|
||||
* infrastructure; see Documentation/security/credentials.txt.
|
||||
*/
|
||||
return -EACCES;
|
||||
}
|
||||
|
||||
/*
|
||||
* Basic control over ability to set these attributes at all.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user