mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-04 20:19:47 +08:00

For X86_FEATURE_SMAP alternatives which replace NOP with STAC or CLAC,
uaccess validation skips the NOP branch to avoid following impossible
code paths, e.g. where a STAC would be patched but a CLAC wouldn't.
However, it's not safe to assume an X86_FEATURE_SMAP alternative is
patching STAC/CLAC. There can be other alternatives, like
static_cpu_has(), where both branches need to be validated.
Fix that by repurposing ANNOTATE_IGNORE_ALTERNATIVE for skipping either
original instructions or new ones. This is a more generic approach
which enables the removal of the feature checking hacks and the
insn->ignore bit.
Fixes the following warnings:
arch/x86/mm/fault.o: warning: objtool: do_user_addr_fault+0x8ec: __stack_chk_fail() missing __noreturn in .c/.h or NORETURN() in noreturns.h
arch/x86/mm/fault.o: warning: objtool: do_user_addr_fault+0x8f1: unreachable instruction
[ mingo: Fix up conflicts with recent x86 changes. ]
Fixes: ea24213d80
("objtool: Add UACCESS validation")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://lore.kernel.org/r/de0621ca242130156a55d5d74fed86994dfa4c9c.1742852846.git.jpoimboe@kernel.org
Closes: https://lore.kernel.org/oe-kbuild-all/202503181736.zkZUBv4N-lkp@intel.com/
42 lines
943 B
C
42 lines
943 B
C
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
/*
|
|
* Copyright (C) 2015 Josh Poimboeuf <jpoimboe@redhat.com>
|
|
*/
|
|
|
|
#ifndef _SPECIAL_H
|
|
#define _SPECIAL_H
|
|
|
|
#include <stdbool.h>
|
|
#include <objtool/check.h>
|
|
#include <objtool/elf.h>
|
|
|
|
#define C_JUMP_TABLE_SECTION ".data.rel.ro.c_jump_table"
|
|
|
|
struct special_alt {
|
|
struct list_head list;
|
|
|
|
bool group;
|
|
bool jump_or_nop;
|
|
u8 key_addend;
|
|
|
|
struct section *orig_sec;
|
|
unsigned long orig_off;
|
|
|
|
struct section *new_sec;
|
|
unsigned long new_off;
|
|
|
|
unsigned int orig_len, new_len; /* group only */
|
|
};
|
|
|
|
int special_get_alts(struct elf *elf, struct list_head *alts);
|
|
|
|
void arch_handle_alternative(struct special_alt *alt);
|
|
|
|
bool arch_support_alt_relocation(struct special_alt *special_alt,
|
|
struct instruction *insn,
|
|
struct reloc *reloc);
|
|
struct reloc *arch_find_switch_table(struct objtool_file *file,
|
|
struct instruction *insn,
|
|
unsigned long *table_size);
|
|
#endif /* _SPECIAL_H */
|