Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3339784ybl; Mon, 19 Aug 2019 17:03:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqxhEKJlIDc1UJlfoAboI18AB5FAff7wJjh4A9Z6CbPpLhI0pAzQErfsU73x5J/LomCrOiuf X-Received: by 2002:a65:68c8:: with SMTP id k8mr21981270pgt.192.1566259397506; Mon, 19 Aug 2019 17:03:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566259397; cv=none; d=google.com; s=arc-20160816; b=sGe7rPpjc9z7sVPXCC6gjxidVciRWDmsAVBDLBwVYNLCqnBQALBQxr5nByOepnJ7w2 PcbbuGIkxAO1iOWndJTLjIqImhkDjndaJukbAdOE1+VQaTFEr9ch3mxTt8aIwDnfmrzD 0HFVVW7vfnFkihSOjj9ph2TY7wIKfNT2bQpmn9/bywjAUgxkOW0e+HT4HRY58l1Vy8G0 J/vQOAFRU7Fd06evjX60z1/TRtinosQhjeYIkhch0nSzZkWM1GQkn0Za7QJ+kEe5CX3i 2CI52F4Fl0QKRHrD2hk6DrCTv+jr6u67XJXQ8QJ88AlvRjYYVX6zy5On4W2+/4qn8jJQ vMbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=hA6SLGyrANNmPql0/vAlr4uvDjeSKnRDgsMIdROmAy0=; b=Rm4L5IQyQI0IFiSX//vySRsA1IgRZwREBKAvIzS5OedvT3wXYagKculhxutwYADuRv P+I40BwspbnjDCq/JGAGMElTuNKUKGxs8YXxJY3b5l2vGDX/pnEhNlVo8Hs+wbnuFf/n tU7QauvahljNBUJ1+oryYnqg7hBM0ohUngUNxIm3jstpkGXqRZs7UDnhZu8G2OpAbd4s 4IFMHQ3P9ED39IAPWqkNBZ4FxIZhm6otjsz2BdjfKDyATJQ1WvEymGz7L9vtI3G5K/3r ZXdkUtWIP7JvBv7kqTNIMX7LlZakwSTta07FsFEIjyIz9WZ4sJe3Z/pMqHRcm4SXtKqY JT9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FRsrIwP7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 36si11078468pla.80.2019.08.19.17.03.01; Mon, 19 Aug 2019 17:03:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FRsrIwP7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728669AbfHTABh (ORCPT + 99 others); Mon, 19 Aug 2019 20:01:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:34434 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728578AbfHTABh (ORCPT ); Mon, 19 Aug 2019 20:01:37 -0400 Received: from devnote2 (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 472E82082F; Tue, 20 Aug 2019 00:01:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566259296; bh=Dygb+76S30NlTIz0E98ZuWWzV7OGS2DSaQKUzrhuObs=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=FRsrIwP79+XwJmcnEAvDLzIWZSmxMclwruPxmhgmjRCdJSaHwtKzRLl0WWC7CRXRK 95gazBM+n2Es4NcakK9McZLYoxqKpcDYTUyQQMkQxKvFGo1IKgusw0QFJndCBU9jVE xJ1GsnFxBziE8PutDAeUpVaZDFWqfVrSYgkPKuHE= Date: Tue, 20 Aug 2019 09:01:30 +0900 From: Masami Hiramatsu To: Jisheng Zhang Cc: Catalin Marinas , Will Deacon , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , "David S. Miller" , Anil S Keshavamurthy , "Naveen N. Rao" , Steven Rostedt , "x86@kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH 1/4] kprobes: adjust kprobe addr for KPROBES_ON_FTRACE Message-Id: <20190820090130.844fc064030db67efb05ceb1@kernel.org> In-Reply-To: <20190819192505.483c0bf0@xhacker.debian> References: <20190819192422.5ed79702@xhacker.debian> <20190819192505.483c0bf0@xhacker.debian> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jisheng, On Mon, 19 Aug 2019 11:36:09 +0000 Jisheng Zhang wrote: > For KPROBES_ON_FTRACE case, we need to adjust the kprobe's addr > correspondingly. No, I think you have misunderstood what the ftrace_call_adjust() does. Ftrace's rec->ip is already adjusted when initializing it. Kprobes checks the list after initialized (adjusted). So you don't need to adjust it again. BTW, this type of hidden adjustment should be avoided by design. If you find user specifies wrong address, return error instead of adjust it silently. Thank you, > > Signed-off-by: Jisheng Zhang > --- > kernel/kprobes.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/kernel/kprobes.c b/kernel/kprobes.c > index 9873fc627d61..f8400753a8a9 100644 > --- a/kernel/kprobes.c > +++ b/kernel/kprobes.c > @@ -1560,6 +1560,9 @@ int register_kprobe(struct kprobe *p) > addr = kprobe_addr(p); > if (IS_ERR(addr)) > return PTR_ERR(addr); > +#ifdef CONFIG_KPROBES_ON_FTRACE > + addr = (kprobe_opcode_t *)ftrace_call_adjust((unsigned long)addr); > +#endif > p->addr = addr; > > ret = check_kprobe_rereg(p); > -- > 2.23.0.rc1 > -- Masami Hiramatsu