Re: [PATCH v2] kconfig: Add transitional symbol attribute for migration support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 01/09/2025 20:31, Kees Cook wrote:
On Mon, Sep 01, 2025 at 08:20:18PM +0200, Vegard Nossum wrote:

On 01/09/2025 18:56, Kees Cook wrote:
@@ -459,13 +462,15 @@ void sym_calc_value(struct symbol *sym)
    			sym_calc_choice(choice_menu);
    			newval.tri = sym->curr.tri;
    		} else {
-			if (sym->visible != no) {
+			if (sym->usable) {
    				/* if the symbol is visible use the user value
    				 * if available, otherwise try the default value
    				 */
    				if (sym_has_value(sym)) {
+					tristate value = sym->transitional ?
+						sym->def[S_DEF_USER].tri : sym->visible;
    					newval.tri = EXPR_AND(sym->def[S_DEF_USER].tri,
-							      sym->visible);
+							      value);
This looks a bit odd to me. Just thinking out loud: your new logic is
there to be able to use a value even though it's not visible. In the
case where it's transitional you use the .config value instead of the
condition that makes it visible.

Could you simply change sym_calc_visibility() instead to always return
'yes' when the symbol is transitional? Wouldn't that simplify everything
in sym_calc_value()?
It's a tristate, so "m" is also possible besides "y". (sym->visible is
also a tristate. 🙂

That would be fine, right?

We'd pass the if (sym->visible != no) check... we'd do the

newval.tri = EXPR_AND(sym->def[S_DEF_USER].tri, sym->visible);

EXPR_AND() is basically min() (with n=0, m=1, y=2), so effectively it
would end up doing

newval.tri = min(sym->def[S_DEF_USER].tri, 2);

which is the same as

newval.tri = sym->def[S_DEF_USER].tri;

That's what your code is currently doing too, but in a much more
roundabout way.

Right, it was this:

     newval.tri = EXPR_AND(sym->def[S_DEF_USER].tri, sym->visible);

But I made it effectively:

   if (sym->transitional)
     newval.tri = EXPR_AND(sym->def[S_DEF_USER].tri, sym->def[S_DEF_USER].tri);
   else
     newval.tri = EXPR_AND(sym->def[S_DEF_USER].tri, sym->visible);

That first "if" is kind of pointless. I just sent the v3 before I saw
this email. :P

I was trying to avoid yet more indentation, but I could change it to:

		if (sym->transitional)
			newval.tri = sym->def[S_DEF_USER].tri;
		else
			newval.tri = EXPR_AND(sym->def[S_DEF_USER].tri,
					      sym->visible);

?


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.


Vegard




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux