lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Fri,  2 Oct 2015 08:34:28 +0800
From:	Nicolas Boichat <drinkcat@...omium.org>
To:	linux-kbuild@...r.kernel.org
Cc:	Michal Marek <mmarek@...e.com>,
	"Paul E . McKenney" <paulmck@...ux.vnet.ibm.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Ingo Molnar <mingo@...nel.org>,
	Pranith Kumar <bobby.prani@...il.com>,
	Peter Zijlstra <peterz@...radead.org>,
	Vladimir Murzin <vladimir.murzin@....com>,
	Davidlohr Bueso <dave@...olabs.net>,
	Joonsoo Kim <iamjoonsoo.kim@....com>,
	John Stultz <john.stultz@...aro.org>,
	Jan Kiszka <jan.kiszka@...mens.com>,
	Rusty Russell <rusty@...tcorp.com.au>,
	Quentin Casasnovas <quentin.casasnovas@...cle.com>,
	Paul Gortmaker <paul.gortmaker@...driver.com>,
	Chris Metcalf <cmetcalf@...hip.com>,
	Takashi Iwai <tiwai@...e.de>,
	Nicolas Boichat <drinkcat@...omium.org>,
	Kyle McMartin <kyle@...hat.com>, linux-kernel@...r.kernel.org,
	Jonathan Kliegman <kliegs@...omium.org>, olofj@...omium.org,
	Sam Ravnborg <sam@...nborg.org>
Subject: [PATCH] modpost: Add flag -f for making section mismatches fatal

The section mismatch warning can be easy to miss during the kernel build
process. Allow it to be marked as fatal to be easily caught and prevent
bugs from slipping in.

Setting CONFIG_SECTION_MISMATCH_WARNING=y causes these warnings to be
non-fatal, since there are a number of section mismatches when using
allmodconfig on some architectures, and we do not want to break these
builds by default.

Signed-off-by: Nicolas Boichat <drinkcat@...omium.org>

Change-Id: Ic346706e3297c9f0d790e3552aa94e5cff9897a6
---

I'm trying to revive this old patch. When it was first submitted [1],
Jonathan got the following feedback:
 - The logic of the option should be inverted (i.e. SECTION_MISMATCH_WARNING),
   so that is not not enabled in allmodconfig for some architectures that do
   have section mismatches. I've seen some failures (namely, on arm64), so I
   did that.
 - CONFIG_DEBUG_SECTION_MISMATCH should be removed and warnings should always
   be shown verbosely. This option does 3 things:
     1. Enable -fno-inline-functions-called-onc
     2. Run the section mismatch analysis for each module/built-in.o
     3. Enable verbose reporting from modpost
   We definitely do not want 1 by default, so I think we should keep the option.
   If we enable 2 & 3 by default, which I think would be reasonable, then the
   option name does not make much sense anymore, and I'm not sure what to do
   with the documentation that is currently provided in the Kconfig description.

Tested on x86-64 allmodconfig, setting the option to =n, and creating a
section mismatch by running:
sed -i -e 's/\(ssize_t soc_codec_reg_show\)/__init \1/' sound/soc/soc-core.c

Applies on linux-next/20151001

[1] http://thread.gmane.org/gmane.linux.kbuild.devel/9044

 lib/Kconfig.debug        |  9 +++++++++
 scripts/Makefile.modpost |  1 +
 scripts/mod/modpost.c    | 24 +++++++++++++++++-------
 3 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index d190d44..74314bb 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -311,6 +311,15 @@ config DEBUG_SECTION_MISMATCH
 	  - Enable verbose reporting from modpost in order to help resolve
 	    the section mismatches that are reported.
 
+config SECTION_MISMATCH_WARNING
+	bool "Make section mismatch errors non-fatal"
+	default y
+	help
+	  If you say N here, the build process will fail if there are any
+	  section mismatch, instead of just throwing warnings.
+
+	  If unsure, say Y.
+
 #
 # Select this config option from the architecture Kconfig, if it
 # is preferred to always offer frame pointers as a config
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index 9c40dae..d2cbd83 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -77,6 +77,7 @@ modpost = scripts/mod/modpost                    \
  $(if $(KBUILD_EXTRA_SYMBOLS), $(patsubst %, -e %,$(KBUILD_EXTRA_SYMBOLS))) \
  $(if $(KBUILD_EXTMOD),-o $(modulesymfile))      \
  $(if $(CONFIG_DEBUG_SECTION_MISMATCH),,-S)      \
+ $(if $(CONFIG_SECTION_MISMATCH_WARNING),,-f)    \
  $(if $(KBUILD_EXTMOD)$(KBUILD_MODPOST_WARN),-w) \
  $(if $(CONFIG_LTO),-w)
 
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index d583c98..bc729b8 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -38,6 +38,7 @@ static int warn_unresolved = 0;
 /* How a symbol is exported */
 static int sec_mismatch_count = 0;
 static int sec_mismatch_verbose = 1;
+static int sec_mismatch_fatal = 0;
 /* ignore missing files */
 static int ignore_missing_files;
 
@@ -2385,7 +2386,7 @@ int main(int argc, char **argv)
 	struct ext_sym_list *extsym_iter;
 	struct ext_sym_list *extsym_start = NULL;
 
-	while ((opt = getopt(argc, argv, "i:I:e:mnsST:o:awM:K:")) != -1) {
+	while ((opt = getopt(argc, argv, "i:I:e:mnsST:o:awM:K:f")) != -1) {
 		switch (opt) {
 		case 'i':
 			kernel_read = optarg;
@@ -2426,6 +2427,9 @@ int main(int argc, char **argv)
 		case 'w':
 			warn_unresolved = 1;
 			break;
+		case 'f':
+			sec_mismatch_fatal = 1;
+			break;
 		default:
 			exit(1);
 		}
@@ -2475,14 +2479,20 @@ int main(int argc, char **argv)
 		sprintf(fname, "%s.mod.c", mod->name);
 		write_if_changed(&buf, fname);
 	}
-
 	if (dump_write)
 		write_dump(dump_write);
-	if (sec_mismatch_count && !sec_mismatch_verbose)
-		warn("modpost: Found %d section mismatch(es).\n"
-		     "To see full details build your kernel with:\n"
-		     "'make CONFIG_DEBUG_SECTION_MISMATCH=y'\n",
-		     sec_mismatch_count);
+	if (sec_mismatch_count) {
+		if (!sec_mismatch_verbose) {
+			warn("modpost: Found %d section mismatch(es).\n"
+			     "To see full details build your kernel with:\n"
+			     "'make CONFIG_DEBUG_SECTION_MISMATCH=y'\n",
+			     sec_mismatch_count);
+		}
+		if (sec_mismatch_fatal) {
+			fatal("modpost: Section mismatches detected.\n"
+			      "Set CONFIG_SECTION_MISMATCH_WARNING=y to allow them.\n");
+		}
+	}
 
 	return err;
 }
-- 
2.6.0.rc2.230.g3dd15c0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ