linux/security/keys
Oleg Nesterov 413cd3d9ab keys: change keyctl_session_to_parent() to use task_work_add()
Change keyctl_session_to_parent() to use task_work_add() and move
key_replace_session_keyring() logic into task_work->func().

Note that we do task_work_cancel() before task_work_add() to ensure that
only one work can be pending at any time.  This is important, we must not
allow user-space to abuse the parent's ->task_works list.

The callback, replace_session_keyring(), checks PF_EXITING.  I guess this
is not really needed but looks better.

As a side effect, this fixes the (unlikely) race.  The callers of
key_replace_session_keyring() and keyctl_session_to_parent() lack the
necessary barriers, the parent can miss the request.

Now we can remove task_struct->replacement_session_keyring and related
code.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: David Howells <dhowells@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Richard Kuo <rkuo@codeaurora.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Alexander Gordeev <agordeev@redhat.com>
Cc: Chris Zankel <chris@zankel.net>
Cc: David Smith <dsmith@redhat.com>
Cc: "Frank Ch. Eigler" <fche@redhat.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Larry Woodman <lwoodman@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2012-05-23 22:11:23 -04:00
..
encrypted-keys encrypted-keys: fix rcu and sparse messages 2012-01-18 10:41:30 +11:00
compat.c KEYS: Add invalidation support 2012-05-11 10:56:56 +01:00
gc.c KEYS: Add invalidation support 2012-05-11 10:56:56 +01:00
internal.h keys: change keyctl_session_to_parent() to use task_work_add() 2012-05-23 22:11:23 -04:00
Kconfig KEYS: Move the key config into security/keys/Kconfig 2012-05-11 10:56:56 +01:00
key.c Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace 2012-05-23 17:42:39 -07:00
keyctl.c keys: change keyctl_session_to_parent() to use task_work_add() 2012-05-23 22:11:23 -04:00
keyring.c KEYS: Add invalidation support 2012-05-11 10:56:56 +01:00
Makefile KEYS: Reorganise keys Makefile 2012-05-11 10:56:56 +01:00
permission.c Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace 2012-05-23 17:42:39 -07:00
proc.c KEYS: Add invalidation support 2012-05-11 10:56:56 +01:00
process_keys.c keys: change keyctl_session_to_parent() to use task_work_add() 2012-05-23 22:11:23 -04:00
request_key_auth.c KEYS: Don't return EAGAIN to keyctl_assume_authority() 2011-06-14 15:03:29 +10:00
request_key.c usermodehelper: kill umh_wait, renumber UMH_* constants 2012-03-23 16:58:41 -07:00
sysctl.c sysctl: Drop & in front of every proc_handler. 2009-11-18 08:37:40 -08:00
trusted.c keys: fix trusted/encrypted keys sparse rcu_assign_pointer messages 2012-01-18 10:41:29 +11:00
trusted.h trusted-keys: rename trusted_defined files to trusted 2011-01-24 10:14:22 +11:00
user_defined.c Merge git://git.samba.org/sfrench/cifs-2.6 2012-01-23 08:59:49 -08:00