linux/security/keys
David Howells 3a50597de8 KEYS: Make the session and process keyrings per-thread
Make the session keyring per-thread rather than per-process, but still
inherited from the parent thread to solve a problem with PAM and gdm.

The problem is that join_session_keyring() will reject attempts to change the
session keyring of a multithreaded program but gdm is now multithreaded before
it gets to the point of starting PAM and running pam_keyinit to create the
session keyring.  See:

	https://bugs.freedesktop.org/show_bug.cgi?id=49211

The reason that join_session_keyring() will only change the session keyring
under a single-threaded environment is that it's hard to alter the other
thread's credentials to effect the change in a multi-threaded program.  The
problems are such as:

 (1) How to prevent two threads both running join_session_keyring() from
     racing.

 (2) Another thread's credentials may not be modified directly by this process.

 (3) The number of threads is uncertain whilst we're not holding the
     appropriate spinlock, making preallocation slightly tricky.

 (4) We could use TIF_NOTIFY_RESUME and key_replace_session_keyring() to get
     another thread to replace its keyring, but that means preallocating for
     each thread.

A reasonable way around this is to make the session keyring per-thread rather
than per-process and just document that if you want a common session keyring,
you must get it before you spawn any threads - which is the current situation
anyway.

Whilst we're at it, we can the process keyring behave in the same way.  This
means we can clean up some of the ickyness in the creds code.

Basically, after this patch, the session, process and thread keyrings are about
inheritance rules only and not about sharing changes of keyring.

Reported-by: Mantas M. <grawity@gmail.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Tested-by: Ray Strode <rstrode@redhat.com>
2012-10-02 19:24:29 +01:00
..
encrypted-keys encrypted-keys: fix rcu and sparse messages 2012-01-18 10:41:30 +11:00
Kconfig KEYS: Move the key config into security/keys/Kconfig 2012-05-11 10:56:56 +01:00
Makefile KEYS: Reorganise keys Makefile 2012-05-11 10:56:56 +01:00
compat.c Merge commit 'v3.5-rc2' into next 2012-06-10 22:52:10 +10:00
gc.c KEYS: Add invalidation support 2012-05-11 10:56:56 +01:00
internal.h Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security 2012-07-23 18:49:06 -07: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: Make the session and process keyrings per-thread 2012-10-02 19:24:29 +01:00
keyring.c KEYS: Fix some sparse warnings 2012-05-25 20:51:42 +10: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: Make the session and process keyrings per-thread 2012-10-02 19:24:29 +01:00
request_key.c KEYS: Make the session and process keyrings per-thread 2012-10-02 19:24:29 +01:00
request_key_auth.c KEYS: Don't return EAGAIN to keyctl_assume_authority() 2011-06-14 15:03:29 +10:00
sysctl.c sysctl: Drop & in front of every proc_handler. 2009-11-18 08:37:40 -08:00
trusted.c tpm: Move tpm_get_random api into the TPM device driver 2012-08-22 11:11:33 -05: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