exynos-linux-stable/arch/x86/mm
Kees Cook cfc386ec7b
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:

  cb87481ee89db ("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: 7a46ec0e2f48 ("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>
2023-04-30 19:49:35 +03:00
..
kmemcheck x86/mm: Audit and remove any unnecessary uses of module.h 2016-07-14 13:04:20 +02:00
amdtopology.c x86/mm/numa: Open code function early_get_boot_cpu_id() 2016-08-15 08:51:54 +02:00
debug_pagetables.c x86/mm/ptdump: Make (debugfs)/kernel_page_tables read-only 2015-12-04 12:55:01 +01:00
dump_pagetables.c x86/mm/ptdump: Fix soft lockup in page table walker 2017-02-14 15:25:41 -08:00
extable.c locking/refcounts, x86/asm: Use unique .text section for refcount exceptions 2023-04-30 19:49:35 +03:00
fault.c This is the 4.9.218 stable release 2020-04-02 19:44:57 +02:00
gup.c mm, gup: add missing refcount overflow checks on x86 and s390 2019-12-05 15:35:19 +01:00
highmem_32.c x86/mm: Audit and remove any unnecessary uses of module.h 2016-07-14 13:04:20 +02:00
hugetlbpage.c mm: larger stack guard gap, between vmas 2017-06-24 07:11:18 +02:00
ident_map.c x86/power/64: Always create temporary identity mapping correctly 2016-08-08 22:04:30 +02:00
init.c x86/speculation/l1tf: Drop the swap storage limit restriction when l1tf=off 2019-05-14 19:19:34 +02:00
init_32.c x86/mm: Audit and remove any unnecessary uses of module.h 2016-07-14 13:04:20 +02:00
init_64.c vfs/proc/kcore, x86/mm/kcore: Fix SMAP fault when dumping vsyscall user page 2018-05-30 07:50:26 +02:00
iomap_32.c x86/mm: Audit and remove any unnecessary uses of module.h 2016-07-14 13:04:20 +02:00
ioremap.c x86/mm/kmmio: Fix mmiotrace for page unaligned addresses 2018-02-25 11:05:49 +01:00
kaiser.c x86/speculation: Support 'mitigations=' cmdline option 2019-05-14 19:19:41 +02:00
kasan_init_64.c x86/kasan: Fix boot with KASAN=y and PROFILE_ANNOTATED_BRANCHES=y 2017-03-22 12:43:40 +01:00
kaslr.c KPTI: Rename to PAGE_TABLE_ISOLATION 2018-01-05 15:46:35 +01:00
kmmio.c x86/mm/kmmio: Make the tracer robust against L1TF 2018-08-15 18:14:54 +02:00
Makefile KPTI: Rename to PAGE_TABLE_ISOLATION 2018-01-05 15:46:35 +01:00
mm_internal.h x86: Enable PAT to use cache mode translation tables 2014-11-16 11:04:26 +01:00
mmap.c x86/speculation/l1tf: Fix off-by-one error when warning that system has too much RAM 2018-09-05 09:20:07 +02:00
mmio-mod.c x86/mm: Audit and remove any unnecessary uses of module.h 2016-07-14 13:04:20 +02:00
mpx.c x86/mpx: Correctly report do_mpx_bt_fault() failures to user-space 2017-07-05 14:40:29 +02:00
numa.c x86/numa: Online memory-less nodes at boot time 2016-09-21 21:18:38 +02:00
numa_32.c x86/mm/32: Set the '__vmalloc_start_set' flag in initmem_init() 2017-06-24 07:11:14 +02:00
numa_64.c x86, mm: kill numa_free_all_bootmem() 2012-11-17 11:59:47 -08:00
numa_emulation.c x86/numa_emulation: Fix emulated-to-physical node mapping 2018-10-03 17:01:42 -07:00
numa_internal.h x86-32, mm: Rip out x86_32 NUMA remapping code 2013-01-31 14:12:30 -08:00
pageattr-test.c x86/mm/pat: Make mm/pageattr[-test].c explicitly non-modular 2015-08-25 09:48:38 +02:00
pageattr.c x86/mm/pat: Make set_memory_np() L1TF safe 2018-08-15 18:14:54 +02:00
pat.c x86/mm/pat: Don't report PAT on CPUs that don't support it 2017-07-15 12:16:17 +02:00
pat_internal.h x86/mm/pat: Convert to pr_*() usage 2015-05-27 14:40:59 +02:00
pat_rbtree.c x86: Clean up various simple wrapper functions 2016-09-13 20:42:58 +02:00
pf_in.c x86/mm: Audit and remove any unnecessary uses of module.h 2016-07-14 13:04:20 +02:00
pf_in.h
pgtable.c x86/mm: Use the correct function type for native_set_fixmap() 2020-01-04 13:39:22 +01:00
pgtable_32.c Merge branch 'x86-headers-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2016-08-01 14:23:42 -04:00
physaddr.c x86/mm: Audit and remove any unnecessary uses of module.h 2016-07-14 13:04:20 +02:00
physaddr.h
pkeys.c x86/fpu: Finish excising 'eagerfpu' 2018-10-13 09:18:59 +02:00
setup_nx.c Revert "x86/mm/32: Set NX in __supported_pte_mask before enabling paging" 2016-04-26 19:52:57 +02:00
srat.c Merge branch 'x86-headers-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2016-08-01 14:23:42 -04:00
testmmiotrace.c
tlb.c x86/speculation: Prepare for conditional IBPB in switch_mm() 2019-05-14 19:19:38 +02:00