Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3493378imm; Sun, 16 Sep 2018 20:19:40 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaBUiv2hJHZfgqFw76u2W5KD7Vk5YdIA+X7hiXl9d3F+DZiiy7AIXw7a7x9IwGvQPgPaAPf X-Received: by 2002:a17:902:8a92:: with SMTP id p18-v6mr22683916plo.148.1537154380519; Sun, 16 Sep 2018 20:19:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537154380; cv=none; d=google.com; s=arc-20160816; b=jF+6cMn7lgpqTiF9BCUdtKiarefTcTNfGGiihekpn4cAAFt5MdOlwlzC3cudyXx2wb gjX9aqGomcGk6Y4sOZv9b6bnpCWd4f7PsPnoj8aX4f4ry8l44XQokMctMQcFUdg3C1oE I6GK7U5Tmvt2pbPQbXrG+CK2ULryPAg+GtENYIgmNSY+VbNR0nmlDzaRO6GK5iqMJK8y skak6jgRrNKpd/Zc8JaJIC7WxbsS0dAqR7QlRJhoLrxhHxuvuVOptPZLRQQiuF/ut8fF tpFUm0LIjSVaL80C6RhQdIVZBPVNgFRs6FeYB/H0RyO0F3nvrJ2bkmvdW3Zo0Lm8ZS3D 6kYw== 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; bh=yAWDwN+LC+dOL5gT0mknHOpkk4CKs5llMJbh1kRlsgM=; b=vPh4C0lMk7gGFnZChnYegdk7etrfyf9H+m7cwy32Kaw4sfZaVuucmXHQzBqfEcjK9H 4RRL545KFLB5u1LNgmChEgxq35xNwjBXEZRexABUS9Yce+aU3B8MogmDupLLTjNu4ase C7U0sxtiVdFrfgj+Gh+UfcuSE0gyuG+OB7iB43QgCVQrL5r/8BBgB9r+d9EZxoFpXvqL 1kOezx0URTsOc8RX57NlZSLrIN/tMk0aLTqDN7/cDx31I0W5XEeUh0pazxkgmDT/C+io kehbFzlcsvyTQXSnSSDtNEJ1htXIkHOoWv0h3Uy9JDzAjDuTt5mCzTSag3gxmVaGtDSY M/Tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=nt+KoW0H; 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 123-v6si14331659pfd.201.2018.09.16.20.19.25; Sun, 16 Sep 2018 20:19: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=nt+KoW0H; 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 S1730526AbeIQIa1 (ORCPT + 99 others); Mon, 17 Sep 2018 04:30:27 -0400 Received: from mail-eopbgr690116.outbound.protection.outlook.com ([40.107.69.116]:54124 "EHLO NAM04-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730502AbeIQIa0 (ORCPT ); Mon, 17 Sep 2018 04:30:26 -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:X-MS-Exchange-SenderADCheck; bh=yAWDwN+LC+dOL5gT0mknHOpkk4CKs5llMJbh1kRlsgM=; b=nt+KoW0H0HKVc6TPn4PbIURS2ebIepM5kdU56wXIcd1ND+DmOk6Ha9mRKbSbrmPtA1yWVaee1ynvzRmnisOxCqjB9sk3OkEH6PCU4YHFJsenO13NllYBz1UgzzCIfwwObc50XwYgi6GVIIzIO80vWw0Enat5D+CJtdMNRg0hDTU= Received: from CY4PR21MB0776.namprd21.prod.outlook.com (10.173.192.22) by CY4PR21MB0133.namprd21.prod.outlook.com (10.173.189.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1164.11; Mon, 17 Sep 2018 03:05:02 +0000 Received: from CY4PR21MB0776.namprd21.prod.outlook.com ([fe80::54e2:88e0:b622:b36]) by CY4PR21MB0776.namprd21.prod.outlook.com ([fe80::54e2:88e0:b622:b36%5]) with mapi id 15.20.1185.003; Mon, 17 Sep 2018 03:05:02 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Jessica Yu , Sasha Levin Subject: [PATCH AUTOSEL 4.14 79/87] module: exclude SHN_UNDEF symbols from kallsyms api Thread-Topic: [PATCH AUTOSEL 4.14 79/87] module: exclude SHN_UNDEF symbols from kallsyms api Thread-Index: AQHUTjL6AdFnEvE7jUuIxJiiUczqFQ== Date: Mon, 17 Sep 2018 03:03:15 +0000 Message-ID: <20180917030220.245686-79-alexander.levin@microsoft.com> References: <20180917030220.245686-1-alexander.levin@microsoft.com> In-Reply-To: <20180917030220.245686-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;CY4PR21MB0133;6:gOiAtEhTZib2RXOV49sHPCyyuigUrc1wC8nib2yvRWj9IAPU1NffsrR8IwtipES6LNDQnJT4H8jK7DCR9vD76GRoKyZzT6zABv9jco+cRrcaOO+CIMTKkLrGPv7SlpYu6SaEKh9Ui2QjV5Ty8+b3fYtDQxB6dXgJ3SAKVwTCCW7lGKxCL3k+E5FlaJ8Pp1JwjO9MU79LCCn83STW6UFQYggSRIdvpcg8PJ5WG+/4Gl0gPN4p78Hn7u9IEXXPqns5GbpgQIm5l5/1Aw7Pk1H+HK+4UKTVqHAmZvqlP6XpX6R1W+YO5fPIiaKLn2REzty+LT5O6hoFtord3pOKgjxqoElZC3kBYAUgRQDK4R9GhX8JE2QWBKWxss66wDJXriuiKsrL8S7Xlz0rT0jpSvV/bOtXgG80a8X57zW4qinNthVDKps3yjtLJE1auPFJh+FmFKOFe36Z8/de/zxsqth5oQ==;5:92WHsGuS+YO0Ai7tszfQF+NOMoMkyLCyNIFQe23A+DWQJaaMBgVmk+lvq604dYsvOr1xboRnyEmxnZD88N5C5YhHgwOIQa3CXc9VE6aA8MJRQ4wXBUIBISzCc2vf83tsRA6f9/yXhXiUfeSp5H1IQtWyQX4dhI14RehOPKsKwps=;7:ui4Z8GiFabvp32bbBbdU738c2HAaujQ2Q9GAMa3ITQTYPrcia3IbGcm1KBLDjZsOq3mQ5hN3HzK5qeiHW+LgzGR3aV51l1+k5zK37yJtmGyyI98RIJyZPIuVLBowCvX/gZwYqZTl+Sxw52/SWkzinJgs0KmQ6L8+gQdztmGAKA6V2FfPxltPhrA4Y0P0V6UKtUQTg6UIM1s14G7iQcOW3OgxLVdqW+zxpI/7DWck6tkl42iaYHSptPhiRDKWw6qx x-ms-office365-filtering-correlation-id: 894b7c9e-ad9d-4dae-91ce-08d61c4a5c53 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7193020);SRVR:CY4PR21MB0133; x-ms-traffictypediagnostic: CY4PR21MB0133: 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); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(10201501046)(3231355)(944501410)(52105095)(2018427008)(3002001)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123558120)(20161123564045)(201708071742011)(7699050)(76991041);SRVR:CY4PR21MB0133;BCL:0;PCL:0;RULEID:;SRVR:CY4PR21MB0133; x-forefront-prvs: 0798146F16 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(136003)(396003)(39860400002)(376002)(346002)(189003)(199004)(102836004)(53936002)(8676002)(486006)(476003)(3846002)(6116002)(76176011)(10290500003)(97736004)(217873002)(256004)(5660300001)(107886003)(6506007)(478600001)(110136005)(2501003)(10090500001)(14444005)(305945005)(7736002)(446003)(11346002)(36756003)(2906002)(1076002)(22452003)(5250100002)(2616005)(26005)(316002)(106356001)(25786009)(68736007)(86362001)(575784001)(14454004)(72206003)(105586002)(99286004)(6486002)(6436002)(6512007)(86612001)(6666003)(81166006)(81156014)(186003)(2900100001)(54906003)(8936002)(4326008)(66066001);DIR:OUT;SFP:1102;SCL:1;SRVR:CY4PR21MB0133;H:CY4PR21MB0776.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: o0LOL/gzx6oTgsMQOGY1bzYZ58WonFfA7iDTlJvQSHkl8aRl5J4AOgR++hHDvTMlArcIwsGkwgwNI8Z4i0gklR61vX5H7VwLyYFitofGdjMOoa1SjkCZu8ePGzwG4DeJ4So6txQB1V0/1EgUdkwSEJI2OVKt5Rv7E8toa9yY0a2RKZI1MP64LdR4YoVJJVxMHuICZd8MLK+W6aqRu37TdU7KzUOQgT83AgVknBLVV6HK4V9aLw+HarGxRKRAa9FvQBrqYLyygPo5Acr5nGQk/xH0m2719QCmoibpIX0ChRVp/RMnhcAhGELLI1BlRIWTnra9ljTXybNmXeC+xAHmgAdS9tgCKnduIY32lzlMg1E= 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: 894b7c9e-ad9d-4dae-91ce-08d61c4a5c53 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Sep 2018 03:03:15.1808 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR21MB0133 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jessica Yu [ Upstream commit 9f2d1e68cf4d641def734adaccfc3823d3575e6c ] Livepatch modules are special in that we preserve their entire symbol tables in order to be able to apply relocations after module load. The unwanted side effect of this is that undefined (SHN_UNDEF) symbols of livepatch modules are accessible via the kallsyms api and this can confuse symbol resolution in livepatch (klp_find_object_symbol()) and cause subtle bugs in livepatch. Have the module kallsyms api skip over SHN_UNDEF symbols. These symbols are usually not available for normal modules anyway as we cut down their symbol tables to just the core (non-undefined) symbols, so this should really just affect livepatch modules. Note that this patch doesn't affect the display of undefined symbols in /proc/kallsyms. Reported-by: Josh Poimboeuf Tested-by: Josh Poimboeuf Reviewed-by: Josh Poimboeuf Signed-off-by: Jessica Yu Signed-off-by: Sasha Levin --- kernel/module.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/module.c b/kernel/module.c index 321b0b1f87e7..2a44c515f0d7 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -4058,7 +4058,7 @@ static unsigned long mod_find_symname(struct module *= mod, const char *name) =20 for (i =3D 0; i < kallsyms->num_symtab; i++) if (strcmp(name, symname(kallsyms, i)) =3D=3D 0 && - kallsyms->symtab[i].st_info !=3D 'U') + kallsyms->symtab[i].st_shndx !=3D SHN_UNDEF) return kallsyms->symtab[i].st_value; return 0; } @@ -4104,6 +4104,10 @@ int module_kallsyms_on_each_symbol(int (*fn)(void *,= const char *, if (mod->state =3D=3D MODULE_STATE_UNFORMED) continue; for (i =3D 0; i < kallsyms->num_symtab; i++) { + + if (kallsyms->symtab[i].st_shndx =3D=3D SHN_UNDEF) + continue; + ret =3D fn(data, symname(kallsyms, i), mod, kallsyms->symtab[i].st_value); if (ret !=3D 0) --=20 2.17.1