]> git.ipfire.org Git - thirdparty/linux.git/commit
x86/kprobes: Prohibit kprobing on INT and UD
authorJinghao Jia <jinghao7@illinois.edu>
Wed, 6 Mar 2024 15:26:01 +0000 (00:26 +0900)
committerMasami Hiramatsu (Google) <mhiramat@kernel.org>
Wed, 6 Mar 2024 15:26:01 +0000 (00:26 +0900)
commite884edbb844fd6935e4368734edd9f3fa46ec5c2
tree140ed6c57dc6c34b1f92f78a8dff5a50838d0f20
parente4778a0ef322834718f8e42da3901eb99fef1208
x86/kprobes: Prohibit kprobing on INT and UD

Both INT (INT n, INT1, INT3, INTO) and UD (UD0, UD1, UD2) serve special
purposes in the kernel, e.g., INT3 is used by KGDB and UD2 is involved
in LLVM-KCFI instrumentation. At the same time, attaching kprobes on
these instructions (particularly UD) will pollute the stack trace dumped
in the kernel ring buffer, since the exception is triggered in the copy
buffer rather than the original location.

Check for INT and UD in can_probe and reject any kprobes trying to
attach to these instructions.

Link: https://lore.kernel.org/all/20240204031300.830475-3-jinghao7@illinois.edu/
Suggested-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Jinghao Jia <jinghao7@illinois.edu>
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
arch/x86/kernel/kprobes/core.c