Kees Cook
564c9cc84e
locking/refcounts, x86/asm: Use unique .text section for refcount exceptions
...
Using .text.unlikely for refcount exceptions isn't safe because gcc may
move entire functions into .text.unlikely (e.g. in6_dev_dev()), which
would cause any uses of a protected refcount_t function to stay inline
with the function, triggering the protection unconditionally:
.section .text.unlikely,"ax",@progbits
.type in6_dev_get, @function
in6_dev_getx:
.LFB4673:
.loc 2 4128 0
.cfi_startproc
...
lock; incl 480(%rbx)
js 111f
.pushsection .text.unlikely
111: lea 480(%rbx), %rcx
112: .byte 0x0f, 0xff
.popsection
113:
This creates a unique .text..refcount section and adds an additional
test to the exception handler to WARN in the case of having none of OF,
SF, nor ZF set so we can see things like this more easily in the future.
The double dot for the section name keeps it out of the TEXT_MAIN macro
namespace, to avoid collisions and so it can be put at the end with
text.unlikely to keep the cold code together.
See commit:
cb87481ee8 ("kbuild: linker script do not match C names unless LD_DEAD_CODE_DATA_ELIMINATION is configured")
... which matches C names: [a-zA-Z0-9_] but not ".".
Reported-by: Mike Galbraith <efault@gmx.de>
Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Elena <elena.reshetova@intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-arch <linux-arch@vger.kernel.org>
Fixes: 7a46ec0e2f ("locking/refcounts, x86/asm: Implement fast refcount overflow protection")
Link: http://lkml.kernel.org/r/1504382986-49301-2-git-send-email-keescook@chromium.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2017-09-28 09:45:05 +02:00
..
bitops
bitops: Do not default to __clear_bit() for __clear_bit_unlock()
2016-03-21 10:50:48 +01:00
4level-fixup.h
asm-generic: introduce 5level-fixup.h
2017-03-09 11:48:47 -08:00
5level-fixup.h
asm-generic: introduce 5level-fixup.h
2017-03-09 11:48:47 -08:00
asm-offsets.h
asm-generic: Add common asm-offsets.h
2015-06-23 13:35:49 +09:00
asm-prototypes.h
asm-prototypes: Clear any CPP defines before declaring the functions
2017-01-05 12:57:42 +01:00
atomic-long.h
locking/atomic: Introduce inc/dec variants for the atomic_fetch_$op() API
2016-07-07 09:16:20 +02:00
atomic.h
openrisc: add optimized atomic operations
2017-02-25 04:14:06 +09:00
atomic64.h
locking/atomic: Fix atomic_set_release() for 'funny' architectures
2017-08-10 12:28:54 +02:00
audit_change_attr.h
audit_dir_write.h
audit_read.h
audit_signal.h
audit_write.h
barrier.h
locking/spinlock, arch: Update and fix spin_unlock_wait() implementations
2016-06-14 11:55:15 +02:00
bitops.h
bitsperlong.h
bug.h
asm-generic/bug.h: declare struct pt_regs; before function prototype
2017-07-10 16:32:34 -07:00
bugs.h
cache.h
cacheflush.h
checksum.h
ipv4: Update parameters for csum_tcpudp_magic to their original types
2016-03-13 23:55:13 -04:00
clkdev.h
cmpxchg-local.h
cmpxchg.h
asm-generic: cmpxchg: avoid warnings from macro-ized cmpxchg() implementations
2015-10-15 00:21:13 +02:00
current.h
delay.h
device.h
div64.h
__div64_32(): make it overridable at compile time
2015-11-16 14:42:12 -05:00
dma-contiguous.h
dma.h
early_ioremap.h
x86/mm: Extend early_memremap() support with additional attrs
2017-07-18 11:38:00 +02:00
emergency-restart.h
exec.h
export.h
modversions: treat symbol CRCs as 32 bit quantities
2017-02-03 08:28:25 -08:00
extable.h
add asm-generic/extable.h
2017-03-27 20:27:28 -04:00
fb.h
fixmap.h
asm-generic: Fix local variable shadow in __set_fixmap_offset
2016-02-16 15:10:44 +00:00
ftrace.h
futex.h
futex: Remove duplicated code and fix undefined behaviour
2017-08-25 22:49:59 +02:00
getorder.h
gpio.h
gpio: allow setting ARCH_NR_GPIOS from Kconfig
2016-02-19 00:22:54 +01:00
hardirq.h
hugetlb.h
mm/hugetlb: allow architectures to override huge_pte_clear()
2017-07-06 16:24:34 -07:00
hw_irq.h
ide_iops.h
int-ll64.h
io.h
x86/io: Remove xlate_dev_kmem_ptr() duplication
2017-07-24 11:18:21 +02:00
ioctl.h
iomap.h
asm-generic/io.h: add io{read,write}64 accessors
2016-05-31 16:41:50 +08:00
irq.h
irq_regs.h
irq_work.h
irqflags.h
kdebug.h
kmap_types.h
kprobes.h
kprobes: move kprobe declarations to asm-generic/kprobes.h
2017-02-27 18:43:45 -08:00
kvm_para.h
linkage.h
local.h
local64.h
mcs_spinlock.h
memory_model.h
mm: add PHYS_PFN, use it in __phys_to_pfn()
2016-01-14 16:00:49 -08:00
mm-arch-hooks.h
mm: clean up per architecture MM hook header files
2015-07-17 16:39:53 -07:00
mm_hooks.h
mm/gup: Drop the arch_pte_access_permitted() MMU callback
2017-03-18 09:48:01 +01:00
mmu.h
mmu_context.h
module.h
msi.h
page.h
asm-generic: page.h: Remove useless get_user_page and free_user_page
2016-02-26 15:24:55 +01:00
param.h
parport.h
pci.h
PCI: Remove unused pcibios_select_root() (again)
2015-06-08 07:56:21 -05:00
pci_iomap.h
PCI: Add pci_iomap_wc() variants
2015-08-25 09:59:45 +02:00
percpu.h
percpu: use notrace variant of preempt_disable/preempt_enable
2016-11-08 10:29:44 +01:00
pgalloc.h
pgtable-nop4d-hack.h
asm-generic: introduce __ARCH_USE_5LEVEL_HACK
2017-03-09 11:48:47 -08:00
pgtable-nop4d.h
asm-generic: introduce <asm-generic/pgtable-nop4d.h>
2017-03-09 11:48:47 -08:00
pgtable-nopmd.h
pgtable-nopud.h
asm-generic: introduce <asm-generic/pgtable-nop4d.h>
2017-03-09 11:48:47 -08:00
pgtable.h
mm: soft-dirty: keep soft-dirty bits over thp migration
2017-09-08 18:26:45 -07:00
preempt.h
sched/preempt: Fix preempt_count manipulations
2016-05-17 12:24:21 +02:00
ptrace.h
qrwlock.h
locking/qrwlock: Fix write unlock bug on big endian systems
2016-08-10 14:13:27 +02:00
qrwlock_types.h
locking/qrwlock: Rename ->lock to ->wait_lock
2015-09-18 09:27:29 +02:00
qspinlock.h
locking: Remove spin_unlock_wait() generic definitions
2017-08-17 08:08:58 -07:00
qspinlock_types.h
locking/qspinlock: Move __ARCH_SPIN_LOCK_UNLOCKED to qspinlock_types.h
2016-02-29 10:02:43 +01:00
resource.h
rwsem.h
locking/rwsem: Remove unnecessary atomic_long_t casts
2017-01-20 09:46:44 +01:00
seccomp.h
seccomp: Get compat syscalls from asm-generic header
2016-05-13 14:02:00 +02:00
sections.h
irq: Make the irqentry text section unconditional
2017-08-10 16:28:53 +02:00
segment.h
serial.h
set_memory.h
treewide: move set_memory_* functions away from cacheflush.h
2017-05-08 17:15:13 -07:00
signal.h
simd.h
sizes.h
spinlock.h
statfs.h
string.h
switch_to.h
syscall.h
syscalls.h
termios-base.h
Replace <asm/uaccess.h> with <linux/uaccess.h> globally
2016-12-24 11:46:01 -08:00
termios.h
Replace <asm/uaccess.h> with <linux/uaccess.h> globally
2016-12-24 11:46:01 -08:00
timex.h
tlb.h
mm: fix MADV_[FREE|DONTNEED] TLB flush miss problem
2017-08-10 15:54:07 -07:00
tlbflush.h
topology.h
cpumask: fix spurious cpumask_of_node() on non-NUMA multi-node configs
2017-08-28 16:13:16 -07:00
trace_clock.h
uaccess.h
fix the __user misannotations in asm-generic get_user/put_user
2017-09-04 12:07:24 -04:00
unaligned.h
unistd.h
user.h
vga.h
vmlinux.lds.h
locking/refcounts, x86/asm: Use unique .text section for refcount exceptions
2017-09-28 09:45:05 +02:00
vtime.h
word-at-a-time.h
Make asm/word-at-a-time.h available on all architectures
2015-07-08 16:41:55 -04:00
xor.h