Skip to content

Commit

Permalink
SELinux: hold tasklist_lock and siglock while waking wait_chldexit
Browse files Browse the repository at this point in the history
SELinux has long been calling wake_up_interruptible() on
current->parent->signal->wait_chldexit without holding any locks.  It
appears that this operation should hold the tasklist_lock to dereference
current->parent and we should hold the siglock when waking up the
signal->wait_chldexit.

Signed-off-by: Eric Paris <eparis@redhat.com>
Signed-off-by: James Morris <jmorris@namei.org>
  • Loading branch information
Eric Paris authored and James Morris committed Nov 4, 2008
1 parent 8b6a5a3 commit 41d9f9c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions security/selinux/hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -2268,7 +2268,9 @@ static void selinux_bprm_post_apply_creds(struct linux_binprm *bprm)
struct rlimit *rlim, *initrlim;
struct itimerval itimer;
struct bprm_security_struct *bsec;
struct sighand_struct *psig;
int rc, i;
unsigned long flags;

tsec = current->security;
bsec = bprm->security;
Expand Down Expand Up @@ -2335,7 +2337,12 @@ static void selinux_bprm_post_apply_creds(struct linux_binprm *bprm)

/* Wake up the parent if it is waiting so that it can
recheck wait permission to the new task SID. */
read_lock_irq(&tasklist_lock);
psig = current->parent->sighand;
spin_lock_irqsave(&psig->siglock, flags);
wake_up_interruptible(&current->parent->signal->wait_chldexit);
spin_unlock_irqrestore(&psig->siglock, flags);
read_unlock_irq(&tasklist_lock);
}

/* superblock security operations */
Expand Down

0 comments on commit 41d9f9c

Please sign in to comment.