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-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <31306b8b-d534-42ad-8ece-b4b558023efd@smile.fr>
Date: Mon, 29 Jan 2024 13:56:44 +0100
From: Yoann Congal <yoann.congal@...le.fr>
To: Jiri Slaby <jirislaby@...nel.org>, x86@...nel.org,
 linux-kernel@...r.kernel.org, linux-serial@...r.kernel.org,
 linux-fsdevel@...r.kernel.org
Cc: linux-kbuild@...r.kernel.org, Geert Uytterhoeven <geert@...ux-m68k.org>,
 "Luis R . Rodriguez" <mcgrof@...nel.org>,
 Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>,
 Borislav Petkov <bp@...en8.de>, Dave Hansen <dave.hansen@...ux.intel.com>,
 "H. Peter Anvin" <hpa@...or.com>,
 Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
 Willem de Bruijn <willemdebruijn.kernel@...il.com>,
 Matthew Wilcox <willy@...radead.org>, Peter Zijlstra <peterz@...radead.org>,
 Darren Hart <dvhart@...radead.org>, Davidlohr Bueso <dave@...olabs.net>,
 André Almeida <andrealmeid@...lia.com>,
 Masahiro Yamada <masahiroy@...nel.org>
Subject: Re: [PATCH v2] printk: Remove redundant CONFIG_BASE_SMALL



Le 29/01/2024 à 12:28, Jiri Slaby a écrit :
> On 27. 01. 24, 23:00, Yoann Congal wrote:
>> CONFIG_BASE_SMALL is currently a type int but is only used as a boolean
>> equivalent to !CONFIG_BASE_FULL.
>>
>> So, remove it entirely and move every usage to !CONFIG_BASE_FULL.
>>
>> In addition, recent kconfig changes (see the discussion in Closes: tag)
>> revealed that using:
>>    config SOMETHING
>>       default "some value" if X
>> does not work as expected if X is not of type bool.
>>
>> CONFIG_BASE_SMALL was used that way in init/Kconfig:
>>    config LOG_CPU_MAX_BUF_SHIFT
>>        default 12 if !BASE_SMALL
>>        default 0 if BASE_SMALL
>>
>> Note: This changes CONFIG_LOG_CPU_MAX_BUF_SHIFT=12 to
>> CONFIG_LOG_CPU_MAX_BUF_SHIFT=0 for some defconfigs, but that will not be
>> a big impact due to this code in kernel/printk/printk.c:
>>    /* by default this will only continue through for large > 64 CPUs */
>>    if (cpu_extra <= __LOG_BUF_LEN / 2)
>>            return;
>>
>> Signed-off-by: Yoann Congal <yoann.congal@...le.fr>
>> Reported-by: Geert Uytterhoeven <geert@...ux-m68k.org>
>> Closes: https://lore.kernel.org/all/CAMuHMdWm6u1wX7efZQf=2XUAHascps76YQac6rdnQGhc8nop_Q@mail.gmail.com/
>> Fixes: 4e244c10eab3 ("kconfig: remove unneeded symbol_empty variable")
>> ---
>> v1 patch was named "treewide: Change CONFIG_BASE_SMALL to bool type"
>> https://lore.kernel.org/all/20240126163032.1613731-1-yoann.congal@smile.fr/
>>
>> v1 -> v2: Applied Masahiro Yamada's comments (Thanks!):
>> * Changed from "Change CONFIG_BASE_SMALL to type bool" to
>>    "Remove it and switch usage to !CONFIG_BASE_FULL"
>> * Fixed "Fixes:" tag and reference to the mailing list thread.
>> * Added a note about CONFIG_LOG_CPU_MAX_BUF_SHIFT changing.
> ...
>> --- a/drivers/tty/vt/vc_screen.c
>> +++ b/drivers/tty/vt/vc_screen.c
>> @@ -51,7 +51,7 @@
>>   #include <asm/unaligned.h>
>>     #define HEADER_SIZE    4u
>> -#define CON_BUF_SIZE (CONFIG_BASE_SMALL ? 256 : PAGE_SIZE)
>> +#define CON_BUF_SIZE (IS_ENABLED(CONFIG_BASE_FULL) ? PAGE_SIZE : 256)
> 
> Why is the IS_ENABLED() addition needed? You don't say anything about that in the commit log.
> 
> thanks,

It is needed because we go from using CONFIG_BASE_*SMALL* which is of type _int_ (so either defined to 0 or some other non-zero value) to CONFIG_BASE_*FULL* which is of type _bool_ (so, it is either enabled or not).
If I understood correctly, the proper way to check a config of type bool inside of a C function is with IS_ENABLED().

Another way to say this is :
  CONFIG_BASE_SMALL != 0
is equivalent to
  !IS_ENABLED(CONFIG_BASE_FULL)

Finally, CONFIG_XXX is not defined if CONFIG_XXX is a type bool and disabled so :
  CONFIG_XXX? "yes":"no";
.. does not compile.

I will try to explain it better in the v3 commit log.

Thanks!

Regards,
-- 
Yoann Congal
Smile ECS - Tech Expert

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ