diff options
author | David Howells <dhowells@redhat.com> | 2005-06-24 01:00:53 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-06-24 03:05:18 -0400 |
commit | 8589b4e00e352f983259140f25a262d973be6bc5 (patch) | |
tree | d53c9b43ee0aaa2d7518a023c4b6373422117506 /security/keys/request_key.c | |
parent | 7888e7ff4ee579442128d7d12a9c9dbf2cf7de6a (diff) |
[PATCH] Keys: Use RCU to manage session keyring pointer
The attached patch uses RCU to manage the session keyring pointer in struct
signal_struct. This means that searching need not disable interrupts and get
a the sighand spinlock to access this pointer. Furthermore, by judicious use
of rcu_read_(un)lock(), this patch also avoids the need to take and put
refcounts on the session keyring itself, thus saving on even more atomic ops.
Signed-Off-By: David Howells <dhowells@redhat.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'security/keys/request_key.c')
-rw-r--r-- | security/keys/request_key.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/security/keys/request_key.c b/security/keys/request_key.c index 1919540f047d..54aa7b70e63b 100644 --- a/security/keys/request_key.c +++ b/security/keys/request_key.c | |||
@@ -175,13 +175,12 @@ static struct key *__request_key_construction(struct key_type *type, | |||
175 | key->expiry = now.tv_sec + key_negative_timeout; | 175 | key->expiry = now.tv_sec + key_negative_timeout; |
176 | 176 | ||
177 | if (current->signal->session_keyring) { | 177 | if (current->signal->session_keyring) { |
178 | unsigned long flags; | ||
179 | struct key *keyring; | 178 | struct key *keyring; |
180 | 179 | ||
181 | spin_lock_irqsave(¤t->sighand->siglock, flags); | 180 | rcu_read_lock(); |
182 | keyring = current->signal->session_keyring; | 181 | keyring = rcu_dereference(current->signal->session_keyring); |
183 | atomic_inc(&keyring->usage); | 182 | atomic_inc(&keyring->usage); |
184 | spin_unlock_irqrestore(¤t->sighand->siglock, flags); | 183 | rcu_read_unlock(); |
185 | 184 | ||
186 | key_link(keyring, key); | 185 | key_link(keyring, key); |
187 | key_put(keyring); | 186 | key_put(keyring); |