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>] [day] [month] [year] [list]
Message-Id: <20240126133010.78999-1-masahiroy@kernel.org>
Date: Fri, 26 Jan 2024 22:30:10 +0900
From: Masahiro Yamada <masahiroy@...nel.org>
To: linux-kbuild@...r.kernel.org
Cc: linux-kernel@...r.kernel.org,
	Geert Uytterhoeven <geert+renesas@...der.be>,
	Yoann Congal <yoann.congal@...le.fr>,
	Masahiro Yamada <masahiroy@...nel.org>
Subject: [PATCH] kconfig: initialize sym->curr.tri to no for all symbol types again

In C programming, a non-zero value is interpreted as true, and a zero
value as false.

Kconfig has never worked like that; only 'bool' and 'tristate' symbols
are properly handled in conditionals. The other types ('int', 'hex',
'string') are always interpreted as false if used in boolean contexts.

Until commit 4e244c10eab3 ("kconfig: remove unneeded symbol_empty
variable") accidentally changed the behavior, the default of
CONFIG_LOG_CPU_MAX_BUF_SHIFT was unconditionally 12, because the 'int'
symbol 'BASE_SMALL' was evaluated as false, hence 'if !BASE_SMALL' was
always true.

You can confirm it as follows:

  $ git checkout 4e244c10eab3^

  $ make -s ARCH=x86_64 defconfig
  $ grep -e LOG_CPU_MAX_BUF_SHIFT -e BASE_SMALL -e BASE_FULL .config
  CONFIG_LOG_CPU_MAX_BUF_SHIFT=12
  CONFIG_BASE_FULL=y
  CONFIG_BASE_SMALL=0

  $ make -s ARCH=arm keystone_defconfig
  $ grep -e LOG_CPU_MAX_BUF_SHIFT -e BASE_SMALL -e BASE_FULL .config
  CONFIG_LOG_CPU_MAX_BUF_SHIFT=12
  # CONFIG_BASE_FULL is not set
  CONFIG_BASE_SMALL=1

CONFIG_LOG_CPU_MAX_BUF_SHIFT defaults to 12 irrespective of the value
of CONFIG_BASE_SMALL.

Since commit 4e244c10eab3, this is an undefined behavior because
sym_calc_value() stopped setting the sym->curr.tri field for 'int',
'hex', and 'string' symbols.

Commit 23b2899f7f19 ("printk: allow increasing the ring buffer depending
on the number of CPUs") presumably intended the following:

  config LOG_CPU_MAX_BUF_SHIFT
          int "CPU kernel log buffer size contribution (13 => 8 KB, 17 => 128KB)"
            [snip]
          default 12 if BASE_SMALL == 0
          default 0

But, the correct fixes would potentially impact multiple defconfigs,
hence they should be reviewed in each dedicated subsystem.

Restore the original behavior for now.

Fixes: 4e244c10eab3 ("kconfig: remove unneeded symbol_empty variable")
Reported-by: Geert Uytterhoeven <geert+renesas@...der.be>
Closes: https://lore.kernel.org/all/CAMuHMdWm6u1wX7efZQf=2XUAHascps76YQac6rdnQGhc8nop_Q@mail.gmail.com/
Signed-off-by: Masahiro Yamada <masahiroy@...nel.org>
---

 scripts/kconfig/symbol.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index f615e2c1e85d..1290c6d2f8c2 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -346,6 +346,8 @@ void sym_calc_value(struct symbol *sym)
 
 	oldval = sym->curr;
 
+	newval.tri = no;
+
 	switch (sym->type) {
 	case S_INT:
 		newval.val = "0";
@@ -358,7 +360,7 @@ void sym_calc_value(struct symbol *sym)
 		break;
 	case S_BOOLEAN:
 	case S_TRISTATE:
-		newval = symbol_no.curr;
+		newval.val = "n";
 		break;
 	default:
 		sym->curr.val = sym->name;
-- 
2.40.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ