linux_dsm_epyc7002/arch/ia64/kernel
Eric W. Biederman cc731525f2 signal: Remove kernel interal si_code magic
struct siginfo is a union and the kernel since 2.4 has been hiding a union
tag in the high 16bits of si_code using the values:
__SI_KILL
__SI_TIMER
__SI_POLL
__SI_FAULT
__SI_CHLD
__SI_RT
__SI_MESGQ
__SI_SYS

While this looks plausible on the surface, in practice this situation has
not worked well.

- Injected positive signals are not copied to user space properly
  unless they have these magic high bits set.

- Injected positive signals are not reported properly by signalfd
  unless they have these magic high bits set.

- These kernel internal values leaked to userspace via ptrace_peek_siginfo

- It was possible to inject these kernel internal values and cause the
  the kernel to misbehave.

- Kernel developers got confused and expected these kernel internal values
  in userspace in kernel self tests.

- Kernel developers got confused and set si_code to __SI_FAULT which
  is SI_USER in userspace which causes userspace to think an ordinary user
  sent the signal and that it was not kernel generated.

- The values make it impossible to reorganize the code to transform
  siginfo_copy_to_user into a plain copy_to_user.  As si_code must
  be massaged before being passed to userspace.

So remove these kernel internal si codes and make the kernel code simpler
and more maintainable.

To replace these kernel internal magic si_codes introduce the helper
function siginfo_layout, that takes a signal number and an si_code and
computes which union member of siginfo is being used.  Have
siginfo_layout return an enumeration so that gcc will have enough
information to warn if a switch statement does not handle all of union
members.

A couple of architectures have a messed up ABI that defines signal
specific duplications of SI_USER which causes more special cases in
siginfo_layout than I would like.  The good news is only problem
architectures pay the cost.

Update all of the code that used the previous magic __SI_ values to
use the new SIL_ values and to call siginfo_layout to get those
values.  Escept where not all of the cases are handled remove the
defaults in the switch statements so that if a new case is missed in
the future the lack will show up at compile time.

Modify the code that copies siginfo si_code to userspace to just copy
the value and not cast si_code to a short first.  The high bits are no
longer used to hold a magic union member.

Fixup the siginfo header files to stop including the __SI_ values in
their constants and for the headers that were missing it to properly
update the number of si_codes for each signal type.

The fixes to copy_siginfo_from_user32 implementations has the
interesting property that several of them perviously should never have
worked as the __SI_ values they depended up where kernel internal.
With that dependency gone those implementations should work much
better.

The idea of not passing the __SI_ values out to userspace and then
not reinserting them has been tested with criu and criu worked without
changes.

Ref: 2.4.0-test1
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
2017-07-24 14:30:28 -05:00
..
.gitignore
acpi-ext.c ACPICA: Resources: Provide common part for struct acpi_resource_address structures. 2015-01-26 16:09:56 +01:00
acpi.c x86/ACPI: keep x86_cpu_to_acpiid mapping valid on CPU hotplug 2017-02-07 13:34:56 +01:00
asm-offsets.c ia64: Remove unused IA64_TASK_SIGHAND_OFFSET and IA64_SIGHAND_SIGLOCK_OFFSET 2017-04-17 21:53:08 -05:00
audit.c
brl_emu.c sched/headers: Prepare for new header dependencies before moving code to <linux/sched/signal.h> 2017-03-02 08:42:29 +01:00
crash_dump.c Replace <asm/uaccess.h> with <linux/uaccess.h> globally 2016-12-24 11:46:01 -08:00
crash.c ia64: reuse append_elf_note() and final_note() functions 2017-05-08 17:15:11 -07:00
cyclone.c clocksource: Use a plain u64 instead of cycle_t 2016-12-25 11:04:12 +01:00
dma-mapping.c treewide: Constify most dma_map_ops structures 2017-01-24 12:23:35 -05:00
efi_stub.S
efi.c ia64: efi: use timespec64 for persistent clock 2016-06-17 13:45:05 -07:00
elfcore.c switch elf_core_write_extra_data() to dump_emit() 2013-11-09 00:16:23 -05:00
entry.h
entry.S sched/core: Remove unused prefetch_stack() 2017-03-03 01:45:38 +01:00
err_inject.c ia64/err-inject: Convert to hotplug state machine 2016-11-09 23:45:29 +01:00
esi_stub.S ia64: move exports to definitions 2016-08-07 23:55:50 -04:00
esi.c
fsys.S ia64: remove paravirt code 2015-06-10 14:26:32 -07:00
fsyscall_gtod_data.h clocksource: Use a plain u64 instead of cycle_t 2016-12-25 11:04:12 +01:00
ftrace.c ia64: ftrace: Fix the comments for ftrace_modify_code() 2015-12-23 14:27:23 -05:00
gate-data.S
gate.lds.S ia64: remove paravirt code 2015-06-10 14:26:32 -07:00
gate.S ia64: remove paravirt code 2015-06-10 14:26:32 -07:00
head.S ia64: Convert vtime to use nsec units directly 2017-02-01 09:14:02 +01:00
ia64_ksyms.c ia64: move exports to definitions 2016-08-07 23:55:50 -04:00
init_task.c Replace <asm/uaccess.h> with <linux/uaccess.h> globally 2016-12-24 11:46:01 -08:00
iosapic.c ia64: rename nop->iosapic_nop 2016-01-12 20:46:47 +02:00
irq_ia64.c ia64: remove deprecated cpus_ usage. 2015-03-10 13:54:38 +10:30
irq_lsapic.c
irq.c Replace <asm/uaccess.h> with <linux/uaccess.h> globally 2016-12-24 11:46:01 -08:00
ivt.S ia64: move exports to definitions 2016-08-07 23:55:50 -04:00
jprobes.S
kprobes.c ia64: ensure exception table search users include extable.h 2017-01-24 12:41:45 -05:00
machine_kexec.c kexec: move vmcoreinfo out of the kernel's .bss section 2017-07-12 16:25:59 -07:00
machvec.c Disintegrate asm/system.h for IA64 2012-03-28 18:30:02 +01:00
Makefile kbuild: Consolidate header generation from ASM offset information 2017-04-13 05:43:37 +09:00
Makefile.gate ia64: thin archives fix linking 2017-06-30 09:03:04 +09:00
mca_asm.S
mca_drv_asm.S
mca_drv.c Remove cast for kmalloc return value 2013-03-19 16:14:53 -07:00
mca_drv.h
mca.c ia64: move inline before return type 2017-07-12 16:26:04 -07:00
minstate.h ia64: remove paravirt code 2015-06-10 14:26:32 -07:00
module.c ia64: fix module loading for gcc-5.4 2017-05-01 14:59:04 -07:00
msi_ia64.c ia64/irq: Use access helper irq_data_get_affinity_mask() 2015-07-27 13:36:37 +02:00
nr-irqs.c ia64/xen: Remove Xen support for ia64 2013-12-10 16:11:07 -08:00
numa.c ia64: fix up obsolete cpu function usage. 2015-03-05 15:25:04 +10:30
pal.S ia64: move exports to definitions 2016-08-07 23:55:50 -04:00
palinfo.c ia64/palinfo: Convert to hotplug state machine 2016-11-09 23:45:30 +01:00
patch.c ia64: remove paravirt code 2015-06-10 14:26:32 -07:00
pci-dma.c treewide: Constify most dma_map_ops structures 2017-01-24 12:23:35 -05:00
pci-swiotlb.c treewide: Constify most dma_map_ops structures 2017-01-24 12:23:35 -05:00
perfmon_default_smpl.c
perfmon_generic.h
perfmon_itanium.h
perfmon_mckinley.h
perfmon_montecito.h
perfmon.c sched/headers: Prepare for new header dependencies before moving code to <linux/sched/task_stack.h> 2017-03-02 08:42:36 +01:00
process.c sched/headers: Prepare for new header dependencies before moving code to <linux/sched/task_stack.h> 2017-03-02 08:42:36 +01:00
ptrace.c sched/headers: Prepare for new header dependencies before moving code to <linux/sched/task_stack.h> 2017-03-02 08:42:36 +01:00
relocate_kernel.S
sal.c
salinfo.c ia64/salinfo: Replace racy task affinity logic 2017-04-15 12:20:53 +02:00
setup.c sched/headers: Move task->mm handling methods to <linux/sched/mm.h> 2017-03-03 01:43:28 +01:00
sigframe.h
signal.c signal: Remove kernel interal si_code magic 2017-07-24 14:30:28 -05:00
smp.c ia64: fix up obsolete cpu function usage. 2015-03-05 15:25:04 +10:30
smpboot.c arch/hotplug: Call into idle with a proper state 2016-03-01 20:36:57 +01:00
stacktrace.c
sys_ia64.c sched/headers: Prepare for new header dependencies before moving code to <linux/sched/task_stack.h> 2017-03-02 08:42:36 +01:00
time.c sched/headers: Prepare to move cputime functionality from <linux/sched.h> into <linux/sched/cputime.h> 2017-03-02 08:42:39 +01:00
topology.c ia64/topology: Remove cpus_allowed manipulation 2017-04-15 12:20:52 +02:00
traps.c signal/ia64: Document a conflict with SI_USER with SIGFPE 2017-07-19 19:13:14 -05:00
unaligned.c sched/headers: Prepare for new header dependencies before moving code to <linux/sched/signal.h> 2017-03-02 08:42:29 +01:00
uncached.c sched/headers: Prepare for new header dependencies before moving code to <linux/sched/nmi.h> 2017-03-02 08:42:30 +01:00
unwind_decoder.c
unwind_i.h
unwind.c Replace <asm/uaccess.h> with <linux/uaccess.h> globally 2016-12-24 11:46:01 -08:00
vmlinux.lds.S debug: Fix __bug_table[] in arch linker scripts 2017-04-03 10:22:40 +02:00