Skip to content

Commit 4a9b165

Browse files
stephensmalleypcmoore
authored andcommitted
lsm: hold cred_guard_mutex for lsm_set_self_attr()
Just as proc_pid_attr_write() already does before calling the LSM hook. This only matters for SELinux and AppArmor which check whether the process is being ptraced and if so, whether to allow the transition. Cc: stable@vger.kernel.org Signed-off-by: Stephen Smalley <stephen.smalley.work@gmail.com> Acked-by: Casey Schaufler <casey@schaufler-ca.com> Signed-off-by: Paul Moore <paul@paul-moore.com>
1 parent 254f496 commit 4a9b165

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

security/lsm_syscalls.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,14 @@ u64 lsm_name_to_attr(const char *name)
5757
SYSCALL_DEFINE4(lsm_set_self_attr, unsigned int, attr, struct lsm_ctx __user *,
5858
ctx, u32, size, u32, flags)
5959
{
60-
return security_setselfattr(attr, ctx, size, flags);
60+
int rc;
61+
62+
rc = mutex_lock_interruptible(&current->signal->cred_guard_mutex);
63+
if (rc < 0)
64+
return rc;
65+
rc = security_setselfattr(attr, ctx, size, flags);
66+
mutex_unlock(&current->signal->cred_guard_mutex);
67+
return rc;
6168
}
6269

6370
/**

0 commit comments

Comments
 (0)