1
0
Fork 0
remarkable-linux/arch/mips
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
..
alchemy MIPS: clockevent drivers: Set ->min_delta_ticks and ->max_delta_ticks 2017-04-14 13:11:16 -07:00
ar7 MIPS: Audit and remove any unnecessary uses of module.h 2017-02-14 09:00:25 +00:00
ath25 genirq: Remove irq argument from irq flow handlers 2015-09-16 15:47:51 +02:00
ath79 gpio: pcf857x: move header file out of I2C realm 2017-05-23 11:35:02 +02:00
bcm47xx MIPS: BCM47XX: Fix button inversion for Asus WL-500W 2017-02-17 11:16:46 +00:00
bcm63xx MIPS: Audit and remove any unnecessary uses of module.h 2017-02-14 09:00:25 +00:00
bmips MIPS: BMIPS: Support APPENDED_DTB 2016-10-06 17:31:02 +02:00
boot Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus 2017-07-15 10:59:54 -07:00
cavium-octeon Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus 2017-05-12 09:56:30 -07:00
cobalt MIPS: Cobalt: Fix typo 2016-08-03 08:16:30 +02:00
configs MIPS: generic: Support MIPS Boston development boards 2017-07-11 14:13:06 +02:00
dec format-security: move static strings to const 2017-05-08 17:15:14 -07:00
emma MIPS: Avoid old-style declaration 2017-01-25 02:51:11 +01:00
fw MIPS: Fix misspellings in comments. 2016-04-03 12:32:09 +02:00
generic Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus 2017-07-15 10:59:54 -07:00
include signal: Remove kernel interal si_code magic 2017-07-24 14:30:28 -05:00
jazz MIPS: Audit and remove any unnecessary uses of module.h 2017-02-14 09:00:25 +00:00
jz4740 MIPS: jz4740: Remove custom GPIO code 2017-05-22 17:26:34 +02:00
kernel signal: Remove kernel interal si_code magic 2017-07-24 14:30:28 -05:00
kvm PPC: 2017-07-06 18:38:31 -07:00
lantiq clk: Provide dummy of_clk_get_from_provider() for compile-testing 2017-06-02 10:51:34 -07:00
lasat MIPS: Audit and remove any unnecessary uses of module.h 2017-02-14 09:00:25 +00:00
lib Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus 2017-07-15 10:59:54 -07:00
loongson32 MIPS: clockevent drivers: Set ->min_delta_ticks and ->max_delta_ticks 2017-04-14 13:11:16 -07:00
loongson64 Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus 2017-07-15 10:59:54 -07:00
math-emu Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus 2017-07-15 10:59:54 -07:00
mm Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus 2017-07-15 10:59:54 -07:00
mti-malta clocksource/drivers: Rename clocksource_probe to timer_probe 2017-06-14 11:59:16 +02:00
net MIPS: Add support for eBPF JIT. 2017-06-28 12:22:39 +02:00
netlogic MIPS: Add missing include files 2017-03-08 10:38:06 +01:00
oprofile mips: sanitize __access_ok() 2017-04-06 02:08:06 -04:00
paravirt sched/headers: Prepare for new header dependencies before moving code to <linux/sched/task_stack.h> 2017-03-02 08:42:36 +01:00
pci MIPS: PCI: Remove unused busn_offset 2017-05-18 15:39:19 -05:00
pic32 clocksource/drivers: Rename clocksource_probe to timer_probe 2017-06-14 11:59:16 +02:00
pistachio clocksource/drivers: Rename clocksource_probe to timer_probe 2017-06-14 11:59:16 +02:00
pmcs-msp71xx MIPS: Audit and remove any unnecessary uses of module.h 2017-02-14 09:00:25 +00:00
pnx833x MIPS: Squash lines for simple wrapper functions 2016-10-04 16:13:57 +02:00
power MIPS: Hibernate: flush TLB entries earlier 2015-04-10 15:41:52 +02:00
ralink clocksource/drivers: Rename CLKSRC_OF to TIMER_OF 2017-06-14 12:01:03 +02:00
rb532 MIPS: Audit and remove any unnecessary uses of module.h 2017-02-14 09:00:25 +00:00
sgi-ip22 mips: sgi-ip22: ecard: use dev_groups and not dev_attrs for bus_type 2017-06-09 11:00:45 +02:00
sgi-ip27 MIPS: clockevent drivers: Set ->min_delta_ticks and ->max_delta_ticks 2017-04-14 13:11:16 -07:00
sgi-ip32 MIPS: Add missing include files 2017-03-08 10:38:06 +01:00
sibyte MIPS: Sibyte: Export symbol periph_rev to sb1250-mac network driver. 2017-04-21 03:23:24 +02:00
sni char/genrtc: remove asm-generic/rtc.h from mips 2016-06-04 00:23:36 +02:00
txx9 MIPS: Audit and remove any unnecessary uses of module.h 2017-02-14 09:00:25 +00:00
vdso MIPS: VDSO: Fix a mismatch between comment and preprocessor constant 2017-06-29 02:42:30 +02:00
vr41xx MIPS: Audit and remove any unnecessary uses of module.h 2017-02-14 09:00:25 +00:00
xilfpga clocksource/drivers: Rename clocksource_probe to timer_probe 2017-06-14 11:59:16 +02:00
Kbuild MIPS: Disable Werror when W= is set 2017-04-10 11:56:07 +02:00
Kbuild.platforms MIPS: generic: Convert SEAD-3 to a generic board 2016-10-06 18:04:20 +02:00
Kconfig Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus 2017-07-15 10:59:54 -07:00
Kconfig.debug MIPS: Sibyte: Fix Kconfig warning. 2017-04-21 03:34:01 +02:00
Makefile MIPS: build: Fix "-modd-spreg" switch usage when compiling for mips32r6 2017-06-29 02:42:23 +02:00
Makefile.postlink MIPS: Fix distclean with Makefile.postlink 2017-02-13 18:57:34 +00:00