summaryrefslogtreecommitdiffstats
path: root/include/linux/key.h
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2012-05-10 20:59:08 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-05-23 22:11:23 -0400
commit413cd3d9abeaef590e5ce00564f7a443165db238 (patch)
treefc7d254053793a95d1470f7c9eafb782d8cf91d6 /include/linux/key.h
parent4d1d61a6b203d957777d73fcebf19d90b038b5b2 (diff)
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>
Diffstat (limited to 'include/linux/key.h')
-rw-r--r--include/linux/key.h6
1 files changed, 2 insertions, 4 deletions
diff --git a/include/linux/key.h b/include/linux/key.h
index 5231800770e1..2a0ee11584e9 100644
--- a/include/linux/key.h
+++ b/include/linux/key.h
@@ -33,6 +33,8 @@ typedef uint32_t key_perm_t;
33 33
34struct key; 34struct key;
35 35
36#define key_replace_session_keyring() do { } while (0)
37
36#ifdef CONFIG_KEYS 38#ifdef CONFIG_KEYS
37 39
38#undef KEY_DEBUGGING 40#undef KEY_DEBUGGING
@@ -308,9 +310,6 @@ static inline bool key_is_instantiated(const struct key *key)
308#ifdef CONFIG_SYSCTL 310#ifdef CONFIG_SYSCTL
309extern ctl_table key_sysctls[]; 311extern ctl_table key_sysctls[];
310#endif 312#endif
311
312extern void key_replace_session_keyring(void);
313
314/* 313/*
315 * the userspace interface 314 * the userspace interface
316 */ 315 */
@@ -334,7 +333,6 @@ extern void key_init(void);
334#define key_fsuid_changed(t) do { } while(0) 333#define key_fsuid_changed(t) do { } while(0)
335#define key_fsgid_changed(t) do { } while(0) 334#define key_fsgid_changed(t) do { } while(0)
336#define key_init() do { } while(0) 335#define key_init() do { } while(0)
337#define key_replace_session_keyring() do { } while(0)
338 336
339#endif /* CONFIG_KEYS */ 337#endif /* CONFIG_KEYS */
340#endif /* __KERNEL__ */ 338#endif /* __KERNEL__ */