CVE-2022-49721 Information
Description
In the Linux kernel the following vulnerability has been resolved:
arm64: ftrace: consistently handle PLTs.
Sometimes it is necessary to use a PLT entry to call an ftrace trampoline. This is handled by ftrace_make_call() and ftrace_make_nop() with each having almost identical logic but this is not handled by ftrace_modify_call() since its introduction in commit:
3b23e4991fb66f6d (rm64: implement ftrace with regs)
Due to this if we ever were to call ftrace_modify_call() for a callsite which requires a PLT entry for a trampoline then either:
a) If the old addr requires a trampoline ftrace_modify_call() will use an out-of-range address to generate the ‘old’ branch instruction. This will result in warnings from aarch64_insn_gen_branch_imm() and ftrace_modify_code() and no instructions will be modified. As ftrace_modify_call() will return an error this will result in subsequent internal ftrace errors.
b) If the old addr does not require a trampoline but the new addr does ftrace_modify_call() will use an out-of-range address to generate the ’new’ branch instruction. This will result in warnings from aarch64_insn_gen_branch_imm() and ftrace_modify_code() will replace the ‘old’ branch with a BRK. This will result in a kernel panic when this BRK is later executed.
Practically speaking case (a) is vastly more likely than case (b) and typically this will result in internal ftrace errors that don’t necessarily affect the rest of the system. This can be demonstrated with an out-of-tree test module which triggers ftrace_modify_call() e.g.
| insmod test_ftrace.ko
| test_ftrace: Function test_function raw=0xffffb3749399201c callsite=0xffffb37493992024
| branch_imm_common: offset out of range
| branch_imm_common: offset out of range
| ————[ ftrace bug ]————
| ftrace failed to modify
| [
We can solve this by consistently determining whether to use a PLT entry for an address.
Note that since (the earlier) commit:
f1a54ae9
truncated—
Reference
https://git.kernel.org/stable/c/a6253579977e4c6f7818eeb05bf2bc65678a7187 https://git.kernel.org/stable/c/bc28fde90937a920f7714ec4408269cac744f796 https://git.kernel.org/stable/c/db73aa9466338ec821ed2a0b01721fe4d06876b1 https://git.kernel.org/stable/c/dcecc96ed16f73417de5550f384e348c9d56f279
Share on: