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] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 2 Apr 2020 22:35:00 +0300
From:   Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:     Reinette Chatre <reinette.chatre@...el.com>
Cc:     tglx@...utronix.de, fenghua.yu@...el.com, bp@...en8.de,
        tony.luck@...el.com, kuo-lang.tseng@...el.com, mingo@...hat.com,
        babu.moger@....com, hpa@...or.com, x86@...nel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2] x86/resctrl: Use appropriate API for strings
 terminated by newline

On Thu, Apr 02, 2020 at 04:06:25PM +0300, Andy Shevchenko wrote:
> On Wed, Apr 01, 2020 at 11:30:48AM -0700, Reinette Chatre wrote:

...

> >  	int ret = 0;
> > +	int user_m;

...and forgot to mention this...

	int user_m;
	int ret;

> >  	/* Valid input requires a trailing newline */
> >  	if (nbytes == 0 || buf[nbytes - 1] != '\n')
> >  		return -EINVAL;
> > -	buf[nbytes - 1] = '\0';
> 
> The above test is not needed and comment now is misleading.
> WRT nbytes I believe that kernel fs code checks for that.
> 
> >  	rdtgrp = rdtgroup_kn_lock_live(of->kn);
> >  	if (!rdtgrp) {
> > @@ -1428,11 +1428,15 @@ static ssize_t rdtgroup_mode_write(struct kernfs_open_file *of,
> >  
> >  	mode = rdtgrp->mode;
> >  
> > -	if ((!strcmp(buf, "shareable") && mode == RDT_MODE_SHAREABLE) ||
> > -	    (!strcmp(buf, "exclusive") && mode == RDT_MODE_EXCLUSIVE) ||
> > -	    (!strcmp(buf, "pseudo-locksetup") &&
> > -	     mode == RDT_MODE_PSEUDO_LOCKSETUP) ||
> > -	    (!strcmp(buf, "pseudo-locked") && mode == RDT_MODE_PSEUDO_LOCKED))
> > +	user_m = sysfs_match_string(rdt_mode_str, buf);
> > +	if (user_m < 0) {
> > +		rdt_last_cmd_puts("Unknown or unsupported mode\n");
> > +		ret = user_m;
> > +		goto out;
> > +	}
> 
> You can do it the way
> 
> 	ret = sysfs_match_string(...);
> 	if (ret < 0) {
> 		...
> 	}
> 	user_m = ret;

...and this changes

	ret = 0;

-- 
With Best Regards,
Andy Shevchenko


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ