From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4694 invoked by alias); 13 Sep 2009 10:07:33 -0000 Received: (qmail 4687 invoked by uid 22791); 13 Sep 2009 10:07:33 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,SPF_SOFTFAIL X-Spam-Check-By: sourceware.org Received: from e32.co.us.ibm.com (HELO e32.co.us.ibm.com) (32.97.110.150) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 13 Sep 2009 10:07:29 +0000 Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by e32.co.us.ibm.com (8.14.3/8.13.1) with ESMTP id n8DA2sRK013373 for ; Sun, 13 Sep 2009 04:02:54 -0600 Received: from d03av03.boulder.ibm.com (d03av03.boulder.ibm.com [9.17.195.169]) by d03relay04.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id n8DA7RGG213912 for ; Sun, 13 Sep 2009 04:07:27 -0600 Received: from d03av03.boulder.ibm.com (loopback [127.0.0.1]) by d03av03.boulder.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n8DA7PMM003833 for ; Sun, 13 Sep 2009 04:07:27 -0600 Received: from thinktux.in.ibm.com ([9.124.223.31]) by d03av03.boulder.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id n8DA7NvM003807; Sun, 13 Sep 2009 04:07:24 -0600 Received: by thinktux.in.ibm.com (Postfix, from userid 500) id 56D0B89BD3; Sun, 13 Sep 2009 15:37:13 +0530 (IST) Date: Sun, 13 Sep 2009 10:07:00 -0000 From: Ananth N Mavinakayanahalli To: Frederic Weisbecker , Masami Hiramatsu Cc: Steven Rostedt , Ingo Molnar , lkml , systemtap , DLE , Jim Keniston , Andi Kleen , Christoph Hellwig , "Frank Ch. Eigler" , "H. Peter Anvin" , Jason Baron , "K.Prasad" , Lai Jiangshan , Li Zefan , Peter Zijlstra , Srikar Dronamraju , Tom Zanussi Subject: [BUGFIX] kprobes: prevent re-registration of the same kprobe Message-ID: <20090913100713.GB14251@in.ibm.com> Reply-To: ananth@in.ibm.com References: <20090910235258.22412.29317.stgit@dhcp-100-2-132.bos.redhat.com> <20090910235329.22412.94731.stgit@dhcp-100-2-132.bos.redhat.com> <20090911031253.GD16396@nowhere> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20090911031253.GD16396@nowhere> User-Agent: Mutt/1.5.17 (2007-11-01) X-IsSubscribed: yes Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org X-SW-Source: 2009-q3/txt/msg00700.txt.bz2 On Fri, Sep 11, 2009 at 05:12:54AM +0200, Frederic Weisbecker wrote: > On Thu, Sep 10, 2009 at 07:53:30PM -0400, Masami Hiramatsu wrote: ... > Is it possible to have two kprobes having the exact same > properties? (pointing to the same address, having the same > probe handlers, etc...) Yes, this is possible with two *different* kprobes. However, we have a bug with the current code where there is insufficient scaffolding to prevent re-registration of the same kprobe. Here is a patch... --- Prevent re-registration of the same kprobe. Current code allows this, albeit with disastrous consequences. Its not a common case, but should be flagged nonetheless. Signed-off-by: Ananth N Mavinakayanahalli --- kernel/kprobes.c | 3 +++ 1 file changed, 3 insertions(+) Index: ptrace-10sep/kernel/kprobes.c =================================================================== --- ptrace-10sep.orig/kernel/kprobes.c +++ ptrace-10sep/kernel/kprobes.c @@ -589,6 +589,9 @@ static int __kprobes register_aggr_kprob int ret = 0; struct kprobe *ap = old_p; + if (old_p == p) + /* Attempt to re-register the same kprobe.. fail */ + return -EINVAL; if (old_p->pre_handler != aggr_pre_handler) { /* If old_p is not an aggr_probe, create new aggr_kprobe. */ ap = kzalloc(sizeof(struct kprobe), GFP_KERNEL);