Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 25526
b: refs/heads/master
c: 1a26feb
h: refs/heads/master
v: v3
  • Loading branch information
David Howells authored and Linus Torvalds committed Apr 11, 2006
1 parent 71f34e4 commit 29f6e06
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 22 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 25a80759c5c237f0ecf57eb11fdd4efb21079c88
refs/heads/master: 1a26feb9622f1b1bc5e4f5f60f65557b73c38cbf
41 changes: 20 additions & 21 deletions trunk/security/keys/process_keys.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,12 @@ int install_thread_keyring(struct task_struct *tsk)
*/
int install_process_keyring(struct task_struct *tsk)
{
unsigned long flags;
struct key *keyring;
char buf[20];
int ret;

might_sleep();

if (!tsk->signal->process_keyring) {
sprintf(buf, "_pid.%u", tsk->tgid);

Expand All @@ -183,12 +184,12 @@ int install_process_keyring(struct task_struct *tsk)
}

/* attach keyring */
spin_lock_irqsave(&tsk->sighand->siglock, flags);
spin_lock_irq(&tsk->sighand->siglock);
if (!tsk->signal->process_keyring) {
tsk->signal->process_keyring = keyring;
keyring = NULL;
}
spin_unlock_irqrestore(&tsk->sighand->siglock, flags);
spin_unlock_irq(&tsk->sighand->siglock);

key_put(keyring);
}
Expand All @@ -207,38 +208,37 @@ int install_process_keyring(struct task_struct *tsk)
static int install_session_keyring(struct task_struct *tsk,
struct key *keyring)
{
unsigned long flags;
struct key *old;
char buf[20];
int ret;

might_sleep();

/* create an empty session keyring */
if (!keyring) {
sprintf(buf, "_ses.%u", tsk->tgid);

keyring = keyring_alloc(buf, tsk->uid, tsk->gid, 1, NULL);
if (IS_ERR(keyring)) {
ret = PTR_ERR(keyring);
goto error;
}
if (IS_ERR(keyring))
return PTR_ERR(keyring);
}
else {
atomic_inc(&keyring->usage);
}

/* install the keyring */
spin_lock_irqsave(&tsk->sighand->siglock, flags);
old = rcu_dereference(tsk->signal->session_keyring);
spin_lock_irq(&tsk->sighand->siglock);
old = tsk->signal->session_keyring;
rcu_assign_pointer(tsk->signal->session_keyring, keyring);
spin_unlock_irqrestore(&tsk->sighand->siglock, flags);
spin_unlock_irq(&tsk->sighand->siglock);

ret = 0;
/* we're using RCU on the pointer, but there's no point synchronising
* on it if it didn't previously point to anything */
if (old) {
synchronize_rcu();
key_put(old);
}

/* we're using RCU on the pointer */
synchronize_rcu();
key_put(old);
error:
return ret;
return 0;

} /* end install_session_keyring() */

Expand Down Expand Up @@ -311,7 +311,6 @@ void exit_keys(struct task_struct *tsk)
*/
int exec_keys(struct task_struct *tsk)
{
unsigned long flags;
struct key *old;

/* newly exec'd tasks don't get a thread keyring */
Expand All @@ -323,10 +322,10 @@ int exec_keys(struct task_struct *tsk)
key_put(old);

/* discard the process keyring from a newly exec'd task */
spin_lock_irqsave(&tsk->sighand->siglock, flags);
spin_lock_irq(&tsk->sighand->siglock);
old = tsk->signal->process_keyring;
tsk->signal->process_keyring = NULL;
spin_unlock_irqrestore(&tsk->sighand->siglock, flags);
spin_unlock_irq(&tsk->sighand->siglock);

key_put(old);

Expand Down

0 comments on commit 29f6e06

Please sign in to comment.