diff options
author | David Howells <dhowells@redhat.com> | 2010-09-10 04:59:46 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-09-10 10:30:00 -0400 |
commit | 9d1ac65a9698513d00e5608d93fca0c53f536c14 (patch) | |
tree | 859809638bdf52f56b6b3890bedefcc1bae89b32 /security/keys | |
parent | ff3cb3fec3c5bbb5110e652bbdd410bc99a47e9f (diff) |
KEYS: Fix RCU no-lock warning in keyctl_session_to_parent()
There's an protected access to the parent process's credentials in the middle
of keyctl_session_to_parent(). This results in the following RCU warning:
===================================================
[ INFO: suspicious rcu_dereference_check() usage. ]
---------------------------------------------------
security/keys/keyctl.c:1291 invoked rcu_dereference_check() without protection!
other info that might help us debug this:
rcu_scheduler_active = 1, debug_locks = 0
1 lock held by keyctl-session-/2137:
#0: (tasklist_lock){.+.+..}, at: [<ffffffff811ae2ec>] keyctl_session_to_parent+0x60/0x236
stack backtrace:
Pid: 2137, comm: keyctl-session- Not tainted 2.6.36-rc2-cachefs+ #1
Call Trace:
[<ffffffff8105606a>] lockdep_rcu_dereference+0xaa/0xb3
[<ffffffff811ae379>] keyctl_session_to_parent+0xed/0x236
[<ffffffff811af77e>] sys_keyctl+0xb4/0xb6
[<ffffffff81001eab>] system_call_fastpath+0x16/0x1b
The code should take the RCU read lock to make sure the parents credentials
don't go away, even though it's holding a spinlock and has IRQ disabled.
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'security/keys')
-rw-r--r-- | security/keys/keyctl.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c index b2b0998d6abd..3868c6700b58 100644 --- a/security/keys/keyctl.c +++ b/security/keys/keyctl.c | |||
@@ -1272,6 +1272,7 @@ long keyctl_session_to_parent(void) | |||
1272 | keyring_r = NULL; | 1272 | keyring_r = NULL; |
1273 | 1273 | ||
1274 | me = current; | 1274 | me = current; |
1275 | rcu_read_lock(); | ||
1275 | write_lock_irq(&tasklist_lock); | 1276 | write_lock_irq(&tasklist_lock); |
1276 | 1277 | ||
1277 | parent = me->real_parent; | 1278 | parent = me->real_parent; |
@@ -1319,6 +1320,7 @@ long keyctl_session_to_parent(void) | |||
1319 | set_ti_thread_flag(task_thread_info(parent), TIF_NOTIFY_RESUME); | 1320 | set_ti_thread_flag(task_thread_info(parent), TIF_NOTIFY_RESUME); |
1320 | 1321 | ||
1321 | write_unlock_irq(&tasklist_lock); | 1322 | write_unlock_irq(&tasklist_lock); |
1323 | rcu_read_unlock(); | ||
1322 | if (oldcred) | 1324 | if (oldcred) |
1323 | put_cred(oldcred); | 1325 | put_cred(oldcred); |
1324 | return 0; | 1326 | return 0; |
@@ -1327,6 +1329,7 @@ already_same: | |||
1327 | ret = 0; | 1329 | ret = 0; |
1328 | not_permitted: | 1330 | not_permitted: |
1329 | write_unlock_irq(&tasklist_lock); | 1331 | write_unlock_irq(&tasklist_lock); |
1332 | rcu_read_unlock(); | ||
1330 | put_cred(cred); | 1333 | put_cred(cred); |
1331 | return ret; | 1334 | return ret; |
1332 | 1335 | ||