linux-stable/arch/mips/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 [MIPS] Ignore vmlinux.lds generated files 2008-08-26 09:10:27 +01:00
8250-platform.c [MIPS] Put an end to <asm/serial.h>'s long and annyoing existence 2007-07-10 17:33:01 +01:00
Makefile MIPS: make cp0 counter clocksource/event usable as fallback. 2009-01-11 09:57:26 +00:00
asm-offsets.c MIPS: Add hibernation support 2009-06-17 11:06:31 +01:00
binfmt_elfn32.c remove div_long_long_rem 2008-05-01 08:03:58 -07:00
binfmt_elfo32.c MIPS: 64-bit: Fix o32 core dump 2009-07-03 15:45:27 +01:00
branch.c MIPS: Compute branch returns for Cavium OCTEON specific branch instructions. 2009-01-11 09:57:24 +00:00
cevt-bcm1480.c MIPS: Build fix - include <linux/smp.h> into all smp_processor_id() users. 2009-06-24 18:34:39 +01:00
cevt-ds1287.c Update Yoichi Yuasa's e-mail address 2009-07-03 15:45:29 +01:00
cevt-gt641xx.c Update Yoichi Yuasa's e-mail address 2009-07-03 15:45:29 +01:00
cevt-r4k.c MIPS: Build fix - include <linux/smp.h> into all smp_processor_id() users. 2009-06-24 18:34:39 +01:00
cevt-sb1250.c MIPS: Build fix - include <linux/smp.h> into all smp_processor_id() users. 2009-06-24 18:34:39 +01:00
cevt-smtc.c MIPS: Build fix - include <linux/smp.h> into all smp_processor_id() users. 2009-06-24 18:34:39 +01:00
cevt-txx9.c MIPS: TXx9: micro optimization for clocksource and clock_event 2009-06-17 11:06:25 +01:00
cpu-bugs64.c [MIPS] Add empty argument parenthesis to GCC_IMM_ASM 2008-05-12 16:46:52 +01:00
cpu-probe.c MIPS: Build fix - include <linux/smp.h> into all smp_processor_id() users. 2009-06-24 18:34:39 +01:00
csrc-bcm1480.c clocksource: pass clocksource to read() callback 2009-04-21 13:41:47 -07:00
csrc-ioasic.c Update Yoichi Yuasa's e-mail address 2009-07-03 15:45:29 +01:00
csrc-r4k.c clocksource: pass clocksource to read() callback 2009-04-21 13:41:47 -07:00
csrc-sb1250.c clocksource: pass clocksource to read() callback 2009-04-21 13:41:47 -07:00
early_printk.c [MIPS] fix sparse warning about setup_early_printk() 2008-07-15 18:44:29 +01:00
entry.S [MIPS] SMTC: Close tiny holes in the SMTC IPI replay system. 2008-10-03 17:58:58 +01:00
genex.S MIPS: Read watch registers with interrupts disabled. 2009-01-30 21:32:58 +00:00
gpio_txx9.c [MIPS] txx9: Make gpio_txx9 entirely spinlock-safe 2008-07-15 18:44:34 +01:00
head.S MIPS: Avoid clobbering struct pt_regs in kthreads 2009-08-03 17:52:41 +01:00
i8253.c MIPS: Build fix - include <linux/smp.h> into all smp_processor_id() users. 2009-06-24 18:34:39 +01:00
i8259.c cpumask: remove references to struct irqaction's mask field. 2009-03-30 22:05:14 +10:30
init_task.c mm: consolidate init_mm definition 2009-06-16 19:47:28 -07:00
irq-gic.c MIPS: CMP: Extend IPI handling to CPU number 2009-07-03 15:45:26 +01:00
irq-gt641xx.c Update Yoichi Yuasa's e-mail address 2009-07-03 15:45:29 +01:00
irq-msc01.c MIPS: Enable GENERIC_HARDIRQS_NO__DO_IRQ for all platforms 2009-03-30 14:49:44 +02:00
irq-rm7000.c [MIPS] Fix broken rm7000/rm9000 interrupt handling 2008-02-19 17:01:31 +00:00
irq-rm9000.c on_each_cpu(): kill unused 'retry' parameter 2008-06-26 11:24:38 +02:00
irq.c Merge branches 'irq/genirq' and 'linus' into irq/core 2009-03-16 09:20:13 +01:00
irq_cpu.c MIPS: Enable GENERIC_HARDIRQS_NO__DO_IRQ for all platforms 2009-03-30 14:49:44 +02:00
irq_txx9.c MIPS: Eleminate filenames from comments 2009-08-03 17:52:40 +01:00
kgdb.c MIPS: Build fix - include <linux/smp.h> into all smp_processor_id() users. 2009-06-24 18:34:39 +01:00
kspd.c CRED: Separate task security context from task_struct 2008-11-14 10:39:16 +11:00
linux32.c MIPS: Compat: Zero upper 32-bit of offset_high and offset_low. 2009-03-30 14:49:40 +02:00
machine_kexec.c [MIPS] Unconditionally writeback and invalidate caches on kexec. 2007-08-27 02:16:59 +01:00
mips-mt-fpaff.c MIPS: SMTC: Fix build after recent creditial changes. 2009-01-30 21:32:56 +00:00
mips-mt.c [MIPS] Replace use of print_symbol with new %sP pointer format. 2008-07-15 18:44:33 +01:00
mips_ksyms.c
module.c MIPS: Module: Make error messages unique. 2009-08-03 17:52:48 +01:00
octeon_switch.S MIPS: Add Cavium OCTEON processor support files to arch/mips/cavium-octeon. 2009-01-11 09:57:21 +00:00
proc.c MIPS: Eleminate filenames from comments 2009-08-03 17:52:40 +01:00
process.c MIPS: Avoid clobbering struct pt_regs in kthreads 2009-08-03 17:52:41 +01:00
ptrace.c MIPS: Ptrace support for HARDWARE_WATCHPOINTS 2008-10-11 16:18:57 +01:00
ptrace32.c headers: smp_lock.h redux 2009-07-12 12:22:34 -07:00
r4k_fpu.S
r4k_switch.S [MIPS] Fix resume for 64K page size on R4000 class processors. 2007-07-12 17:41:05 +01:00
r2300_fpu.S
r2300_switch.S
r6000_fpu.S
relocate_kernel.S [MIPS] Kexec: Fix several 64-bit bugs. 2007-07-31 21:35:36 +01:00
reset.c
rtlx.c device create: misc: convert device_create_drvdata to device_create 2008-10-16 09:24:43 -07:00
scall32-o32.S MIPS: Wire up accept4 syscall. 2009-08-03 17:52:50 +01:00
scall64-64.S MIPS: Wire up accept4 syscall. 2009-08-03 17:52:50 +01:00
scall64-n32.S MIPS: Wire up accept4 syscall. 2009-08-03 17:52:50 +01:00
scall64-o32.S MIPS: Wire up accept4 syscall. 2009-08-03 17:52:50 +01:00
setup.c MIPS: Stop using <asm-generic/int-l64.h>. 2009-03-30 14:49:41 +02:00
signal-common.h [MIPS] replace remaining __FUNCTION__ occurrences 2008-04-28 17:14:27 +01: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
signal32.c MIPS: CVE-2009-0029: Enable syscall wrappers. 2009-02-27 17:56:35 +00:00
signal_n32.c [MIPS] Fix "no space between function name and open parenthesis" warnings. 2007-10-11 23:46:15 +01:00
smp-cmp.c MIPS: CMP: activate CMP support 2009-07-03 15:45:26 +01:00
smp-mt.c cpumask: centralize cpu_online_map and cpu_possible_map 2008-12-13 21:19:41 +10:30
smp-up.c MIPS: Add arch generic CPU hotplug 2009-06-24 18:34:40 +01:00
smp.c MIPS: Add arch generic CPU hotplug 2009-06-24 18:34:40 +01:00
smtc-asm.S [MIPS] SMTC: Don't set and restore irqregs ptr from self_ipi. 2007-06-11 18:20:53 +01:00
smtc-proc.c [MIPS] SMP: Call platform methods via ops structure. 2008-01-29 10:14:57 +00:00
smtc.c MIPS: SMTC: Move cross VPE writes to after a TC is assigned to VPE. 2009-08-03 17:52:42 +01:00
spram.c [MIPS] Basic SPRAM support 2008-04-28 17:14:23 +01:00
stacktrace.c MIPS: Eleminate filenames from comments 2009-08-03 17:52:40 +01:00
sync-r4k.c MIPS: CMP: Update sync-r4k for current kernel 2009-07-03 15:45:27 +01:00
syscall.c MIPS: CVE-2009-0029: Enable syscall wrappers. 2009-02-27 17:56:35 +00:00
time.c [MIPS] unexport null_perf_irq() and make it static 2008-04-28 17:14:31 +01:00
topology.c MIPS: Add arch generic CPU hotplug 2009-06-24 18:34:40 +01:00
traps.c MIPS: Move Cavium CP0 hwrena impl bits to cpu-feature-overrides.h 2009-06-17 11:06:31 +01:00
unaligned.c MIPS: Use force_sig when handling address errors. 2009-05-14 13:50:29 +01:00
vmlinux.lds.S MIPS: Align .data.cacheline_aligned based on CONFIG_MIPS_L1_CACHE_SHIFT 2008-10-15 12:46:50 +01:00
vpe.c MIPS: VPE: Delete unused function get_tc_unused(). 2009-08-03 17:52:50 +01:00
watch.c MIPS: Add HARDWARE_WATCHPOINTS definitions and support code. 2008-10-11 16:18:56 +01:00