Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1622169ybv; Fri, 21 Feb 2020 00:28:04 -0800 (PST) X-Google-Smtp-Source: APXvYqxeETMEPDQF+/2kDLR2Luz+neg0tV5mpRUhyVkTaZCgpQzIinPqg+Ogti4Phn96MJDCh7pU X-Received: by 2002:aca:f2c5:: with SMTP id q188mr1016851oih.113.1582273684358; Fri, 21 Feb 2020 00:28:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582273684; cv=none; d=google.com; s=arc-20160816; b=OQeNSgNqwExJgJTq57b9UTvAxtARC3iq4iTCLBCeq5e/JIOjPQJHQRvkQ9tj9hLDhS 2s8yW8S4kk3Mym7X+eUmkPqHNzRd0Nn5/PkYGrilbT0AYEJVap+whaWKYKgDpNsV8DfB rSuAm8NUuUF0Ub8VG+wkyelkgEVmD290VfF+fXqm5xDylsXXHusFf7r3Ih38Aeo6XRXm rrEdYin+LDdxFyPgThCSTzmj7qMlDzuOqYNsmncy9b7haUZOIJbW7rKkx8lD2K4dAzDC Lyyo0oRxUrSx4MZ/0zU7a2ab2VrbpMtkQs5BLlx+knlcm3TN1EtPOpGKFgBZXAd6r8eR ZjOg== 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=Vg60+Ltq3sRmsZl3Bide0x4LzJ7CHDb7Zx8NdUYNPEs=; b=ag9dxg8d8swtOGD+t+rmN3RVDLtyuHOCRObBNemViV+iuj4BlRxqc3RgC3MACeeiNi v6BGSJg7w+JwtHZYcbWOiD8RyUP+CiMihiysPv4qRcxgipk+9smdxab+gYlgcrbxeX1Y TR4HOAdgtRVl95aCKStSYrwJ8lyf9fYFWIzZ1D3CCCmJS1i8nAqqzV23l8T0IOJnZVel kuhIZDx/26pjwG2CJyt9Y/uhxUchv//sf4tkD/LZbrkrsOq+FcLdMPyy1Qjg9kgiUxQC DTg1lZcjFGWct6pUkhPX6qEqDG8q1eQh4fg4lceMxZT/OGEeRva5pI/rz2/CXAVbl38f 0ffw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2K05Ussw; 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 e22si531810oiy.124.2020.02.21.00.27.52; Fri, 21 Feb 2020 00:28:04 -0800 (PST) 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=2K05Ussw; 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 S2388393AbgBUIW5 (ORCPT + 99 others); Fri, 21 Feb 2020 03:22:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:34712 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730697AbgBUIW4 (ORCPT ); Fri, 21 Feb 2020 03:22:56 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 B1A762467D; Fri, 21 Feb 2020 08:22:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582273375; bh=3KRChEGwMrFyCZkXflHL2hF+PqaYvlhAhPObu7WcK68=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2K05UsswHBv/KKUzwDXGcnEar+z3NP0QXebb7dMMLbG8x3AX5rzLUdnXrhsSq9wki 1CXc+IwaLxEBuE9CWDaNryB0iq2Rj5l3OLP6XbyC2+80jDLNBShJnTKkcnP1mKrj65 76MYFW3+cacrovAJbz0ELQknzJL/K9xniu9WBKTg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miroslav Benes , Jessica Yu , Sasha Levin Subject: [PATCH 4.19 147/191] module: avoid setting info->name early in case we can fall back to info->mod->name Date: Fri, 21 Feb 2020 08:42:00 +0100 Message-Id: <20200221072308.211661443@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200221072250.732482588@linuxfoundation.org> References: <20200221072250.732482588@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Jessica Yu [ Upstream commit 708e0ada1916be765b7faa58854062f2bc620bbf ] In setup_load_info(), info->name (which contains the name of the module, mostly used for early logging purposes before the module gets set up) gets unconditionally assigned if .modinfo is missing despite the fact that there is an if (!info->name) check near the end of the function. Avoid assigning a placeholder string to info->name if .modinfo doesn't exist, so that we can fall back to info->mod->name later on. Fixes: 5fdc7db6448a ("module: setup load info before module_sig_check()") Reviewed-by: Miroslav Benes Signed-off-by: Jessica Yu Signed-off-by: Sasha Levin --- kernel/module.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/kernel/module.c b/kernel/module.c index 70a75a7216abb..20fc0efc679c0 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -2980,9 +2980,7 @@ static int setup_load_info(struct load_info *info, int flags) /* Try to find a name early so we can log errors with a module name */ info->index.info = find_sec(info, ".modinfo"); - if (!info->index.info) - info->name = "(missing .modinfo section)"; - else + if (info->index.info) info->name = get_modinfo(info, "name"); /* Find internal symbols and strings. */ @@ -2997,14 +2995,15 @@ static int setup_load_info(struct load_info *info, int flags) } if (info->index.sym == 0) { - pr_warn("%s: module has no symbols (stripped?)\n", info->name); + pr_warn("%s: module has no symbols (stripped?)\n", + info->name ?: "(missing .modinfo section or name field)"); return -ENOEXEC; } info->index.mod = find_sec(info, ".gnu.linkonce.this_module"); if (!info->index.mod) { pr_warn("%s: No module found in object\n", - info->name ?: "(missing .modinfo name field)"); + info->name ?: "(missing .modinfo section or name field)"); return -ENOEXEC; } /* This is temporary: point mod into copy of data. */ -- 2.20.1