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: <20190409143641.960ac8fae3293b2d1a834cfa@linux-foundation.org>
Date:   Tue, 9 Apr 2019 14:36:41 -0700
From:   Andrew Morton <akpm@...ux-foundation.org>
To:     Yury Norov <yury.norov@...il.com>
Cc:     Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        Rasmus Villemoes <linux@...musvillemoes.dk>,
        Amritha Nambiar <amritha.nambiar@...el.com>,
        "David S. Miller" <davem@...emloft.net>, Tejun Heo <tj@...nel.org>,
        Willem de Bruijn <willemb@...gle.com>,
        Yury Norov <ynorov@...vell.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] cpumask: fix double string traverse in cpumask_parse

On Tue,  9 Apr 2019 13:42:08 -0700 Yury Norov <yury.norov@...il.com> wrote:

> From: Yury Norov <ynorov@...vell.com>
> 
> cpumask_parse() finds first occurrence of either \n or \0 by calling
> strchr() and strlen(). We can do it better with a single call of
> strchrnul().

Fair enough.

> --- a/include/linux/cpumask.h
> +++ b/include/linux/cpumask.h
> @@ -633,8 +633,7 @@ static inline int cpumask_parselist_user(const char __user *buf, int len,
>   */
>  static inline int cpumask_parse(const char *buf, struct cpumask *dstp)
>  {
> -	char *nl = strchr(buf, '\n');
> -	unsigned int len = nl ? (unsigned int)(nl - buf) : strlen(buf);
> +	unsigned int len = (unsigned int)(strchrnul(buf, '\n') - buf);

Does the cast do anything useful?  The compiler will convert a
ptrdiff_t to uint without issues, I think?

>  	return bitmap_parse(buf, len, cpumask_bits(dstp), nr_cpumask_bits);
>  }

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ