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: <Yt6u34sigPEkeZ0Y@FVFF77S0Q05N.cambridge.arm.com>
Date:   Mon, 25 Jul 2022 15:55:27 +0100
From:   Mark Rutland <mark.rutland@....com>
To:     Jagdish Gediya <jvgediya@...ux.ibm.com>
Cc:     linux-kernel@...r.kernel.org, linux-mm@...ck.org,
        willy@...radead.org, ying.huang@...el.com, dave.hansen@...el.com,
        Jonathan.Cameron@...wei.com, adobriyan@...il.com,
        akpm@...ux-foundation.org, andriy.shevchenko@...ux.intel.com,
        rf@...nsource.cirrus.com, pmladek@...e.com, will@...nel.org
Subject: Re: [PATCH v3 1/2] lib/kstrtox.c: Add "false"/"true" support to
 kstrtobool()

On Tue, Apr 26, 2022 at 11:32:02PM +0530, Jagdish Gediya wrote:
> At many places in kernel, It is necessary to convert sysfs input
> to corrosponding bool value e.g. "false" or "0" need to be converted
> to bool false, "true" or "1" need to be converted to bool true,
> places where such conversion is needed currently check the input
> string manually, kstrtobool() can be utilized at such places but
> currently it doesn't have support to accept "false"/"true".
> 
> Add support to accept "false"/"true" as valid string in kstrtobool().
> 
> Signed-off-by: Jagdish Gediya <jvgediya@...ux.ibm.com>
> Reviewed-by: Matthew Wilcox (Oracle) <willy@...radead.org>

I've just spotted that this broke arm64's "rodata=full" command line option,
since "full" gets parsed as 'f' = FALSE, when previously that would have been
rejected. So anyone passing "rodata=full" on the command line will have rodata
disabled, which is not what they wanted.

The current state of things is a bit messy (we prase the option twice because
arch code needs it early), and we can probably fix that with some refactoring,
but I do wonder if we actually want to open up the sysfs parsing to accept
anything *beginning* with [tTfF] rather than the full "true" and "false"
strings as previously, or whether it's worth reverting this for now in case
anything else is affected.

Mark.

> ---
> Chnages in v2:
> - kstrtobool to kstrtobool() in commit message.
> - Split single patch into 2
> - Remove strcmp usage from kstrtobool() and instead compare 1st
>   character only.
> 
> Changes in v3:
> - Covert -> Convert in patch 2 subject
> - Collected Reviewed-by: Matthew Wilcox (Oracle) <willy@...radead.org>
> 
>  lib/kstrtox.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/kstrtox.c b/lib/kstrtox.c
> index 886510d248e5..465e31e4d70d 100644
> --- a/lib/kstrtox.c
> +++ b/lib/kstrtox.c
> @@ -340,7 +340,7 @@ EXPORT_SYMBOL(kstrtos8);
>   * @s: input string
>   * @res: result
>   *
> - * This routine returns 0 iff the first character is one of 'Yy1Nn0', or
> + * This routine returns 0 if the first character is one of 'YyTt1NnFf0', or
>   * [oO][NnFf] for "on" and "off". Otherwise it will return -EINVAL.  Value
>   * pointed to by res is updated upon finding a match.
>   */
> @@ -353,11 +353,15 @@ int kstrtobool(const char *s, bool *res)
>  	switch (s[0]) {
>  	case 'y':
>  	case 'Y':
> +	case 't':
> +	case 'T':
>  	case '1':
>  		*res = true;
>  		return 0;
>  	case 'n':
>  	case 'N':
> +	case 'f':
> +	case 'F':
>  	case '0':
>  		*res = false;
>  		return 0;
> -- 
> 2.35.1
> 
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ