linux/arch/sparc/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 sparc: gitignore a few files 2008-12-04 09:17:15 -08:00
apc.c sparc: correct section of apc_no_idle 2008-10-22 21:53:43 -07:00
asm-offsets.c sparc,sparc64: unify asm-offsets.c 2008-12-04 09:17:12 -08:00
audit.c sparc,sparc64: unify kernel/ 2008-12-04 09:17:21 -08:00
auxio_32.c sparc: move EXPORT_SYMBOL to the symbols definition 2009-01-08 16:58:05 -08:00
auxio_64.c sparc64: move EXPORT_SYMBOL to the symbols definition 2009-01-08 16:58:20 -08:00
central.c sparc64: Initialize FHC/CLOCK LED platform_device 'id' field correctly. 2009-01-19 13:27:15 -08:00
cherrs.S sparc,sparc64: unify kernel/ 2008-12-04 09:17:21 -08:00
chmc.c sparc64: Fix crashes in jbusmc_print_dimm() 2009-02-11 00:54:07 -08:00
compat_audit.c sparc,sparc64: unify kernel/ 2008-12-04 09:17:21 -08:00
cpu.c sparc: Probe PMU type and record in sparc_pmu_type. 2009-01-28 17:27:14 -08:00
cpumap.c sparc64: fix and optimize irq distribution 2009-06-16 04:56:28 -07:00
cpumap.h sparc64: fix and optimize irq distribution 2009-06-16 04:56:28 -07:00
devices.c sparc: drop CONFIG_SUN_AUXIO 2008-12-04 13:26:31 -08:00
dma.c sparc: remove dma-mapping_{32|64}.h 2009-06-16 04:56:47 -07:00
dma.h sparc32: Implement more generic dma_*() interfaces. 2008-08-29 02:13:14 -07:00
ds.c sparc64: Defer cpu_data() setup until end of per-cpu data initialization. 2009-06-16 04:56:22 -07:00
dtlb_miss.S sparc,sparc64: unify kernel/ 2008-12-04 09:17:21 -08:00
dtlb_prot.S sparc,sparc64: unify kernel/ 2008-12-04 09:17:21 -08:00
ebus.c sparc,sparc64: unify kernel/ 2008-12-04 09:17:21 -08:00
entry.h sparc: fix sparse warnings in irq_32.c 2008-12-08 01:08:24 -08:00
entry.S [CVE-2009-0029] Remove __attribute__((weak)) from sys_pipe/sys_pipe2 2009-01-14 14:15:15 +01:00
etrap_32.S sparc: prepare kernel/ for unification 2008-12-04 09:17:20 -08:00
etrap_64.S sparc,sparc64: unify kernel/ 2008-12-04 09:17:21 -08:00
fpu_traps.S sparc,sparc64: unify kernel/ 2008-12-04 09:17:21 -08:00
ftrace.c sparc64: Add proper dynamic ftrace support. 2009-06-16 04:56:53 -07:00
getsetcc.S sparc,sparc64: unify kernel/ 2008-12-04 09:17:21 -08:00
head_32.S sparc: cleanup references to deprecated .text.init* sections. 2009-04-27 19:51:58 -07:00
head_64.S sparc64: Store per-cpu offset in trap_block[] 2009-06-16 04:56:11 -07:00
helpers.S sparc,sparc64: unify kernel/ 2008-12-04 09:17:21 -08:00
hvapi.c sparc,sparc64: unify kernel/ 2008-12-04 09:17:21 -08:00
hvcalls.S sparc,sparc64: unify kernel/ 2008-12-04 09:17:21 -08:00
hvtramp.S sparc,sparc64: unify kernel/ 2008-12-04 09:17:21 -08:00
idprom.c sparc: move EXPORT_SYMBOL to the symbols definition 2009-01-08 16:58:05 -08:00
init_task.c mm: consolidate init_mm definition 2009-06-16 19:47:28 -07:00
iommu_common.h sparc,sparc64: unify kernel/ 2008-12-04 09:17:21 -08:00
iommu.c sparc: use dma_map_page instead of dma_map_single 2009-06-16 04:56:45 -07:00
ioport.c sparc: move EXPORT_SYMBOL to the symbols definition 2009-01-08 16:58:05 -08:00
irq_32.c cpumask: remove references to struct irqaction's mask field. 2009-03-30 22:05:14 +10:30
irq_64.c sparc64: Don't use alloc_bootmem() in init_IRQ() code paths. 2009-06-25 19:00:47 -07:00
irq.h sparc32: Kill clear_profile_irq btfixup entry. 2008-09-19 21:17:59 -07:00
itlb_miss.S sparc,sparc64: unify kernel/ 2008-12-04 09:17:21 -08:00
ivec.S sparc,sparc64: unify kernel/ 2008-12-04 09:17:21 -08:00
kernel.h sparc: Probe PMU type and record in sparc_pmu_type. 2009-01-28 17:27:14 -08:00
kgdb_32.c sparc: add '32' suffix to reg_window, sigcontext, __siginfo_t 2009-01-02 19:32:59 -08:00
kgdb_64.c sparc64: Reschedule KGDB capture to a software interrupt. 2009-03-18 23:51:57 -07:00
kprobes.c trivial: fix then -> than typos in comments and documentation 2009-01-06 11:28:06 +01:00
kstack.h sparc,sparc64: unify kernel/ 2008-12-04 09:17:21 -08:00
ktlb.S sparc,sparc64: unify kernel/ 2008-12-04 09:17:21 -08:00
ldc.c sparc: remove some pointless conditionals before kfree() 2009-04-15 03:04:56 -07:00
led.c proc 2/2: remove struct proc_dir_entry::owner 2009-03-31 01:14:44 +04:00
Makefile sparc: move of_device common code to of_device_common 2009-06-16 04:56:49 -07:00
mdesc.c sparc64: Defer cpu_data() setup until end of per-cpu data initialization. 2009-06-16 04:56:22 -07:00
misctrap.S sparc,sparc64: unify kernel/ 2008-12-04 09:17:21 -08:00
module.c module: cleanup FIXME comments about trimming exception table entries. 2009-06-12 21:47:05 +09:30
muldiv.c sparc: add '32' suffix to reg_window, sigcontext, __siginfo_t 2009-01-02 19:32:59 -08:00
nmi.c sparc64: Fix reset hangs on Niagara systems. 2009-03-29 15:40:33 -07:00
of_device_32.c sparc: move of_device common code to of_device_common 2009-06-16 04:56:49 -07:00
of_device_64.c sparc: move of_device common code to of_device_common 2009-06-16 04:56:49 -07:00
of_device_common.c sparc: move of_device common code to of_device_common 2009-06-16 04:56:49 -07:00
of_device_common.h sparc: move of_device common code to of_device_common 2009-06-16 04:56:49 -07:00
pci_common.c sparc64: Fix crash with /proc/iomem 2009-03-18 23:53:16 -07:00
pci_fire.c sparc64: Fix section mismatch warnings in PCI controller drivers. 2009-04-08 03:28:15 -07:00
pci_impl.h sparc,sparc64: unify kernel/ 2008-12-04 09:17:21 -08:00
pci_msi.c sparc64: Use unsigned long long for u64. 2009-01-06 13:19:28 -08:00
pci_psycho.c sparc64: Fix section mismatch warnings in PCI controller drivers. 2009-04-08 03:28:15 -07:00
pci_sabre.c sparc64: Fix section mismatch warnings in PCI controller drivers. 2009-04-08 03:28:15 -07:00
pci_schizo.c sparc64: Use unsigned long long for u64. 2009-01-06 13:19:28 -08:00
pci_sun4v_asm.S sparc,sparc64: unify kernel/ 2008-12-04 09:17:21 -08:00
pci_sun4v.c sparc: use dma_map_page instead of dma_map_single 2009-06-16 04:56:45 -07:00
pci_sun4v.h sparc,sparc64: unify kernel/ 2008-12-04 09:17:21 -08:00
pci.c Delete pcibios_select_root 2009-06-17 14:04:42 -07:00
pcic.c sparc: move EXPORT_SYMBOL to the symbols definition 2009-01-08 16:58:05 -08:00
pcr.c sparc64: Don't hook up pcr_ops on spitfire chips. 2009-02-05 23:59:04 -08:00
pmc.c sparc: fix trivial style issues in kernel/pmc.c 2008-12-08 01:02:55 -08:00
power.c sparc64: Fix section mismatch warnings in power driver. 2009-04-08 03:27:52 -07:00
process_32.c Simplify copy_thread() 2009-04-02 19:04:51 -07:00
process_64.c Simplify copy_thread() 2009-04-02 19:04:51 -07:00
prom_32.c sparc: Restore irq_trans_init() call in prom_create_node(). 2008-12-07 00:46:33 -08:00
prom_64.c sparc64: Defer cpu_data() setup until end of per-cpu data initialization. 2009-06-16 04:56:22 -07:00
prom_common.c sparc: Call OF and MD cpu scanning explicitly from paging_init() 2009-06-16 04:56:19 -07:00
prom_irqtrans.c sparc64: Use unsigned long long for u64. 2009-01-06 13:19:28 -08:00
prom.h sparc: Call OF and MD cpu scanning explicitly from paging_init() 2009-06-16 04:56:19 -07:00
psycho_common.c sparc64: fix warnings in psycho_common after ull conversion 2009-01-08 11:37:19 -08:00
psycho_common.h sparc,sparc64: unify kernel/ 2008-12-04 09:17:21 -08:00
ptrace_32.c headers: smp_lock.h redux 2009-07-12 12:22:34 -07:00
ptrace_64.c headers: smp_lock.h redux 2009-07-12 12:22:34 -07:00
reboot.c sparc,sparc64: unify kernel/ 2008-12-04 09:17:21 -08:00
rtrap_32.S sparc: prepare kernel/ for unification 2008-12-04 09:17:20 -08:00
rtrap_64.S sparc,sparc64: unify kernel/ 2008-12-04 09:17:21 -08:00
sbus.c sparc64: move EXPORT_SYMBOL to the symbols definition 2009-01-08 16:58:20 -08:00
setup_32.c sparc: move EXPORT_SYMBOL to the symbols definition 2009-01-08 16:58:05 -08:00
setup_64.c sparc: Probe PMU type and record in sparc_pmu_type. 2009-01-28 17:27:14 -08:00
signal32.c sparc,sparc64: unify kernel/ 2008-12-04 09:17:21 -08:00
signal_32.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
signal_64.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
smp_32.c cpumask: use mm_cpumask() wrapper: sparc 2009-03-16 14:40:39 +10:30
smp_64.c percpu, sparc64: fix sparse possible cpu map handling 2009-08-14 13:20:53 +09:00
sparc_ksyms_32.c sparc: Eliminate PROMLIB_INTERNAL as it does nothing 2009-01-08 16:59:01 -08:00
sparc_ksyms_64.c sparc64: Fix UP build failure. 2009-01-13 17:38:24 -08:00
spiterrs.S sparc,sparc64: unify kernel/ 2008-12-04 09:17:21 -08:00
sstate.c sparc,sparc64: unify kernel/ 2008-12-04 09:17:21 -08:00
stacktrace.c sparc,sparc64: unify kernel/ 2008-12-04 09:17:21 -08:00
starfire.c sparc,sparc64: unify kernel/ 2008-12-04 09:17:21 -08:00
sun4c_irq.c sparc: Add missing of_node_put 2008-12-04 09:17:22 -08:00
sun4d_irq.c cpumask: remove references to struct irqaction's mask field. 2009-03-30 22:05:14 +10:30
sun4d_smp.c cpumask: prepare for iterators to only go to nr_cpu_ids/nr_cpumask_bits.: sparc 2009-03-16 14:40:24 +10:30
sun4m_irq.c sparc: Add missing of_node_put 2008-12-04 09:17:22 -08:00
sun4m_smp.c cpumask: prepare for iterators to only go to nr_cpu_ids/nr_cpumask_bits.: sparc 2009-03-16 14:40:24 +10:30
sun4v_ivec.S sparc,sparc64: unify kernel/ 2008-12-04 09:17:21 -08:00
sun4v_tlb_miss.S sparc,sparc64: unify kernel/ 2008-12-04 09:17:21 -08:00
sys32.S sparc,sparc64: unify kernel/ 2008-12-04 09:17:21 -08:00
sys_sparc32.c Separate out common fstatat code into vfs_fstatat 2009-04-20 23:02:51 -04:00
sys_sparc_32.c sparc: prepare kernel/ for unification 2008-12-04 09:17:20 -08:00
sys_sparc_64.c sparc64: Annotate sparc64 specific syscalls with SYSCALL_DEFINEx() 2009-01-19 21:11:27 -08:00
syscalls.S sparc64: Annotate sparc64 specific syscalls with SYSCALL_DEFINEx() 2009-01-19 21:11:27 -08:00
sysfs.c sparc: fix hardirq.h removal fallout 2008-12-26 15:33:07 -08:00
systbls_32.S sparc: Wire up sys_rt_tgsigqueueinfo(). 2009-06-16 04:56:58 -07:00
systbls_64.S sparc: Wire up sys_rt_tgsigqueueinfo(). 2009-06-16 04:56:58 -07:00
systbls.h sparc64: Annotate sparc64 specific syscalls with SYSCALL_DEFINEx() 2009-01-19 21:11:27 -08:00
tadpole.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
tick14.c sparc32: Delete claim_ticker14(). 2008-09-19 21:18:01 -07:00
time_32.c sparc: move EXPORT_SYMBOL to the symbols definition 2009-01-08 16:58:05 -08:00
time_64.c headers: smp_lock.h redux 2009-07-12 12:22:34 -07:00
trampoline_32.S sparc: prepare kernel/ for unification 2008-12-04 09:17:20 -08:00
trampoline_64.S sparc,sparc64: unify kernel/ 2008-12-04 09:17:21 -08:00
traps_32.c headers: smp_lock.h redux 2009-07-12 12:22:34 -07:00
traps_64.c sparc64: Use BUILD_BUG_ON() in trap_init(). 2009-06-16 04:56:13 -07:00
tsb.S sparc,sparc64: unify kernel/ 2008-12-04 09:17:21 -08:00
ttable.S sparc64: Reschedule KGDB capture to a software interrupt. 2009-03-18 23:51:57 -07:00
una_asm_32.S sparc: prepare kernel/ for unification 2008-12-04 09:17:20 -08:00
una_asm_64.S sparc,sparc64: unify kernel/ 2008-12-04 09:17:21 -08:00
unaligned_32.c sparc: add '32' suffix to reg_window, sigcontext, __siginfo_t 2009-01-02 19:32:59 -08:00
unaligned_64.c sparc: Most unaligned_64.c tweaks for branch tracer warnings. 2009-01-08 16:52:36 -08:00
us2e_cpufreq.c sparc,sparc64: unify kernel/ 2008-12-04 09:17:21 -08:00
us3_cpufreq.c sparc,sparc64: unify kernel/ 2008-12-04 09:17:21 -08:00
utrap.S sparc,sparc64: unify kernel/ 2008-12-04 09:17:21 -08:00
vio.c sparc: remove driver-core BUS_ID_SIZE 2009-07-12 13:02:09 -07:00
viohs.c sparc64: refactor code in viohs.c 2009-01-06 12:46:46 -08:00
visemul.c sparc,sparc64: unify kernel/ 2008-12-04 09:17:21 -08:00
vmlinux.lds.S sparc: convert to use __HEAD and HEAD_TEXT macros. 2009-04-26 09:20:39 -07:00
windows.c sparc: add '32' suffix to reg_window, sigcontext, __siginfo_t 2009-01-02 19:32:59 -08:00
winfixup.S sparc,sparc64: unify kernel/ 2008-12-04 09:17:21 -08:00
wof.S sparc/kernel/: possible cleanups 2008-07-17 21:37:46 -07:00
wuf.S sparc/kernel/: possible cleanups 2008-07-17 21:37:46 -07:00