All of lore.kernel.org
 help / color / mirror / Atom feed
* CONFIG_RETHUNK int3 filling prevents kprobes in function body
@ 2022-09-04 14:07 Masami Hiramatsu
  2022-09-05 14:57 ` Steven Rostedt
  2022-09-05 15:09 ` Peter Zijlstra
  0 siblings, 2 replies; 10+ messages in thread
From: Masami Hiramatsu @ 2022-09-04 14:07 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Borislav Petkov, Josh Poimboeuf, linux-kernel, Steven Rostedt,
	Ingo Molnar

Hi Peter,

I found that the CONFIG_RETHUNK code (path_return) fills the unused bytes
with int3 for padding. Unfortunately, this prevents kprobes on the function
body after the return code (e.g. branch blocks placed behind the return.)

This is because kprobes decodes function body to ensure the probed address
is an instruction boundary, and if it finds the 0xcc (int3), it stops
decoding and reject probing because the int3 is usually used for a
software breakpoint and is replacing some other instruction. Without
recovering the instruction, it can not continue decoding safely.

Can we use another instruction for padding instead of INT3? (e.g. NOP or UD2)

Or, can I expect the instruction length in __return_sites[] are always 5?
If so, I can just skip 5 bytes if the address is in __return_sites[].

Thank you,

-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-09-06  8:47 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-04 14:07 CONFIG_RETHUNK int3 filling prevents kprobes in function body Masami Hiramatsu
2022-09-05 14:57 ` Steven Rostedt
2022-09-05 15:10   ` Peter Zijlstra
2022-09-05 15:20     ` Peter Zijlstra
2022-09-06  1:30       ` Masami Hiramatsu
2022-09-05 15:09 ` Peter Zijlstra
2022-09-05 15:15   ` Peter Zijlstra
2022-09-05 15:52   ` Peter Zijlstra
2022-09-06  1:33     ` Masami Hiramatsu
2022-09-06  8:44       ` Peter Zijlstra

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.