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, 19 May 2017 09:08:13 -0600
From:   Tycho Andersen <tycho@...ker.com>
To:     "Yann E . MORIN" <yann.morin.1998@...e.fr>
Cc:     linux-kbuild@...r.kernel.org, linux-kernel@...r.kernel.org,
        Tycho Andersen <tycho@...ker.com>,
        Roman Zippel <zippel@...ux-m68k.org>
Subject: [PATCH] kconfig: always use user input symbols

...regardless of visibility.

When a symbol that is not visible by default (e.g. PNFS_FLEXFILE_LAYOUT)
has a default value, it is impossible to set the value to something not the
default:

~/packages/linux render-symbol-inputs grep FLEXFILE .config
CONFIG_PNFS_FLEXFILE_LAYOUT=y
~/packages/linux render-symbol-inputs make oldconfig
scripts/kconfig/conf  --oldconfig Kconfig
~/packages/linux render-symbol-inputs grep FLEXFILE .config
CONFIG_PNFS_FLEXFILE_LAYOUT=m

There are two reasons for this: the symbol's user input value is only
considered when it is visible (hunks 2 and 3), and the user values are
explicitly ignored (hunk 1) if the symbols are not visible.

It's not clear to me why hunk 1 exists. I'm sure it solve some problem, but
I'm not sure why we would ever want to discard user input values, and
causes a problem exactly as the comment describes.

Signed-off-by: Tycho Andersen <tycho@...ker.com>
CC: Roman Zippel <zippel@...ux-m68k.org>
---
I don't know much about how kconfig works, I just noticed this when trying
to do some automatic merging of configs. My main goal is to build a kernel
without modules, but after a merge and running `make oldconfig`, some
symbols always come back set as modules.
---
 scripts/kconfig/confdata.c |  7 -------
 scripts/kconfig/symbol.c   | 32 ++++++++++++++++++--------------
 2 files changed, 18 insertions(+), 21 deletions(-)

diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 297b079..3537090 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -448,13 +448,6 @@ int conf_read(const char *name)
 
 	for_all_symbols(i, sym) {
 		if (sym_has_value(sym) && !sym_is_choice_value(sym)) {
-			/* Reset values of generates values, so they'll appear
-			 * as new, if they should become visible, but that
-			 * doesn't quite work if the Kconfig and the saved
-			 * configuration disagree.
-			 */
-			if (sym->visible == no && !conf_unsaved)
-				sym->flags &= ~SYMBOL_DEF_USER;
 			switch (sym->type) {
 			case S_STRING:
 			case S_INT:
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index 20136ff..27fca39 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -386,17 +386,19 @@ void sym_calc_value(struct symbol *sym)
 			prop = sym_get_choice_prop(sym);
 			newval.tri = (prop_get_symbol(prop)->curr.val == sym) ? yes : no;
 		} else {
-			if (sym->visible != no) {
-				/* if the symbol is visible use the user value
-				 * if available, otherwise try the default value
-				 */
+			/* If the user defined a value, let's not ignore it,
+			 * even if the symbol is not visible.
+			 */
+			if (sym_has_value(sym)) {
 				sym->flags |= SYMBOL_WRITE;
-				if (sym_has_value(sym)) {
-					newval.tri = EXPR_AND(sym->def[S_DEF_USER].tri,
-							      sym->visible);
-					goto calc_newval;
-				}
+				newval.tri = sym->def[S_DEF_USER].tri;
+				goto calc_newval;
 			}
+
+			if (sym->visible != no)
+				sym->flags |= SYMBOL_WRITE;
+
+			/* otherwise, let's use the default */
 			if (sym->rev_dep.tri != no)
 				sym->flags |= SYMBOL_WRITE;
 			if (!sym_is_choice(sym)) {
@@ -433,13 +435,15 @@ void sym_calc_value(struct symbol *sym)
 	case S_STRING:
 	case S_HEX:
 	case S_INT:
-		if (sym->visible != no) {
+		if (sym_has_value(sym)) {
 			sym->flags |= SYMBOL_WRITE;
-			if (sym_has_value(sym)) {
-				newval.val = sym->def[S_DEF_USER].val;
-				break;
-			}
+			newval.val = sym->def[S_DEF_USER].val;
+			goto calc_newval;
 		}
+
+		if (sym->visible != no)
+			sym->flags |= SYMBOL_WRITE;
+
 		prop = sym_get_default_prop(sym);
 		if (prop) {
 			struct symbol *ds = prop_get_symbol(prop);
-- 
2.9.3

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ