Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3850372ybl; Tue, 20 Aug 2019 03:16:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqzMkv8xQIW0/y0RP4NTiCfz4gZh4dIuNI8JsB1hugat86vKrYZLo5zRORPyW0AQ3ELtpWQ1 X-Received: by 2002:a63:ec03:: with SMTP id j3mr24900434pgh.325.1566296201482; Tue, 20 Aug 2019 03:16:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566296201; cv=none; d=google.com; s=arc-20160816; b=joC5eSIszZrmns6xJ6p9k+qOUDPNR6G92A1IAfsjg98tvvcTuP8RNSMi2Et7dJoEML WzkBiNKCzB74Ew06UCkyR0NQNpsiLmrknIDlVQdPy6EdVBO2xbFj1OVmimokBkdacb/H MbmizlSvz3ZjRhldZjrX6qszcKt7S6fQJEA9pCK3kGZIoHoopS0I+YDUCYraefuS4YzJ J5UjW+OFH0+1Ofq2OaAIU8IizUzUYdo5mnDE3tDIW5SbFLyotbSmr3ZAT5MyBndrDcxz Qq8Psd3TXISzzN38Lu2ECKcRraFuwygcvyhNzUAGOL5mt1cbaT7IlarBoHn5LP8aJce5 rW7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :user-agent:mime-version:in-reply-to:references:cc:to:subject:from :date; bh=hK9Rhzb/PniWnnMLsb4hqYo3iRlQB4zup6HTGtv5GCg=; b=K/1RFt3nX8fzuoJr+H8ya+kWAfdIuXiHP31bNd+jgdo5xx54CkXEpf5yeOr+PEDX3r Fmkq4KTT2dKj/GWcEEJAjNZYEDt2zGf59RCQAsebsiV7pUelrw0nDT7HpHNO/LWVYcKJ J6XZHbKmO/PHsl0vm0QkqhlqKVrof0rrEU4wCst6UuFJbGcoRyzQaQQtEycXM18gmZe4 IOOnxU9kDkFsanLbc00zJ4/e1gIORDWIndIplXWfNbSoVSwnFgNxas8EsG8/R/f59/wy x/8+r0eIiT6zvzP1VJpYspXX0u0ws4HlP0cwDUDnQPQRwYd16t/0YK87aiit9Myw+hjY v5cQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v24si11906066pgn.64.2019.08.20.03.16.25; Tue, 20 Aug 2019 03:16:41 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729494AbfHTKPg convert rfc822-to-8bit (ORCPT + 99 others); Tue, 20 Aug 2019 06:15:36 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:17506 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728545AbfHTKPg (ORCPT ); Tue, 20 Aug 2019 06:15:36 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x7KABgRI100730 for ; Tue, 20 Aug 2019 06:15:34 -0400 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0b-001b2d01.pphosted.com with ESMTP id 2ugefpsdtk-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 20 Aug 2019 06:15:34 -0400 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 20 Aug 2019 11:15:32 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp02.uk.ibm.com (192.168.101.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 20 Aug 2019 11:15:28 +0100 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x7KAFRgd61145098 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Aug 2019 10:15:27 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 03FDA4C062; Tue, 20 Aug 2019 10:15:27 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6B3C64C04A; Tue, 20 Aug 2019 10:15:26 +0000 (GMT) Received: from localhost (unknown [9.199.61.204]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 20 Aug 2019 10:15:26 +0000 (GMT) Date: Tue, 20 Aug 2019 15:45:24 +0530 From: "Naveen N. Rao" Subject: Re: [PATCH v2 2/3] kprobes: adjust kprobe addr for KPROBES_ON_FTRACE To: Anil =?iso-8859-1?q?S=0A?= Keshavamurthy , Borislav Petkov , Catalin Marinas , Jonathan Corbet , "David S. Miller" , "H. Peter Anvin" , Jisheng Zhang , Masami Hiramatsu , Ingo Molnar , Thomas Gleixner , Will Deacon , "x86@kernel.org" Cc: "linux-arm-kernel@lists.infradead.org" , "linux-doc@vger.kernel.org" , "linux-kernel@vger.kernel.org" References: <20190820113928.1971900c@xhacker.debian> <20190820114224.0c8963c4@xhacker.debian> In-Reply-To: <20190820114224.0c8963c4@xhacker.debian> MIME-Version: 1.0 User-Agent: astroid/0.15.0 (https://github.com/astroidmail/astroid) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8BIT X-TM-AS-GCONF: 00 x-cbid: 19082010-0008-0000-0000-0000030B00B9 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19082010-0009-0000-0000-00004A29275C Message-Id: <1566295437.yqnot2qd2e.naveen@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-08-20_03:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908200108 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Jisheng Zhang wrote: > For KPROBES_ON_FTRACE case, we need to adjust the kprobe's addr > correspondingly. > > Signed-off-by: Jisheng Zhang > --- > kernel/kprobes.c | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > diff --git a/kernel/kprobes.c b/kernel/kprobes.c > index 9873fc627d61..3fd2f68644da 100644 > --- a/kernel/kprobes.c > +++ b/kernel/kprobes.c > @@ -1484,15 +1484,19 @@ static inline int check_kprobe_rereg(struct kprobe *p) > > int __weak arch_check_ftrace_location(struct kprobe *p) > { > - unsigned long ftrace_addr; > + unsigned long ftrace_addr, addr = (unsigned long)p->addr; > > - ftrace_addr = ftrace_location((unsigned long)p->addr); > +#ifdef CONFIG_KPROBES_ON_FTRACE > + addr = ftrace_call_adjust(addr); > +#endif Looking at the commit message for patch 3/3, it looks like you want the probe to be placed on ftrace entry by default, and this patch seems to be aimed at that. If so, this is not the right approach. As I mentioned previously, you would want to over-ride kprobe_lookup_name(). This ensures that the address is changed only if the user provided a symbol, and not if the user wanted to probe at a very specific address. See commit 24bd909e94776 ("powerpc/kprobes: Prefer ftrace when probing function entry"). If this patch is for some other purpose, then it isn't clear from the commit log. Please provide a better explanation. - Naveen