kernel-ark/arch/alpha/kernel
David Howells ee18d64c1f KEYS: Add a keyctl to install a process's session keyring on its parent [try #6]
Add a keyctl to install a process's session keyring onto its parent.  This
replaces the parent's session keyring.  Because the COW credential code does
not permit one process to change another process's credentials directly, the
change is deferred until userspace next starts executing again.  Normally this
will be after a wait*() syscall.

To support this, three new security hooks have been provided:
cred_alloc_blank() to allocate unset security creds, cred_transfer() to fill in
the blank security creds and key_session_to_parent() - which asks the LSM if
the process may replace its parent's session keyring.

The replacement may only happen if the process has the same ownership details
as its parent, and the process has LINK permission on the session keyring, and
the session keyring is owned by the process, and the LSM permits it.

Note that this requires alteration to each architecture's notify_resume path.
This has been done for all arches barring blackfin, m68k* and xtensa, all of
which need assembly alteration to support TIF_NOTIFY_RESUME.  This allows the
replacement to be performed at the point the parent process resumes userspace
execution.

This allows the userspace AFS pioctl emulation to fully emulate newpag() and
the VIOCSETTOK and VIOCSETTOK2 pioctls, all of which require the ability to
alter the parent process's PAG membership.  However, since kAFS doesn't use
PAGs per se, but rather dumps the keys into the session keyring, the session
keyring of the parent must be replaced if, for example, VIOCSETTOK is passed
the newpag flag.

This can be tested with the following program:

	#include <stdio.h>
	#include <stdlib.h>
	#include <keyutils.h>

	#define KEYCTL_SESSION_TO_PARENT	18

	#define OSERROR(X, S) do { if ((long)(X) == -1) { perror(S); exit(1); } } while(0)

	int main(int argc, char **argv)
	{
		key_serial_t keyring, key;
		long ret;

		keyring = keyctl_join_session_keyring(argv[1]);
		OSERROR(keyring, "keyctl_join_session_keyring");

		key = add_key("user", "a", "b", 1, keyring);
		OSERROR(key, "add_key");

		ret = keyctl(KEYCTL_SESSION_TO_PARENT);
		OSERROR(ret, "KEYCTL_SESSION_TO_PARENT");

		return 0;
	}

Compiled and linked with -lkeyutils, you should see something like:

	[dhowells@andromeda ~]$ keyctl show
	Session Keyring
	       -3 --alswrv   4043  4043  keyring: _ses
	355907932 --alswrv   4043    -1   \_ keyring: _uid.4043
	[dhowells@andromeda ~]$ /tmp/newpag
	[dhowells@andromeda ~]$ keyctl show
	Session Keyring
	       -3 --alswrv   4043  4043  keyring: _ses
	1055658746 --alswrv   4043  4043   \_ user: a
	[dhowells@andromeda ~]$ /tmp/newpag hello
	[dhowells@andromeda ~]$ keyctl show
	Session Keyring
	       -3 --alswrv   4043  4043  keyring: hello
	340417692 --alswrv   4043  4043   \_ user: a

Where the test program creates a new session keyring, sticks a user key named
'a' into it and then installs it on its parent.

Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: James Morris <jmorris@namei.org>
2009-09-02 21:29:22 +10:00
..
.gitignore alpha: .gitignore vmlinux.lds 2009-01-15 16:39:40 -08:00
alpha_ksyms.c Generic semaphore implementation 2008-04-17 10:42:34 -04:00
asm-offsets.c CRED: Separate task security context from task_struct 2008-11-14 10:39:16 +11:00
binfmt_loader.c alpha: binfmt_aout fix 2009-05-02 15:36:10 -07:00
console.c ALPHA: support graphics on non-zero PCI domains 2007-06-01 08:18:29 -07:00
core_apecs.c [PATCH] alpha pt_regs cleanups: machine_check() 2006-10-08 12:32:36 -07:00
core_cia.c [PATCH] alpha pt_regs cleanups: machine_check() 2006-10-08 12:32:36 -07:00
core_irongate.c Introduce flags for reserve_bootmem() 2008-02-07 08:42:25 -08:00
core_lca.c [PATCH] alpha pt_regs cleanups: machine_check() 2006-10-08 12:32:36 -07:00
core_marvel.c alpha: fix RTC on marvel 2009-01-15 16:39:40 -08:00
core_mcpcia.c alpha: fixes for specific machine types 2007-04-17 16:36:27 -07:00
core_polaris.c [PATCH] alpha pt_regs cleanups: machine_check() 2006-10-08 12:32:36 -07:00
core_t2.c alpha: fix compile failures with gcc-4.3 (bug #10438) 2008-06-20 16:46:10 -07:00
core_titan.c alpha: remove remaining __FUNCTION__ occurrences 2008-04-28 08:58:27 -07:00
core_tsunami.c alpha: remove remaining __FUNCTION__ occurrences 2008-04-28 08:58:27 -07:00
core_wildfire.c [PATCH] alpha pt_regs cleanups: machine_check() 2006-10-08 12:32:36 -07:00
entry.S do_pipe cleanup: drop its last user in arch/alpha/ 2009-03-27 14:43:58 -04:00
err_common.c PCI: Cleanup the includes of <linux/pci.h> 2007-05-02 19:02:35 -07:00
err_ev6.c alpha: titan and marvel build fixes 2009-05-02 15:36:10 -07:00
err_ev7.c alpha: titan and marvel build fixes 2009-05-02 15:36:10 -07:00
err_impl.h alpha: titan and marvel build fixes 2009-05-02 15:36:10 -07:00
err_marvel.c alpha: titan and marvel build fixes 2009-05-02 15:36:10 -07:00
err_titan.c alpha: titan and marvel build fixes 2009-05-02 15:36:10 -07:00
es1888.c
gct.c Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
head.S alpha: convert to use __HEAD and HEAD_TEXT macros. 2009-04-26 09:20:38 -07:00
init_task.c mm: consolidate init_mm definition 2009-06-16 19:47:28 -07:00
io.c
irq_alpha.c alpha: remove obsolete hw_interrupt_type 2009-06-16 19:47:46 -07:00
irq_i8259.c alpha: remove obsolete hw_interrupt_type 2009-06-16 19:47:46 -07:00
irq_impl.h alpha: remove obsolete hw_interrupt_type 2009-06-16 19:47:46 -07:00
irq_pyxis.c alpha: remove obsolete hw_interrupt_type 2009-06-16 19:47:46 -07:00
irq_srm.c alpha: remove obsolete hw_interrupt_type 2009-06-16 19:47:46 -07:00
irq.c Merge branch 'core/percpu' into percpu-cpumask-x86-for-linus-2 2009-03-27 17:28:43 +01:00
machvec_impl.h alpha: fix RTC on marvel 2009-01-15 16:39:40 -08:00
Makefile alpha: binfmt_aout fix 2009-05-02 15:36:10 -07:00
module.c alpha: handle kcalloc failure 2008-04-28 08:58:27 -07:00
ns87312.c
osf_sys.c Push BKL into do_mount() 2009-06-11 21:36:08 -04:00
pci_impl.h PCI: alpha: use generic INTx swizzle from PCI core 2009-01-07 11:13:13 -08:00
pci_iommu.c alpha: convert u64 to unsigned long long 2009-04-01 08:59:16 -07:00
pci-noop.c alpha: compile fixes 2009-01-29 18:04:44 -08:00
pci-sysfs.c PCI/alpha: pci sysfs resources 2009-03-19 19:29:36 -07:00
pci.c alpha: convert u64 to unsigned long long 2009-04-01 08:59:16 -07:00
process.c Simplify copy_thread() 2009-04-02 19:04:51 -07:00
proto.h alpha: titan and marvel build fixes 2009-05-02 15:36:10 -07:00
ptrace.c headers: smp_lock.h redux 2009-07-12 12:22:34 -07:00
setup.c alpha: bad macro expansion, parameter is member 2009-06-16 19:47:46 -07:00
signal.c KEYS: Add a keyctl to install a process's session keyring on its parent [try #6] 2009-09-02 21:29:22 +10:00
smc37c93x.c Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
smc37c669.c alpha: convert u64 to unsigned long long 2009-04-01 08:59:16 -07:00
smp.c cpumask: Use cpu_*_mask accessors code: alpha 2009-02-16 17:32:00 +10:30
srm_env.c proc 2/2: remove struct proc_dir_entry::owner 2009-03-31 01:14:44 +04:00
srmcons.c alpha: fix trivial section mismatch warnings 2007-07-16 09:05:37 -07:00
sys_alcor.c alpha: remove obsolete hw_interrupt_type 2009-06-16 19:47:46 -07:00
sys_cabriolet.c alpha: remove obsolete hw_interrupt_type 2009-06-16 19:47:46 -07:00
sys_dp264.c alpha: remove obsolete hw_interrupt_type 2009-06-16 19:47:46 -07:00
sys_eb64p.c alpha: remove obsolete hw_interrupt_type 2009-06-16 19:47:46 -07:00
sys_eiger.c alpha: remove obsolete hw_interrupt_type 2009-06-16 19:47:46 -07:00
sys_jensen.c alpha: remove obsolete hw_interrupt_type 2009-06-16 19:47:46 -07:00
sys_marvel.c alpha: remove obsolete hw_interrupt_type 2009-06-16 19:47:46 -07:00
sys_miata.c PCI: alpha: use generic pci_swizzle_interrupt_pin() 2009-01-07 11:12:53 -08:00
sys_mikasa.c alpha: remove obsolete hw_interrupt_type 2009-06-16 19:47:46 -07:00
sys_nautilus.c alpha: nautilus - fix hang on boot 2009-01-15 16:39:40 -08:00
sys_noritake.c alpha: remove obsolete hw_interrupt_type 2009-06-16 19:47:46 -07:00
sys_rawhide.c alpha: remove obsolete hw_interrupt_type 2009-06-16 19:47:46 -07:00
sys_ruffian.c time: move PIT_TICK_RATE to linux/timex.h 2009-06-16 19:47:27 -07:00
sys_rx164.c alpha: remove obsolete hw_interrupt_type 2009-06-16 19:47:46 -07:00
sys_sable.c alpha: remove obsolete hw_interrupt_type 2009-06-16 19:47:46 -07:00
sys_sio.c alpha: remove remaining __FUNCTION__ occurrences 2008-04-28 08:58:27 -07:00
sys_sx164.c alpha: more fixes for specific machine types 2007-04-17 16:36:27 -07:00
sys_takara.c alpha: remove obsolete hw_interrupt_type 2009-06-16 19:47:46 -07:00
sys_titan.c alpha: remove obsolete hw_interrupt_type 2009-06-16 19:47:46 -07:00
sys_wildfire.c alpha: remove obsolete hw_interrupt_type 2009-06-16 19:47:46 -07:00
systbls.S alpha: use syscall wrappers 2009-01-29 18:04:44 -08:00
time.c alpha: fix RTC on marvel 2009-01-15 16:39:40 -08:00
traps.c alpha: convert u64 to unsigned long long 2009-04-01 08:59:16 -07:00
vmlinux.lds.S alpha: convert to use __HEAD and HEAD_TEXT macros. 2009-04-26 09:20:38 -07:00