Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3913113imm; Mon, 8 Oct 2018 11:35:12 -0700 (PDT) X-Google-Smtp-Source: ACcGV63QGXBqZp+3+tqxHBaDDrCNGbIjSuBMenV2G5/iRpS89JY9EozI9g1elQ6o61CzLKy9iKbU X-Received: by 2002:a65:609a:: with SMTP id t26-v6mr21680639pgu.41.1539023712151; Mon, 08 Oct 2018 11:35:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539023712; cv=none; d=google.com; s=arc-20160816; b=bgcE6b2zaaQHjwSEvKA1XE1ol+uTtUvsltD1KGBVMXmlGrwRLkytZ2XXKJRWFidoF+ nt3F0NXRX8bdj+32liHKKLxunbYOlb1gr4LXNnoThvmImEmHEYx7nU63oIHWWEcjTTW7 +be4qwrNPCCvHCDuzxfMpk81fQan04/ml28XOwdEcXISa6WDaWzzQ8VJKQrDMGNfsbfP +HVZYhoiZInJN/fS/MWjGiQQYbwHEAz/0sJQb5XOEOvq+zXL07M4Mg7PTQleXo/Wv9Ls paNuipAglWO8INDLO5k+VeJtqjQ1DnLkzBTph4qrcpQDu1r9wEoGPaVk/ZFMY1Q64ZVO ZdEg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ojjv90Maazamc3QmeBiRfmSne5wAR1zZKnitNZVHrsg=; b=f3fbPQtoytmgcVl7YKWy7/2DI3G/D/3EA384lhi/XsKRVlTiYgSyf0B1OnZE3kO20b OLxEH0mmXFlOFHR/b1HnXsDw8BUMf00V0CFmJ2rI+vgP6ZysIgXBx3XfIX9u6DoRzJdK A3V2+g92DnuDXXpHZQIC51xBeITnsyJAqdcVQDOIr3qoSX5aUWAMhkFQWyuSKjix2On7 iKRLHVHR/UQ2KdbunhQlwNn1OGQVvt0v4N4um94mF4yzIvMDTioVvGBtB9WfuhZeAPGH VSxevDv71YZvplhohlfob8nCSpD4JAcNn8vmMXx6TlpNbs7XF5Maf8x1AAITYJ74wpkq 1jfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ChAOnM3N; 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 z2-v6si17321466plo.412.2018.10.08.11.34.57; Mon, 08 Oct 2018 11:35:12 -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=ChAOnM3N; 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 S1727734AbeJIBrW (ORCPT + 99 others); Mon, 8 Oct 2018 21:47:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:58434 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726568AbeJIBrV (ORCPT ); Mon, 8 Oct 2018 21:47:21 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (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 9D50D214C3; Mon, 8 Oct 2018 18:34:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539023659; bh=9ie+ra4UaHkzlO3F4aiv3XB83aqXeBRTUNsc2EH55TM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ChAOnM3Nf64IuI99W8hpMyu4XKn83OZIfG0mpGHmpBd/PyCgPBmXGsNut0UxUe/8a oiqYaZTbPRHEJAk8C72zXEqNw8z5OAISwZTcE54je5SXjugRIBo+Z34n9XO7V9HEiu /AjFXgpqNTmzA4qm+gOBuA3loET5k1258bu0/XAE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Josh Poimboeuf , Jessica Yu , Sasha Levin Subject: [PATCH 4.4 040/113] module: exclude SHN_UNDEF symbols from kallsyms api Date: Mon, 8 Oct 2018 20:30:41 +0200 Message-Id: <20181008175532.788656523@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181008175530.864641368@linuxfoundation.org> References: <20181008175530.864641368@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ 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 Signed-off-by: Greg Kroah-Hartman --- kernel/module.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/kernel/module.c +++ b/kernel/module.c @@ -3860,7 +3860,7 @@ static unsigned long mod_find_symname(st for (i = 0; i < kallsyms->num_symtab; i++) if (strcmp(name, symname(kallsyms, i)) == 0 && - kallsyms->symtab[i].st_info != 'U') + kallsyms->symtab[i].st_shndx != SHN_UNDEF) return kallsyms->symtab[i].st_value; return 0; } @@ -3906,6 +3906,10 @@ int module_kallsyms_on_each_symbol(int ( if (mod->state == MODULE_STATE_UNFORMED) continue; for (i = 0; i < kallsyms->num_symtab; i++) { + + if (kallsyms->symtab[i].st_shndx == SHN_UNDEF) + continue; + ret = fn(data, symname(kallsyms, i), mod, kallsyms->symtab[i].st_value); if (ret != 0)