Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758868AbYKWPEV (ORCPT ); Sun, 23 Nov 2008 10:04:21 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1758237AbYKWPEL (ORCPT ); Sun, 23 Nov 2008 10:04:11 -0500 Received: from qb-out-0506.google.com ([72.14.204.235]:53321 "EHLO qb-out-0506.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758227AbYKWPEJ (ORCPT ); Sun, 23 Nov 2008 10:04:09 -0500 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=Ry+UgaWtUNKMg8P7KzTAlvmDbHLI3YIqiLtspQNkP+7nqzlYex6XeWHpkYpa59Ar11 BgkjETjL6eRP5cD7/TKpRweq9XQwcHYocGV8FBs+b8aw2CTqoD0br4kRn9x2K4lHXLsy zX1kuMLgkr7kqATyft9TpoCVo4+deCV5D5syI= Date: Sun, 23 Nov 2008 18:04:06 +0300 From: Cyrill Gorcunov To: Ingo Molnar Cc: Alexander van Heukelum , LKML , "H. Peter Anvin" , Jan Beulich , Thomas Gleixner Subject: Re: [PATCH] x86: KPROBE_ENTRY should be paired wth KPROBE_END Message-ID: <20081123150406.GA27396@localhost> References: <20081121154155.GA12999@mailshack.com> <20081121154318.GA13014@mailshack.com> <20081121154428.GB13014@mailshack.com> <20081121160629.GA24839@elte.hu> <20081123090828.GA31490@mailshack.com> <20081123091532.GA31515@mailshack.com> <20081123132752.GF1178@elte.hu> <20081123135134.GH24818@localhost> <20081123141237.GI24818@localhost> <20081123145554.GA3224@elte.hu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20081123145554.GA3224@elte.hu> User-Agent: Mutt/1.5.17+20080114 (2008-01-14) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3465 Lines: 105 [Ingo Molnar - Sun, Nov 23, 2008 at 03:55:54PM +0100] | | * 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 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 | > | | | > | | 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) | > | > will fail like | > | > cyrill@lenovo linux-2.6.git $ make arch/x86/kernel/entry_64.o | > CHK include/linux/version.h | > CHK include/linux/utsrelease.h | > SYMLINK include/asm -> include/asm-x86 | > CALL scripts/checksyscalls.sh | > AS arch/x86/kernel/entry_64.o | > arch/x86/kernel/entry_64.S: Assembler messages: | > arch/x86/kernel/entry_64.S:84: Error: END should be used | > arch/x86/kernel/entry_64.S:84: Fatal error: .abort detected. Abandoning ship. | > make[1]: *** [arch/x86/kernel/entry_64.o] Error 1 | > make: *** [arch/x86/kernel/entry_64.o] Error 2 | > cyrill@lenovo linux-2.6.git $ | > | > So if such an approach is acceptable (in general) -- I could take a | > more deeper look. So every ENTRY would check if other ENTRY/KPROBE | > is active and report that. | | looks good! | | Can we somehow detect a missing .cfi_endproc? That's another pattern | i've seen. | | Ingo | As only I finish with this pattern we could add anything we need :) Will keep you in touch. - Cyrill - -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/