Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp9133426ybl; Fri, 17 Jan 2020 06:54:28 -0800 (PST) X-Google-Smtp-Source: APXvYqw9ltQXrjSYc/HBlbQTGGAN3TZaIgjZvlGbhlEtxqPDruaEU49QAUasYpXRtE5sDWm+rgTo X-Received: by 2002:aca:a811:: with SMTP id r17mr3674345oie.59.1579272867847; Fri, 17 Jan 2020 06:54:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579272867; cv=none; d=google.com; s=arc-20160816; b=B/D3oRrW4ral2DcanhgB7GjoJkbFhyFhpNdQVO0h14iAD9ze72tbAhpbjAJYAVjFxW zftB9QMrMAmkPOkvhJREuvxey7yqaWmwID6/+8jMCa4fWYw8rPgJWalIhhDEGTqQokpw SMPS95PImpR2tl0hSlkRYkPWVtDRA91CDi5Gq1Vbba7l/71vqQD9fYnMHBQmXn3WvlxU 77SiZAAkzSh2Ig7r3RotzJnc305CtEwMB0BeDIZr/lhwAqGo4+xYwcMwF+itY7hzoqe0 qaf3O4/QwtJKBxE5NQFT+dCwj7S4IfVGFHKmrm9C3PRuy7tAACedx+bbBZHsx5/d7mvT wYjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=t+YFaO/GRj39F7Wtm4vny9BCXzlMHgAhqxnFKHYUd3g=; b=NBKuqlQmZ6mHUCl/juDSwv6AdV1ihqhFiOyCbI3VxCpoDkw16+ldS7Eg4S+UtFr0VL IqcLoEnC+sTpGvYmg+yXoEuQ/9RHF9dHDljzvOg368SGTAOvo3WfrisoGOpcM6nr6vPT L9GFPeelEiqeAHC5GS28gCDJR5NpxzuuBz9cgqyuZI8CLkVZwt9wht1uzyXcPlbhomWN 54Ypb9nfcDuHIFVtIFg3/C6MP7DzjA5KeQ3D8ayrIcDDwEN3MzIhqItz8iD0JGRaWNnD v98rroYuNMEpgyP3jHHPvH624nSefQLeIIGReu3kVMjNEuKVjLj+HLbZ3l7Uw0imV/7Q o+2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FE4tCBjf; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g5si15216472otn.232.2020.01.17.06.54.15; Fri, 17 Jan 2020 06:54:27 -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=FE4tCBjf; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728820AbgAQOxT (ORCPT + 99 others); Fri, 17 Jan 2020 09:53:19 -0500 Received: from mail.kernel.org ([198.145.29.99]:33792 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726827AbgAQOxT (ORCPT ); Fri, 17 Jan 2020 09:53:19 -0500 Received: from linux-8ccs.suse.cz (x2f7fe76.dyn.telefonica.de [2.247.254.118]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D6D132083E; Fri, 17 Jan 2020 14:53:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579272799; bh=NKvl8pqM+SZeTyBOZdayAwjEIGElTONmX+PkukewNTc=; h=From:To:Cc:Subject:Date:From; b=FE4tCBjf9vYqsnxyanyleXsV3lL0AOUz+hI3jVef8wzS4gdT9rNt2NL22/nF/fuY/ iuIWawdkESvYD0fcIkvbrYg9ilzsAPiXy5V2HdmWrLAbMxIoKDWh0vQiFhF/efl+Hl c/vf6mj3Yl0OmB7yCA8ALITgHbG7a9BLJbAIIX6Q= From: Jessica Yu To: linux-kernel@vger.kernel.org Cc: Jessica Yu Subject: [PATCH] module: avoid setting info->name early in case we can fall back to info->mod->name Date: Fri, 17 Jan 2020 15:53:06 +0100 Message-Id: <20200117145306.15509-1-jeyu@kernel.org> X-Mailer: git-send-email 2.16.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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()") Signed-off-by: Jessica Yu --- kernel/module.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/kernel/module.c b/kernel/module.c index 2b5f9c4748bc..f2379e54fae8 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -3059,9 +3059,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. */ @@ -3076,14 +3074,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.16.4