Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3520452ybl; Mon, 19 Aug 2019 20:55:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqx0ZNJJASG9zaIS1+bl5qdya85+KHLiIz25n9jdLUnUW9MmR5OAZaHu3UZKP2gNjbjPSyym X-Received: by 2002:a63:6947:: with SMTP id e68mr23119194pgc.60.1566273355948; Mon, 19 Aug 2019 20:55:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1566273355; cv=pass; d=google.com; s=arc-20160816; b=vsK2GXO/WOCkOeWCY7+MltIu4tugzMn2nW0ny/34908u+joN6CpM84+BzOWzfQtYbG 90dW/Z6DUBR1CYvAp0Hd/OPs3hT4fIe1X/NRfEHx1hXip7tAAamYKKYKzc5+XutAoeeP m8G/N0+OC7Nd6QcU+tM2ed7/ecYmEmsujQEAxv3nGMUdm6IfP1E/cNKsnKVl4N6mNzTv TV+Mxharn6bdAQEOQbsJqqxpQM7afbfnu19QLzBhUYvgQPoWfKl3ycFqxrBgAhqXU5w0 hxsUJeUMeHAN4DMyPwWVTak+GY7gsZtFP48s8U3deVX0lgqAS57rrga84MYqUKzyxOI3 hgvQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-id:content-language:accept-language:in-reply-to:references :message-id:date:thread-index:thread-topic:subject:cc:to:from :dkim-signature; bh=M6liWGvIujiyKQMbDLvytJ2ECSW3hXjgw7Be6M5leWU=; b=X+7qYfC2u3MQ6wvaqHKQQsCytvLfQtDLA+nG29FhI9KVU45kQHAHSEqoePcCc83p8E pS2IH5ef+1iyS4GqkZTRU0fwposORv3Y/YyDya8fSRYva9j5Er9MQ6sSfu7si4MIBL7Q Pw327jqynhUJGtZumUjIoN7CzFEn+KCwyXnlQO14fL4mNSWbGkDxVC8Om2oC17T17sFY 8mexQ0PkN2nBio9/gKSdMAyIeKUVNZTWkzWSAAs1SXXQKZHxBfSGJUmaZB9JBUw4P60x grqQBhLRJYbaF2q/7FHccRVRGBBhMNUTZ+aD76ORsy4/haQ+Tu0buYkYMmQs14EncDAR pLFA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Synaptics.onmicrosoft.com header.s=selector2-Synaptics-onmicrosoft-com header.b=QaRLnHir; arc=pass (i=1 spf=pass spfdomain=synaptics.com dkim=pass dkdomain=synaptics.com dmarc=pass fromdomain=synaptics.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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f1si8046919pld.69.2019.08.19.20.55.40; Mon, 19 Aug 2019 20:55:55 -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=@Synaptics.onmicrosoft.com header.s=selector2-Synaptics-onmicrosoft-com header.b=QaRLnHir; arc=pass (i=1 spf=pass spfdomain=synaptics.com dkim=pass dkdomain=synaptics.com dmarc=pass fromdomain=synaptics.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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729072AbfHTDxe (ORCPT + 99 others); Mon, 19 Aug 2019 23:53:34 -0400 Received: from mail-eopbgr710061.outbound.protection.outlook.com ([40.107.71.61]:30752 "EHLO NAM05-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728647AbfHTDxd (ORCPT ); Mon, 19 Aug 2019 23:53:33 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F7q68aOII07dbCPVlZDbWL/VA4WV1ZTem58jonRUwqBzHS6aArLR2z3ojB65Gr42V8jz5c7K57GjHQ1hU9OzvGNFdcmaGWobDRYPoOAjVVC+107PCj+5OFk52e7LNxpiYcc3bFUM71C+uHlGuAFQY4/6R609FGytneVCm3evn/CWemhT10GptLSBHSefj+hyZrcCFZCsRtvzB3kI1PsOEVyVC6eYE8A+PTRcSn6W/20R0WqazfuqF78jItRknEZBP303fKbBIiycOMK095IeZUWqSB68HhOp3WKYwLWUHltz57Nm4zACJjicW0CvHALJh3XjYDKvyV58004Ran1rFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=M6liWGvIujiyKQMbDLvytJ2ECSW3hXjgw7Be6M5leWU=; b=JEC0j0jBv5Fvy8EjBUTePLjBwbl6oepnpYpRk0tFoNXQ2QIzP7D9w4AygVLjLjBn1WCh8vcScKLZY0AQGwhwNldgp/JSs7DjGawkoy9y/V4Um3DMDhpN3EH1VcD/IHAQU2jyDpMtk5dgYNqEFA73C6Zz26U3ByQB3AfW/1fNpUuUUMIXYOCltCne4zE/Ljq8Rs9yhc0XxNByB07FXl8DDDaEDKYJPVCgMJ+Drc7eSEjcLjWelOcEz5tPZHTNN/pkjG+uGKSuoHmwZ80CPgKycObYumWfoqBRZvuUCbqUP0yF2oTzvxJ/bRXGD4aYWQ4ZmtmNPnMoXwbDvtyvMhe/4g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=synaptics.com; dmarc=pass action=none header.from=synaptics.com; dkim=pass header.d=synaptics.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Synaptics.onmicrosoft.com; s=selector2-Synaptics-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=M6liWGvIujiyKQMbDLvytJ2ECSW3hXjgw7Be6M5leWU=; b=QaRLnHirbl599QEXr+mhGFW92RpiC3VmmFS76kctwTGFkyBquo5No4uLBhmQinsRWuHkSNHp2GLWPu37Cgay/MIRFETF8brueVBRgueDV5KHmm3Wk/kIquT9n9SZeULo5W1MxXIkTcZV8LCsC2i9WIZ+tcV1dINllIXucvCsCco= Received: from BYAPR03MB4773.namprd03.prod.outlook.com (20.179.92.152) by BYAPR03MB4870.namprd03.prod.outlook.com (20.179.93.215) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2157.16; Tue, 20 Aug 2019 03:53:31 +0000 Received: from BYAPR03MB4773.namprd03.prod.outlook.com ([fe80::a517:3578:67bf:6c88]) by BYAPR03MB4773.namprd03.prod.outlook.com ([fe80::a517:3578:67bf:6c88%7]) with mapi id 15.20.2157.022; Tue, 20 Aug 2019 03:53:31 +0000 From: Jisheng Zhang To: Catalin Marinas , Jonathan Corbet , Will Deacon , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , "x86@kernel.org" , "Naveen N. Rao" , Anil S Keshavamurthy , "David S. Miller" , Masami Hiramatsu CC: "linux-doc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" Subject: [PATCH v2 2/3] kprobes: adjust kprobe addr for KPROBES_ON_FTRACE Thread-Topic: [PATCH v2 2/3] kprobes: adjust kprobe addr for KPROBES_ON_FTRACE Thread-Index: AQHVVwrVXMrB52r5zEm7ypsroIKAaw== Date: Tue, 20 Aug 2019 03:53:31 +0000 Message-ID: <20190820114224.0c8963c4@xhacker.debian> References: <20190820113928.1971900c@xhacker.debian> In-Reply-To: <20190820113928.1971900c@xhacker.debian> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [124.74.246.114] x-clientproxiedby: TY1PR01CA0180.jpnprd01.prod.outlook.com (2603:1096:402::32) To BYAPR03MB4773.namprd03.prod.outlook.com (2603:10b6:a03:134::24) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Jisheng.Zhang@synaptics.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 736b347f-b974-409b-2ee0-08d72521f77c x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328)(7193020);SRVR:BYAPR03MB4870; x-ms-traffictypediagnostic: BYAPR03MB4870: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1417; x-forefront-prvs: 013568035E x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(979002)(136003)(346002)(39860400002)(376002)(366004)(396003)(189003)(199004)(6116002)(6486002)(3846002)(53936002)(76176011)(2906002)(6436002)(86362001)(1076003)(64756008)(71190400001)(6512007)(110136005)(9686003)(6506007)(71200400001)(54906003)(66066001)(5660300002)(4326008)(14454004)(316002)(52116002)(66556008)(476003)(7736002)(99286004)(446003)(2501003)(486006)(386003)(8676002)(81166006)(66946007)(256004)(478600001)(50226002)(102836004)(8936002)(26005)(305945005)(66446008)(66476007)(7416002)(186003)(11346002)(25786009)(81156014)(921003)(39210200001)(1121003)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1101;SCL:1;SRVR:BYAPR03MB4870;H:BYAPR03MB4773.namprd03.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:0; received-spf: None (protection.outlook.com: synaptics.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: jCr85pMSBpZf/iiTBNOAhYnJ5xFbTKe8X4xtmJrxBD1sszI8fCBxWBiAAZX9NObyVHX+0xGGFib9crGswXfiAyEZap4+Qu6pIhDxPfj3DJZqVLRXBlWdJF7e44bp7C47xf705mr5vrPAtB7g9b4RNUc0RCZFENiZsBMTtfxdLsCYQab2+04ApIhLbHSaHl+VR77t10kDwbOTH98GZzJAhAHxceZimhePqoMUbaOtLc5NdKHNhxNt4pzVaTUywHXLxFxNuq6zPav10heXZVs8okBbQ74ogUlEqhtU3U0ijRx0jB0DkghlpPiZg2MLxJKl6zPV4B8ZbqcHnMmL9ok89/SjIgMGd7hNEuz3IvCWCz0yj1Cey5ykRdFwCKKPbwABmImQOCewNI+6xYv2etadp0BEEK0vrgUK/9mJkJNG8+A= x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-Network-Message-Id: 736b347f-b974-409b-2ee0-08d72521f77c X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Aug 2019 03:53:31.5622 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: DVcKL1qaCY64uLm1mYUqT7Zuz8nHg1XeXtugrzuWZIjXzbRfk1okiEyjk1Mmgnk+ZT7yxJtG433sq+cGKgSicg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR03MB4870 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) =20 int __weak arch_check_ftrace_location(struct kprobe *p) { - unsigned long ftrace_addr; + unsigned long ftrace_addr, addr =3D (unsigned long)p->addr; =20 - ftrace_addr =3D ftrace_location((unsigned long)p->addr); +#ifdef CONFIG_KPROBES_ON_FTRACE + addr =3D ftrace_call_adjust(addr); +#endif + ftrace_addr =3D ftrace_location(addr); if (ftrace_addr) { #ifdef CONFIG_KPROBES_ON_FTRACE /* Given address is not on the instruction boundary */ - if ((unsigned long)p->addr !=3D ftrace_addr) + if (addr !=3D ftrace_addr) return -EILSEQ; p->flags |=3D KPROBE_FLAG_FTRACE; + p->addr =3D (kprobe_opcode_t *)addr; #else /* !CONFIG_KPROBES_ON_FTRACE */ return -EINVAL; #endif --=20 2.23.0.rc1