/* * Returns the target address and the expected type when regs->ip points * to a compiler-generated CFI trap.
*/ staticbool decode_cfi_insn(struct pt_regs *regs, unsignedlong *target,
u32 *type)
{ char buffer[MAX_INSN_SIZE]; struct insn insn; int offset = 0;
*target = *type = 0;
/* * The compiler generates the following instruction sequence * for indirect call checks: * * movl -<id>, %r10d ; 6 bytes * addl -4(%reg), %r10d ; 4 bytes * je .Ltmp1 ; 2 bytes * ud2 ; <- regs->ip * .Ltmp1: * * We can decode the expected type and the target address from the * movl/addl instructions.
*/ if (copy_from_kernel_nofault(buffer, (void *)regs->ip - 12, MAX_INSN_SIZE)) returnfalse; if (insn_decode_kernel(&insn, &buffer[offset])) returnfalse; if (insn.opcode.value != 0xBA) returnfalse;
*type = -(u32)insn.immediate.value;
if (copy_from_kernel_nofault(buffer, (void *)regs->ip - 6, MAX_INSN_SIZE)) returnfalse; if (insn_decode_kernel(&insn, &buffer[offset])) returnfalse; if (insn.opcode.value != 0x3) returnfalse;
/* Read the target address from the register. */
offset = insn_get_modrm_rm_off(&insn, regs); if (offset < 0) returnfalse;
/* * Checks if a ud2 trap is because of a CFI failure, and handles the trap * if needed. Returns a bug_trap_type value similarly to report_bug.
*/ enum bug_trap_type handle_cfi_failure(struct pt_regs *regs)
{ unsignedlong target, addr = regs->ip;
u32 type;
switch (cfi_mode) { case CFI_KCFI: if (!is_cfi_trap(addr)) return BUG_TRAP_TYPE_NONE;
if (!decode_cfi_insn(regs, &target, &type)) return report_cfi_failure_noaddr(regs, addr);
break;
case CFI_FINEIBT: if (!decode_fineibt_insn(regs, &target, &type)) return BUG_TRAP_TYPE_NONE;
/* * Ensure that __kcfi_typeid_ symbols are emitted for functions that may * not be indirectly called with all configurations.
*/
__ADDRESSABLE(__memcpy)
Messung V0.5
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.