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] [day] [month] [year] [list]
Message-ID: <CAK7LNAQV7vDLP3VzpSY41K6+DpFAi3Q021zsW5jqR0Ck3C+r_A@mail.gmail.com>
Date: Sun, 19 May 2024 18:50:29 +0900
From: Masahiro Yamada <masahiroy@...nel.org>
To: linux-kbuild@...r.kernel.org
Cc: linux-kernel@...r.kernel.org
Subject: Re: [PATCH] kconfig: fix comparison to constant symbols, 'm', 'n'

On Sun, May 19, 2024 at 6:22 PM Masahiro Yamada <masahiroy@...nel.org> wrote:
>
> Currently, comparisons to 'm' or 'n' result in incorrect output.
>
> [Test Code]
>
>     config MODULES
>             def_bool y
>             modules
>
>     config A
>             def_tristate m
>
>     config B
>             def_bool A > n
>
> CONFIG_B is actually unset, while the expectation is CONFIG_B=y.
>
> The reason for the issue is because Kconfig compares the tristate values
> as strings.
>
> Currently, the .type fields of the constant symbols, 'y', 'm', and 'n'
> are unspecified, i.e., S_UNKNOWN.
>
> When expr_calc_value() evaluates 'A > n', it checks the types of 'A' and
> 'n' to determine how to compare them.
>
> The left-hand side, 'A', is a tristate symbol with a value of 'm', which
> corresponds to a numeric value of 1. (Internally, 'y', 'm', and 'n' are
> represented as 2, 1, and 0, respectively.)
>
> The right-hand side, 'n', has an unknown type, so it is treated as the
> string "n" during the comparison.
>
> expr_calc_value() compares two values numerically only when both can
> have numeric values. Otherwise, they are compared as strings.
>
>     symbol    numeric value    ASCII code
>     -------------------------------------
>       y           2             0x79
>       m           1             0x6d
>       n           0             0x6e
>
> 'm' is greater than 'n' if compared numerically (since 1 is greater
> than 0), but small than 'n' if compared as strings (since the ASCII


small than -> smaller than




-- 
Best Regards
Masahiro Yamada

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ