The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Vegard Nossum <vegard.nossum@oracle.com>
To: Kees Cook <kees@kernel.org>
Cc: Nathan Chancellor <nathan@kernel.org>,
	Nicolas Schier <nicolas.schier@linux.dev>,
	Jonathan Corbet <corbet@lwn.net>,
	Masahiro Yamada <masahiroy@kernel.org>,
	Randy Dunlap <rdunlap@infradead.org>,
	Arnd Bergmann <arnd@arndb.de>,
	Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
	linux-kbuild@vger.kernel.org, linux-doc@vger.kernel.org,
	Miguel Ojeda <ojeda@kernel.org>,
	Stephen Brennan <stephen.s.brennan@oracle.com>,
	Marco Bonelli <marco@mebeim.net>, Petr Vorel <pvorel@suse.cz>,
	linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [PATCH v2] kconfig: Add transitional symbol attribute for migration support
Date: Thu, 4 Sep 2025 19:03:56 +0200	[thread overview]
Message-ID: <4cbc348d-02ca-4743-b8d4-21db2ebf4460@oracle.com> (raw)
In-Reply-To: <202509031949.375138FB13@keescook>

[-- Attachment #1: Type: text/plain, Size: 1338 bytes --]


On 04/09/2025 04:51, Kees Cook wrote:
> On Mon, Sep 01, 2025 at 08:44:56PM +0200, Vegard Nossum wrote:
>> If you change sym_calc_visibility() to always return 'yes' for
>> transitional values then I don't think you need to touch
>> sym_calc_value() at all.
> 
> Hm, it looks like sym_calc_visibility() doesn't strictly just look at
> visibility. And visibility seems to "last"? And I think the "tri" still
> can't just be "yes", don't we need the other stuff handled?
> 
> Do you see a way to do it how you're suggesting? And now I wrote the
> regression tests so we can test any alternatives! ;)

Here's what I had in mind (on top of your kcfi patchset), see the
attachment.

It basically undoes all your additions to sym_calc_value() in favour of
two straightforward additions:

@@ -214,6 +214,11 @@ static void sym_calc_visibility(struct symbol *sym)
         struct property *prop;
         tristate tri;

+       if (sym->flags & SYMBOL_HIDDEN) {
+               sym->visible = yes;
+               return;
+       }
+

and

@@ -536,7 +531,7 @@ void sym_calc_value(struct symbol *sym)
                 }
         }

-       if (sym_is_choice(sym))
+       if (sym_is_choice(sym) || sym->flags & SYMBOL_HIDDEN)
                 sym->flags &= ~SYMBOL_WRITE;
  }

Let me know how that works for you (the new test passes here).


Vegard

[-- Attachment #2: hidden.patch --]
[-- Type: text/x-patch, Size: 2101 bytes --]

diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index b2686dba05ece..37958ff57f707 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -214,6 +214,11 @@ static void sym_calc_visibility(struct symbol *sym)
 	struct property *prop;
 	tristate tri;
 
+	if (sym->flags & SYMBOL_HIDDEN) {
+		sym->visible = yes;
+		return;
+	}
+
 	/* any prompt visible? */
 	tri = no;
 	for_all_prompts(sym, prop) {
@@ -408,7 +413,6 @@ void sym_calc_value(struct symbol *sym)
 	struct symbol_value newval, oldval;
 	struct property *prop;
 	struct menu *choice_menu;
-	bool usable;
 
 	if (!sym)
 		return;
@@ -448,13 +452,6 @@ void sym_calc_value(struct symbol *sym)
 	if (sym->visible != no)
 		sym->flags |= SYMBOL_WRITE;
 
-	/*
-	 * For a symbol to be processed during configuration it needs to
-	 * be either visible or a transitional symbol that is hidden from
-	 * menus and omitted from newly written .config files.
-	 */
-	usable = (sym->visible != no || (sym->flags & SYMBOL_HIDDEN));
-
 	/* set default if recursively called */
 	sym->curr = newval;
 
@@ -467,15 +464,13 @@ void sym_calc_value(struct symbol *sym)
 			sym_calc_choice(choice_menu);
 			newval.tri = sym->curr.tri;
 		} else {
-			if (usable) {
+			if (sym->visible != no) {
 				/* if the symbol is visible use the user value
 				 * if available, otherwise try the default value
 				 */
 				if (sym_has_value(sym)) {
-					tristate value = (sym->flags & SYMBOL_HIDDEN) ?
-						sym->def[S_DEF_USER].tri : sym->visible;
 					newval.tri = EXPR_AND(sym->def[S_DEF_USER].tri,
-							      value);
+							      sym->visible);
 					goto calc_newval;
 				}
 			}
@@ -507,7 +502,7 @@ void sym_calc_value(struct symbol *sym)
 	case S_STRING:
 	case S_HEX:
 	case S_INT:
-		if (usable && sym_has_value(sym)) {
+		if (sym->visible != no && sym_has_value(sym)) {
 			newval.val = sym->def[S_DEF_USER].val;
 			break;
 		}
@@ -536,7 +531,7 @@ void sym_calc_value(struct symbol *sym)
 		}
 	}
 
-	if (sym_is_choice(sym))
+	if (sym_is_choice(sym) || sym->flags & SYMBOL_HIDDEN)
 		sym->flags &= ~SYMBOL_WRITE;
 }
 

  reply	other threads:[~2025-09-04 17:04 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-30  2:01 [PATCH v2] kconfig: Add transitional symbol attribute for migration support Kees Cook
2025-09-01  8:34 ` Vegard Nossum
2025-09-01 16:56   ` Kees Cook
2025-09-01 18:20     ` Vegard Nossum
2025-09-01 18:31       ` Kees Cook
2025-09-01 18:44         ` Vegard Nossum
2025-09-04  2:51           ` Kees Cook
2025-09-04 17:03             ` Vegard Nossum [this message]
2025-09-04 17:10               ` Vegard Nossum
2025-09-05  9:41                 ` Vegard Nossum
2025-09-05 16:24                   ` Kees Cook
2025-09-05 16:23               ` Kees Cook
2025-09-23 21:36                 ` Kees Cook
2025-09-01  9:09 ` Jani Nikula
2025-09-01 16:48   ` Kees Cook
2025-09-01 16:39 ` Randy Dunlap
2025-09-01 16:45   ` Kees Cook
2025-09-01 16:54     ` Randy Dunlap

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4cbc348d-02ca-4743-b8d4-21db2ebf4460@oracle.com \
    --to=vegard.nossum@oracle.com \
    --cc=arnd@arndb.de \
    --cc=corbet@lwn.net \
    --cc=kees@kernel.org \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marco@mebeim.net \
    --cc=masahiroy@kernel.org \
    --cc=nathan@kernel.org \
    --cc=nicolas.schier@linux.dev \
    --cc=ojeda@kernel.org \
    --cc=pvorel@suse.cz \
    --cc=rdunlap@infradead.org \
    --cc=stephen.s.brennan@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox