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  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Mon, 21 Dec 2020 16:16:01 +0100
From:   Petr Mladek <pmladek@...e.com>
To:     Richard Fitzgerald <rf@...nsource.cirrus.com>
Cc:     rostedt@...dmis.org, sergey.senozhatsky@...il.com,
        shuah@...nel.org, patches@...nsource.cirrus.com,
        linux-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org,
        Stanislaw Gruszka <stf_xl@...pl>,
        Kalle Valo <kvalo@...eaurora.org>,
        "David S. Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        linux-wireless@...r.kernel.org, netdev@...r.kernel.org
Subject: Re: [PATCH v3 1/4] lib: vsprintf: scanf: Negative number must have
 field width > 1

On Thu 2020-12-17 18:00:54, Richard Fitzgerald wrote:
> If a signed number field starts with a '-' the field width must be > 1,
> or unlimited, to allow at least one digit after the '-'.
> 
> This patch adds a check for this. If a signed field starts with '-'
> and field_width == 1 the scanf will quit.
> 
> It is ok for a signed number field to have a field width of 1 if it
> starts with a digit. In that case the single digit can be converted.

The change makes perfect sense. vsscanf() should always process only one
character when the field width is 1.

Well, it has a potential to break existing users that rely on the
broken behavior. Fortunately, there seems be only one:

	drivers/net/wireless/intel/iwlegacy/3945-mac.c: if (sscanf(buf, "%1i", &ant) != 1) {

It is used to set a device parameter: il3945_mod_params.antenna.
There are three valid values:

	enum il3945_antenna {
		IL_ANTENNA_DIVERSITY,
		IL_ANTENNA_MAIN,
		IL_ANTENNA_AUX
	};

So, we should be on the safe side.

Anyway, adding people from
get_maintainer.pl drivers/net/wireless/intel/iwlegacy/3945-mac.c
so that they are aware of this.

> Signed-off-by: Richard Fitzgerald <rf@...nsource.cirrus.com>

Reviewed-by: Petr Mladek <pmladek@...e.com>

Best Regards,
Petr

> ---
>  lib/vsprintf.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> index 14c9a6af1b23..8954ff94a53c 100644
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -3433,8 +3433,12 @@ int vsscanf(const char *buf, const char *fmt, va_list args)
>  		str = skip_spaces(str);
>  
>  		digit = *str;
> -		if (is_sign && digit == '-')
> +		if (is_sign && digit == '-') {
> +			if (field_width == 1)
> +				break;
> +
>  			digit = *(str + 1);
> +		}
>  
>  		if (!digit
>  		    || (base == 16 && !isxdigit(digit))
> -- 
> 2.20.1

Powered by blists - more mailing lists