Re: [PATCH] x86: KPROBE_ENTRY should be paired wth KPROBE_END

From: Cyrill Gorcunov
Date: Sun Nov 23 2008 - 10:41:24 EST


[Ingo Molnar - Sun, Nov 23, 2008 at 04:31:40PM +0100]
|
| * Cyrill Gorcunov <gorcunov@xxxxxxxxx> wrote:
|
| > [Alexander van Heukelum - Sun, Nov 23, 2008 at 04:04:18PM +0100]
| > | On Sun, Nov 23, 2008 at 05:12:37PM +0300, Cyrill Gorcunov wrote:
| > | > [Cyrill Gorcunov - Sun, Nov 23, 2008 at 04:51:34PM +0300]
| > | > | [Ingo Molnar - Sun, Nov 23, 2008 at 02:27:52PM +0100]
| > | > | |
| > | > | | * Alexander van Heukelum <heukelum@xxxxxxxxxxxxx> wrote:
| > | > | |
| > | > | | > Impact: moves some code out of .kprobes.text
| > | > | | >
| > | > | | > KPROBE_ENTRY switches code generation to .kprobes.text, and KPROBE_END
| > | > | | > uses .popsection to get back to the previous section (.text, normally).
| > | > | | > Also replace ENDPROC by END, for consistency.
| > | > | | >
| > | > | | > Signed-off-by: Alexander van Heukelum <heukelum@xxxxxxxxxxx>
| > | > | |
| > | > | | applied to tip/x86/irq, thanks Alexander!
| > | > | |
| > | > | | > One more small change for today. The xen-related functions
| > | > | | > xen_do_hypervisor_callback and xen_failsafe_callback are put
| > | > | | > in the .kprobes.text even in the current kernel: ignore_sysret
| > | > | | > is enclosed in KPROBE_ENTRY / ENDPROC, instead of KPROBE_ENTRY /
| > | > | | > KPROBE_END, but I guess the situation is harmless.
| > | > | |
| > | > | | yeah. It narrows no-kprobes protection for that code, but it should
| > | > | | indeed be fine (and that's the intention as well).
| > | > | |
| > | > | | Note that this is a reoccuring bug type, and rather long-lived. Can
| > | > | | you think of any way to get automated nesting protection of both the
| > | > | | .cfi_startproc/endproc macros and kprobes start/end? A poor man's
| > | > | | solution would be to grep the number of start and end methods and
| > | > | | enforce that they are equal.
| > | > | |
| > | > | | Ingo
| > | > | |
| > | > |
| > | > | I think we could play with preprocessor and check if ENTRY/END matches.
| > | > | Looking now.
| > | > |
| > | > | - Cyrill -
| > | >
| > | > Here is what I've done
| > | >
| > | > 1) Add some macros like:
| > | >
| > | > .macro __set_entry
| > | > .set _ENTRY_IN, 1
| > | > .endm
| > | >
| > | > .macro __unset_entry
| > | > .set _ENTRY_IN, 0
| > | > .endm
| > | >
| > | > .macro __check_entry
| > | > .ifeq _ENTRY_IN
| > | > .error "END should be used"
| > | > .abort
| > | > .endif
| > | > .endm
| > | >
| > | > So the code
| > | >
| > | > ENTRY(mcount)
| > | > __unset_entry
| > | > retq
| > | > __check_entry
| > | > END(mcount)
| > |
| > | Looks like a good approach to me. But I assume the ENTRY cppmacro
| > | will include magic?
| > |
| > | Greetings,
| > | Alexander
| > |
| >
| > yes, but now I'm in doubts since we have this definition in common
| > linkage.h I dont know if such approach would be usable on other
| > platforms.
|
| i'd suggest to introduce another entry macro name for that, for the
| time being. If other architectures want to pick up the method, they
| can generalize and test it.
|
| ( but this is assembly magic so i'm doubtful - while the features used
| are generic GAS features that should work everywhere, binutils
| variants tend to be rather fragile. So lets go with some other name
| like X86_ENTRY()/X86_END() or so - or maybe ENTRY_CFI()/END_CFI(). )
|
| Ingo
|

Indeed! I've just sent some quite raw version. Maybe we should introduce
asmmacro.h as ia64 did?

- Cyrill -
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/