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]
Date: Thu, 13 Jun 2024 21:34:44 +0300
From: Dan Carpenter <dan.carpenter@...aro.org>
To: Ben Walsh <ben@...nut.com>
Cc: Benson Leung <bleung@...omium.org>, Tzung-Bi Shih <tzungbi@...nel.org>,
	Guenter Roeck <groeck@...omium.org>,
	chrome-platform@...ts.linux.dev, linux-kernel@...r.kernel.org,
	kernel-janitors@...r.kernel.org
Subject: Re: [PATCH] platform/chrome: cros_ec_lpc: Fix error code in
 cros_ec_lpc_mec_read_bytes()

On Thu, Jun 13, 2024 at 07:20:32PM +0100, Ben Walsh wrote:
> 
> Dan Carpenter <dan.carpenter@...aro.org> writes:
> 
> > On Thu, Jun 13, 2024 at 05:51:39PM +0100, Ben Walsh wrote:
> >> 
> >> Thanks for fixing this! Unfortunately `in_range` returns -EINVAL if
> >> length == 0 (see the definition of `fwk_ec_lpc_mec_in_range`). I'm sure
> >> this broke something in my testing, but I can't find what it was now.
> >
> > I don't think fwk_ec_lpc_mec_in_range() is upstream.  This email is the
> > only reference I can find to it on the internet.
> 
> Sorry, I mean cros_ec_lpc_mec_in_range().
> 
> >  int cros_ec_lpc_mec_in_range(unsigned int offset, unsigned int length)
> >  {
> >  	if (length == 0)
> > -		return -EINVAL;
> > +		return 0;
> >  
> >  	if (WARN_ON(mec_emi_base == 0 || mec_emi_end == 0))
> >  		return -EINVAL;
> >
> > But I don't like how subtle that is.  Probably adding a check for
> > for if (length == 0) to the  to cros_ec_lpc_mec_read_bytes() seems
> > like the best option.  I guess option 2 is the best option.
> 
> Thanks. I'll check out Tzung-Bi's suggestions as well before we decide.

Writing length 0 bytes to cros_ec_lpc_io_bytes_mec() changes the
function to basically this:

	cros_ec_lpc_mec_lock();
	/* Initialize I/O at desired address */
	cros_ec_lpc_mec_emi_write_address(offset, access);
	cros_ec_lpc_mec_unlock();

	return 0;

I was a little concerned about the cros_ec_lpc_mec_emi_write_address()
But I don't know this subsystem at all so it might be fine.

Perhaps the cleanest thing is to delete the length == 0 check in
cros_ec_lpc_mec_in_range() and add one to the start of
cros_ec_lpc_io_bytes_mec().

I think that's a good solution.

regards,
dan carpenter


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ