Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1366264ybl; Tue, 13 Aug 2019 11:19:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqzwYyhDdAdMKiMVxjmhoXp9YnUn9H9DDl+ZCmzSVADPV40pRNum03q2fBxAVMbtTYY1TdNL X-Received: by 2002:a65:6096:: with SMTP id t22mr35231541pgu.204.1565720350468; Tue, 13 Aug 2019 11:19:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565720350; cv=none; d=google.com; s=arc-20160816; b=BG5FBBpUXCj7ojdIebCLjalrHARlsgPQYVol2tNwRwCrWVoBT4S2SwqFdPppGfrtsy VWdLS2RkEMzEdJFvQ0WwtNfw7Acdu9WdN/ydVflXNzNYUuAjfmwv/Wt0+hpuJwC5XU1O 5aQTdQBpHWI2Lg2Y4xulHc/s5A34vQoM6tWYouuihP7FfFFtDJMRG/Z8nOBrP38E8afj 7369Cd80zuCdGVJsthk5s2gGaIQ4wnNUOni0lk3z1utYrwRVcqUb0506IygWsweX24K+ ociceuhjKb9UtdfJdKqN0V29ucCbKDQVhALoDBFkvLsD9scGYwCNYBMd4tn+OMtJk00D weEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=HyxHZ/T1aDqEs5WPBl96wQAfbXjL1SgYe1M4azMb1mg=; b=Pkztf02ldKphek/TXUAJCfbHFF4/UM32ShyNVFnvK1gI+RgAyakFgVrLDYDYfpNQn8 w8xt4x22jdXaQzfPLyHXxkahrGWQgSLCXdghdVUygZr1ZTtwf+Zo5vsfzA2JbENFJkL5 vPYkqoQ3sZZXurpYWAagumFHxPpcT+UkX8m4RMlCVjBKPg+UWvI1+Kd1Q29KSGMt8WiE Z1nkv5SOGtHYthp8ib11Xy5XyKqHMC3FNz1YOSJJz+pD/u5bmvNizMk7bwJ2NAftYKOb X3pxQwtzZA0KQ7kE7KZ6OqggJrIlAs4DhxcGMOJ7fhxUjAfZ8MIVBbAW8anfxUpLcjKT E0WA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BRGQXroQ; 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 f7si7493958pfq.93.2019.08.13.11.18.54; Tue, 13 Aug 2019 11:19:10 -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=BRGQXroQ; 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 S1728526AbfHMSRi (ORCPT + 99 others); Tue, 13 Aug 2019 14:17:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:60570 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728284AbfHMSRh (ORCPT ); Tue, 13 Aug 2019 14:17:37 -0400 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 0162120665; Tue, 13 Aug 2019 18:17:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565720256; bh=ODQ3g1b+4WWI1Y+sTyjeEEkmXSZ1vLnLLfxKPgIj4TM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=BRGQXroQxcAhJdNbVGc99NxIL4lFjPcDg7ibmGCnDdWLTD7m1RB9aSseD0XA2LN2J 42UcYahiZr8oXQoCdQPAaxGef5rdIp2ctdXDRxPTaQg/yRhxbHnE3uYBISvvSAfvki 0po/OvyYWIG3OJdzzVccC86G+t2vsNwWD7yaNH2Q= Date: Tue, 13 Aug 2019 20:17:34 +0200 From: Greg KH To: Matthias Maennich Cc: linux-kernel@vger.kernel.org, maco@android.com, kernel-team@android.com, arnd@arndb.de, geert@linux-m68k.org, hpa@zytor.com, jeyu@kernel.org, joel@joelfernandes.org, kstewart@linuxfoundation.org, linux-arch@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-modules@vger.kernel.org, linux-scsi@vger.kernel.org, linux-usb@vger.kernel.org, lucas.de.marchi@gmail.com, maco@google.com, michal.lkml@markovi.net, mingo@redhat.com, oneukum@suse.com, pombredanne@nexb.com, sam@ravnborg.org, sboyd@codeaurora.org, sspatil@google.com, stern@rowland.harvard.edu, tglx@linutronix.de, usb-storage@lists.one-eyed-alien.net, x86@kernel.org, yamada.masahiro@socionext.com, Andrew Morton , Johannes Weiner , "Peter Zijlstra (Intel)" , Mauro Carvalho Chehab , David Howells , Patrick Bellasi , Dan Williams , Adrian Reber , Richard Guy Briggs Subject: Re: [PATCH v2 05/10] module: add config option MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS Message-ID: <20190813181734.GE2378@kroah.com> References: <20180716122125.175792-1-maco@android.com> <20190813121733.52480-1-maennich@google.com> <20190813121733.52480-6-maennich@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190813121733.52480-6-maennich@google.com> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 13, 2019 at 01:17:02PM +0100, Matthias Maennich wrote: > If MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS is enabled (default=n), the > requirement for modules to import all namespaces that are used by > the module is relaxed. > > Enabling this option effectively allows (invalid) modules to be loaded > while only a warning is emitted. > > Disabling this option keeps the enforcement at module loading time and > loading is denied if the module's imports are not satisfactory. > > Reviewed-by: Martijn Coenen > Signed-off-by: Matthias Maennich > --- > init/Kconfig | 14 ++++++++++++++ > kernel/module.c | 11 +++++++++-- > 2 files changed, 23 insertions(+), 2 deletions(-) > > diff --git a/init/Kconfig b/init/Kconfig > index bd7d650d4a99..b3373334cdf1 100644 > --- a/init/Kconfig > +++ b/init/Kconfig > @@ -2119,6 +2119,20 @@ config MODULE_COMPRESS_XZ > > endchoice > > +config MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS > + bool "Allow loading of modules with missing namespace imports" > + default n the default for config options is always N, no need to list it here. > + help > + Symbols exported with EXPORT_SYMBOL_NS*() are considered exported in > + a namespace. A module that makes use of a symbol exported with such a > + namespace is required to import the namespace via MODULE_IMPORT_NS(). > + This option relaxes this requirement when loading a module. While > + technically there is no reason to enforce correct namespace imports, > + it creates consistency between symbols defining namespaces and users > + importing namespaces they make use of. > + > + If unsure, say N. > + > config TRIM_UNUSED_KSYMS > bool "Trim unused exported kernel symbols" > depends on MODULES && !UNUSED_SYMBOLS > diff --git a/kernel/module.c b/kernel/module.c > index 57e8253f2251..7c934aaae2d3 100644 > --- a/kernel/module.c > +++ b/kernel/module.c > @@ -1408,9 +1408,16 @@ static int verify_namespace_is_imported(const struct load_info *info, > imported_namespace = get_next_modinfo( > info, "import_ns", imported_namespace); > } > - pr_err("%s: module uses symbol (%s) from namespace %s, but does not import it.\n", > - mod->name, kernel_symbol_name(sym), namespace); > +#ifdef CONFIG_MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS > + pr_warn( > +#else > + pr_err( > +#endif > + "%s: module uses symbol (%s) from namespace %s, but does not import it.\n", > + mod->name, kernel_symbol_name(sym), namespace); > +#ifndef CONFIG_MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS > return -EINVAL; > +#endif This #ifdef mess is a hack, but oh well :) If you drop the above default line, feel free to add: Reviewed-by: Greg Kroah-Hartman