objtool: Add UACCESS validation
It is important that UACCESS regions are as small as possible; furthermore the UACCESS state is not scheduled, so doing anything that might directly call into the scheduler will cause random code to be ran with UACCESS enabled. Teach objtool too track UACCESS state and warn about any CALL made while UACCESS is enabled. This very much includes the __fentry__() and __preempt_schedule() calls. Note that exceptions _do_ save/restore the UACCESS state, and therefore they can drive preemption. This also means that all exception handlers must have an otherwise redundant UACCESS disable instruction; therefore ignore this warning for !STT_FUNC code (exception handlers are not normal functions). Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Borislav Petkov <bp@alien8.de> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:

committed by
Ingo Molnar

parent
54262aa283
commit
ea24213d80
@@ -357,19 +357,26 @@ int arch_decode_instruction(struct elf *elf, struct section *sec,
|
||||
/* pushf */
|
||||
*type = INSN_STACK;
|
||||
op->src.type = OP_SRC_CONST;
|
||||
op->dest.type = OP_DEST_PUSH;
|
||||
op->dest.type = OP_DEST_PUSHF;
|
||||
break;
|
||||
|
||||
case 0x9d:
|
||||
/* popf */
|
||||
*type = INSN_STACK;
|
||||
op->src.type = OP_SRC_POP;
|
||||
op->src.type = OP_SRC_POPF;
|
||||
op->dest.type = OP_DEST_MEM;
|
||||
break;
|
||||
|
||||
case 0x0f:
|
||||
|
||||
if (op2 >= 0x80 && op2 <= 0x8f) {
|
||||
if (op2 == 0x01) {
|
||||
|
||||
if (modrm == 0xca)
|
||||
*type = INSN_CLAC;
|
||||
else if (modrm == 0xcb)
|
||||
*type = INSN_STAC;
|
||||
|
||||
} else if (op2 >= 0x80 && op2 <= 0x8f) {
|
||||
|
||||
*type = INSN_JUMP_CONDITIONAL;
|
||||
|
||||
|
Reference in New Issue
Block a user