Received: by 10.213.65.68 with SMTP id h4csp2115897imn; Sun, 8 Apr 2018 20:06:40 -0700 (PDT) X-Google-Smtp-Source: AIpwx48aqwc0PZhGEBg2S7IevgoXI2rUlloxgYHKd+UC9r8QVHCs3txPwRkzJYpztj8d21L/bA3o X-Received: by 2002:a17:902:7245:: with SMTP id c5-v6mr36885485pll.217.1523243200052; Sun, 08 Apr 2018 20:06:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243200; cv=none; d=google.com; s=arc-20160816; b=AWjgW5u1XooswcUK7gJMWbQ97RI2BxhLCDeoYzmsMAx8RIYF2fIFXfrJF5tRek71Yz +URBBESBras3YRK3fjpzHRjeSK/V4onderY5+z4kOq9vsG3qioFQHydFozGXo2J5rf8B M3yHtiOie+JjGSPrTZraBCBdQ2H9o4Rd9B54cA63xEojQYEO5x4nReoPaa8DXvEdXlYH M8dE1WU2yHWikvFH0cBRfwptaF2JB9aIqYbESJEa27ABduaIVvF8/0ACZPS4wGfYB/E5 398XtECauUuLjVtV43LhjMBLveg8hH3J+225NEOOqvsmwLeFwP1H7BQoTNjh2EHwmRzy 6oiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=PHkeemZ7HPPD0Jl0H/DUx1catmbnvjKWIwoB5LP9SFI=; b=ZkeZjtvKVu/cq6uSp4ih6OeHlnvbXXm1EydS8pN68WH5VnjDYauyb7uwi6Fbz2Finf rwM+HfwUzuehzOCJTX5TooRQr1nIzDqPq18ByfAHRO7ymUNBaMw/Noq8uepQflFFohpS AvXNM36SyifYLLhen9go64za0vfr0hYODQ1G4PWGXy9n4v+1QgHZbuPuYI5fGQhd6HsA CS33ep+owx+AuKNllZi+OJxs8zSXpoJ5PYk9OC6RK7V/cODfzKtddcvdxIYzjGMXvASl Z+fBLhd4ta/vDppgKneqmh3kpG8dIrQVeZswufX1dYNaV20CRAj0U7rZxIPHYu1T8zCL QUlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=YyePs6s/; 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=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i61-v6si13347153plb.560.2018.04.08.20.06.03; Sun, 08 Apr 2018 20:06:40 -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=@microsoft.com header.s=selector1 header.b=YyePs6s/; 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=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756490AbeDIAcR (ORCPT + 99 others); Sun, 8 Apr 2018 20:32:17 -0400 Received: from mail-sn1nam01on0103.outbound.protection.outlook.com ([104.47.32.103]:45281 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756434AbeDIAcK (ORCPT ); Sun, 8 Apr 2018 20:32:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=PHkeemZ7HPPD0Jl0H/DUx1catmbnvjKWIwoB5LP9SFI=; b=YyePs6s/tkIc7ThBs2iPfW8AnxsY3qB/HKAD39tCFsyt3iIRNUFWWvDRKslDY53PmPB6QGp/u1kfEvC+BmH2LWl050vnPkWHnlIYabhUlBqAPtNeiJe8FyftjxzJO9UIgDTGvaQ/O6c0gYEGoTFm5l4HWLGWo5piOWc/twL/LaE= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0870.namprd21.prod.outlook.com (10.167.110.165) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.0; Mon, 9 Apr 2018 00:32:06 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:32:06 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: "Naveen N. Rao" , Michael Ellerman , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 198/293] powerpc64/elfv1: Only dereference function descriptor for non-text symbols Thread-Topic: [PATCH AUTOSEL for 4.9 198/293] powerpc64/elfv1: Only dereference function descriptor for non-text symbols Thread-Index: AQHTz5lDoNQBKU1l/EmOcy8JJUaGPg== Date: Mon, 9 Apr 2018 00:25:28 +0000 Message-ID: <20180409002239.163177-198-alexander.levin@microsoft.com> References: <20180409002239.163177-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002239.163177-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB0870;7:/HVWt18C+AEBgXhp1yq+etOzRnn+bSiH1eD3FaJoo0v9iPpit1xQBPeJ4sKc1uBvl0jCCcCVHJezKN48+CQPL0xi7+iu8i69I9/Zdilgpt96JB6aYwU2/Gl1J4Pc5LqxZK1+Z1a+xqjC7nLj1NJLlOGbEhpglQKhRIGXz1ijoYp3EShilI6e2kXzuBH6G9inuKUPK5JmfwhtSxlHSsluVhDEP7JqPtbAYqYxDk8g25YDnPooOSjRuhXuTyWs6H9s;20:5Pafwh4/i62AZX/LxxxxTlbslUiROzshpD42KF7mzpFkQLzk0F1Hxo/5ViJRm6gP20vHKx0kTZ1qlUbltXKExK/CzgUTibmnjo1xkhSyv36ptWs98/XBJEDG93bc9qzZptgrX9FDnzPBZnFLgTjkbu2XdGzNrG1Y+G2jfP2Z3r4= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 5802a4cc-0e82-45b4-4a52-08d59db15292 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0870; x-ms-traffictypediagnostic: DM5PR2101MB0870: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(85827821059158)(104084551191319); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(3002001)(10201501046)(3231221)(944501327)(52105095)(93006095)(93001095)(6055026)(61426038)(61427038)(6041310)(20161123558120)(20161123560045)(20161123564045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:DM5PR2101MB0870;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0870; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(39860400002)(366004)(396003)(39380400002)(376002)(199004)(189003)(53936002)(2906002)(6512007)(102836004)(2616005)(76176011)(14454004)(446003)(10090500001)(11346002)(476003)(486006)(107886003)(59450400001)(2900100001)(97736004)(66066001)(6506007)(6436002)(106356001)(99286004)(105586002)(3660700001)(6116002)(86612001)(3280700002)(6666003)(2501003)(10290500003)(26005)(8676002)(8936002)(478600001)(68736007)(5250100002)(5660300001)(316002)(4326008)(72206003)(186003)(110136005)(6486002)(7736002)(25786009)(3846002)(86362001)(36756003)(22452003)(81156014)(81166006)(305945005)(54906003)(1076002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0870;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: yIzhqObQcg/IU5UamJtQRH42pjy+SLnoYNQEtuyLcbpMCO3IirGTgVs/lTIqtsT8tZGQaSCiLGPgMbJf7uj+9WPjLApIEW9rNkfhCVqXYwqVoCOMB4nFhKnJQab57+IlGTy3520oEEosiNpE9D503kqJGo4s6bwN5jxLvdkx0eZ5Wv7RcR/N9GqyivVwxYltmKrPZiT1MPS5x67sgiOZwVQpJNP6vaJV6tVYs7tsPPDAy5aB21tuzod+DHtdHOcZ/hHaG3NCW9vd/PZ3I+hSotKXqyfShbK/QQ/2qSWtFYf3rTRtZZMMDojNQZlT3pWrmR0anJ3f2ZyfrKghYnd5K5C9LPshLT+IFyuHYHVhG4HAjLJWz6EZVIxBMjS3OmIiU/OTDVD1RBc6yOOl4BG/gvZZYbGKWbztsw10QVIDMh4= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5802a4cc-0e82-45b4-4a52-08d59db15292 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:25:28.7846 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0870 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Naveen N. Rao" [ Upstream commit 83e840c770f2c578bbbff478d62a4403c073b438 ] Currently, we assume that the function pointer we receive in ppc_function_entry() points to a function descriptor. However, this is not always the case. In particular, assembly symbols without the right annotation do not have an associated function descriptor. Some of these symbols are added to the kprobe blacklist using _ASM_NOKPROBE_SYMBOL(). When such addresses are subsequently processed through arch_deref_entry_point() in populate_kprobe_blacklist(), we see the below errors during bootup: [ 0.663963] Failed to find blacklist at 7d9b02a648029b6c [ 0.663970] Failed to find blacklist at a14d03d0394a0001 [ 0.663972] Failed to find blacklist at 7d5302a6f94d0388 [ 0.663973] Failed to find blacklist at 48027d11e8610178 [ 0.663974] Failed to find blacklist at f8010070f8410080 [ 0.663976] Failed to find blacklist at 386100704801f89d [ 0.663977] Failed to find blacklist at 7d5302a6f94d00b0 Fix this by checking if the function pointer we receive in ppc_function_entry() already points to kernel text. If so, we just return it as is. If not, we assume that this is a function descriptor and proceed to dereference it. Suggested-by: Nicholas Piggin Reviewed-by: Nicholas Piggin Signed-off-by: Naveen N. Rao Signed-off-by: Michael Ellerman Signed-off-by: Sasha Levin --- arch/powerpc/include/asm/code-patching.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/include/asm/code-patching.h b/arch/powerpc/includ= e/asm/code-patching.h index b4ab1f497335..a96e4ad380d1 100644 --- a/arch/powerpc/include/asm/code-patching.h +++ b/arch/powerpc/include/asm/code-patching.h @@ -80,8 +80,16 @@ static inline unsigned long ppc_function_entry(void *fun= c) * On PPC64 ABIv1 the function pointer actually points to the * function's descriptor. The first entry in the descriptor is the * address of the function text. + * + * However, we may also receive pointer to an assembly symbol. To + * detect that, we first check if the function pointer we receive + * already points to kernel/module text and we only dereference it + * if it doesn't. */ - return ((func_descr_t *)func)->entry; + if (kernel_text_address((unsigned long)func)) + return (unsigned long)func; + else + return ((func_descr_t *)func)->entry; #else return (unsigned long)func; #endif --=20 2.15.1