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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <YoIsC8Ay+Th0n4bA@li-6e1fa1cc-351b-11b2-a85c-b897023bb5f3.ibm.com>
Date:   Mon, 16 May 2022 16:18:43 +0530
From:   Jagdish Gediya <jvgediya@...ux.ibm.com>
To:     Andrew Morton <akpm@...ux-foundation.org>
Cc:     Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        linux-kernel@...r.kernel.org, linux-mm@...ck.org,
        Jonathan.Cameron@...wei.com, adobriyan@...il.com,
        rf@...nsource.cirrus.com, pmladek@...e.com, ying.huang@...el.com,
        dave.hansen@...el.com
Subject: Re: [PATCH v2 2/2] mm: Covert sysfs input to bool using kstrtobool()

On Thu, May 12, 2022 at 06:05:37PM -0700, Andrew Morton wrote:
> On Wed, 27 Apr 2022 18:17:29 +0300 Andy Shevchenko <andriy.shevchenko@...ux.intel.com> wrote:
> 
> > On Tue, Apr 26, 2022 at 10:30:40PM +0530, Jagdish Gediya wrote:
> > > Sysfs input conversion to corrosponding bool value e.g. "false" or "0"
> > > to false, "true" or "1" to true are currently handled through strncmp
> > > at multiple places. Use kstrtobool() to convert sysfs input to bool
> > > value.
> > 
> > ...
> > 
> > > +	if (kstrtobool(buf, &numa_demotion_enabled))
> > >  		return -EINVAL;
> > 
> > Hmm... The commit message doesn't explain what's wrong with the error codes
> > returned by kstrtobool(). Can't it be
> > 
> > 	ret = kstrtobool();
> > 	if (ret)
> > 		return ret;
> > 
> > ?
> 
> Jagdish fell asleep.
Sorry, I was away from work for few days.
> Yes, I agree.  It has no practical difference at present because
> kstrtobool() can only return 0 or -EINVAL.  I did this:
> 
> --- a/mm/migrate.c~mm-convert-sysfs-input-to-bool-using-kstrtobool-fix
> +++ a/mm/migrate.c
> @@ -2523,8 +2523,10 @@ static ssize_t numa_demotion_enabled_sto
>  					   struct kobj_attribute *attr,
>  					   const char *buf, size_t count)
>  {
> -	if (kstrtobool(buf, &numa_demotion_enabled))
> -		return -EINVAL;
> +	ssize_t ret;
> +
> +	ret = kstrtobool(buf, &numa_demotion_enabled);
> +		return ret;
>  
>  	return count;
>  }
> --- a/mm/swap_state.c~mm-convert-sysfs-input-to-bool-using-kstrtobool-fix
> +++ a/mm/swap_state.c
> @@ -874,8 +874,11 @@ static ssize_t vma_ra_enabled_store(stru
>  				      struct kobj_attribute *attr,
>  				      const char *buf, size_t count)
>  {
> -	if (kstrtobool(buf, &enable_vma_readahead))
> -		return -EINVAL;
> +	ssize_t ret;
> +
> +	ret = kstrtobool(buf, &enable_vma_readahead);
> +	if (ret)
> +		return ret;
>  
>  	return count;
>  }
> _
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ