linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] platform/chrome: Fix off-by-one error in wilco_ec/debugfs.c
@ 2019-02-20 21:58 Nick Crews
  2019-02-20 22:06 ` Enric Balletbo i Serra
  0 siblings, 1 reply; 6+ messages in thread
From: Nick Crews @ 2019-02-20 21:58 UTC (permalink / raw)
  To: bleung, enric.balletbo
  Cc: linux-kernel, kernel-janitors, dan.carpenter, dlaurie, ncrews

Before, in debugfs.c it was possible to supply only the message type,
and not supply any other arguments when sending raw commands. However,
this is never used by the EC, and it led to an underflow error. Now,
just don't allow too short of a command, we will never need
that anyways.

Fixes: 46c7fd06f8c9 ("platform/chrome: wilco_ec: Add support for raw commands in debugfs")
Signed-off-by: Nick Crews <ncrews@chromium.org>
---
 drivers/platform/chrome/wilco_ec/debugfs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/platform/chrome/wilco_ec/debugfs.c b/drivers/platform/chrome/wilco_ec/debugfs.c
index 46ff3b6c46c7..c090db2cd5be 100644
--- a/drivers/platform/chrome/wilco_ec/debugfs.c
+++ b/drivers/platform/chrome/wilco_ec/debugfs.c
@@ -136,8 +136,8 @@ static ssize_t raw_write(struct file *file, const char __user *user_buf,
 	ret = parse_hex_sentence(buf, kcount, request_data, TYPE_AND_DATA_SIZE);
 	if (ret < 0)
 		return ret;
-	/* Need at least two bytes for message type */
-	if (ret < 2)
+	/* Need at least two bytes for message type and one for command */
+	if (ret < 3)
 		return -EINVAL;
 
 	/* Clear response data buffer */
@@ -145,7 +145,7 @@ static ssize_t raw_write(struct file *file, const char __user *user_buf,
 
 	msg.type = request_data[0] << 8 | request_data[1];
 	msg.flags = WILCO_EC_FLAG_RAW;
-	msg.command = ret > 2 ? request_data[2] : 0;
+	msg.command = request_data[2];
 	msg.request_data = ret > 3 ? request_data + 3 : 0;
 	msg.request_size = ret - 3;
 	msg.response_data = debug_info->raw_data;

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH -next] platform/chrome: Fix off-by-one error in wilco_ec/debugfs.c
  2019-02-20 21:58 [PATCH -next] platform/chrome: Fix off-by-one error in wilco_ec/debugfs.c Nick Crews
@ 2019-02-20 22:06 ` Enric Balletbo i Serra
  2019-02-20 22:15   ` Nick Crews
  0 siblings, 1 reply; 6+ messages in thread
From: Enric Balletbo i Serra @ 2019-02-20 22:06 UTC (permalink / raw)
  To: Nick Crews, bleung; +Cc: linux-kernel, kernel-janitors, dan.carpenter, dlaurie

Hi Nick,

Thanks for the patch.

On 20/2/19 22:58, Nick Crews wrote:
> Before, in debugfs.c it was possible to supply only the message type,
> and not supply any other arguments when sending raw commands. However,
> this is never used by the EC, and it led to an underflow error. Now,
> just don't allow too short of a command, we will never need
> that anyways.
> 
> Fixes: 46c7fd06f8c9 ("platform/chrome: wilco_ec: Add support for raw commands in debugfs")

As this is -next material I'd like to squash the fix if you don't mind.

-- Enric

> Signed-off-by: Nick Crews <ncrews@chromium.org>
> ---
>  drivers/platform/chrome/wilco_ec/debugfs.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/platform/chrome/wilco_ec/debugfs.c b/drivers/platform/chrome/wilco_ec/debugfs.c
> index 46ff3b6c46c7..c090db2cd5be 100644
> --- a/drivers/platform/chrome/wilco_ec/debugfs.c
> +++ b/drivers/platform/chrome/wilco_ec/debugfs.c
> @@ -136,8 +136,8 @@ static ssize_t raw_write(struct file *file, const char __user *user_buf,
>  	ret = parse_hex_sentence(buf, kcount, request_data, TYPE_AND_DATA_SIZE);
>  	if (ret < 0)
>  		return ret;
> -	/* Need at least two bytes for message type */
> -	if (ret < 2)
> +	/* Need at least two bytes for message type and one for command */
> +	if (ret < 3)
>  		return -EINVAL;
>  
>  	/* Clear response data buffer */
> @@ -145,7 +145,7 @@ static ssize_t raw_write(struct file *file, const char __user *user_buf,
>  
>  	msg.type = request_data[0] << 8 | request_data[1];
>  	msg.flags = WILCO_EC_FLAG_RAW;
> -	msg.command = ret > 2 ? request_data[2] : 0;
> +	msg.command = request_data[2];
>  	msg.request_data = ret > 3 ? request_data + 3 : 0;
>  	msg.request_size = ret - 3;
>  	msg.response_data = debug_info->raw_data;
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH -next] platform/chrome: Fix off-by-one error in wilco_ec/debugfs.c
  2019-02-20 22:06 ` Enric Balletbo i Serra
@ 2019-02-20 22:15   ` Nick Crews
  2019-02-21  7:58     ` Enric Balletbo i Serra
  2019-02-21 18:31     ` Dan Carpenter
  0 siblings, 2 replies; 6+ messages in thread
From: Nick Crews @ 2019-02-20 22:15 UTC (permalink / raw)
  To: Enric Balletbo i Serra
  Cc: Benson Leung, linux-kernel, kernel-janitors, Dan Carpenter,
	Duncan Laurie

Hi Enric,

On Wed, Feb 20, 2019 at 3:06 PM Enric Balletbo i Serra
<enric.balletbo@collabora.com> wrote:
>
> Hi Nick,
>
> Thanks for the patch.
>
> On 20/2/19 22:58, Nick Crews wrote:
> > Before, in debugfs.c it was possible to supply only the message type,
> > and not supply any other arguments when sending raw commands. However,
> > this is never used by the EC, and it led to an underflow error. Now,
> > just don't allow too short of a command, we will never need
> > that anyways.
> >
> > Fixes: 46c7fd06f8c9 ("platform/chrome: wilco_ec: Add support for raw commands in debugfs")
>
> As this is -next material I'd like to squash the fix if you don't mind.


Please do. Fixing something after it's already in the tree was a new
process for me,
so I tried to copy other people's examples. Please let me know
if there's anything else I should do something different next time.

Nick

>
> -- Enric
>
> > Signed-off-by: Nick Crews <ncrews@chromium.org>
> > ---
> >  drivers/platform/chrome/wilco_ec/debugfs.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/platform/chrome/wilco_ec/debugfs.c b/drivers/platform/chrome/wilco_ec/debugfs.c
> > index 46ff3b6c46c7..c090db2cd5be 100644
> > --- a/drivers/platform/chrome/wilco_ec/debugfs.c
> > +++ b/drivers/platform/chrome/wilco_ec/debugfs.c
> > @@ -136,8 +136,8 @@ static ssize_t raw_write(struct file *file, const char __user *user_buf,
> >       ret = parse_hex_sentence(buf, kcount, request_data, TYPE_AND_DATA_SIZE);
> >       if (ret < 0)
> >               return ret;
> > -     /* Need at least two bytes for message type */
> > -     if (ret < 2)
> > +     /* Need at least two bytes for message type and one for command */
> > +     if (ret < 3)
> >               return -EINVAL;
> >
> >       /* Clear response data buffer */
> > @@ -145,7 +145,7 @@ static ssize_t raw_write(struct file *file, const char __user *user_buf,
> >
> >       msg.type = request_data[0] << 8 | request_data[1];
> >       msg.flags = WILCO_EC_FLAG_RAW;
> > -     msg.command = ret > 2 ? request_data[2] : 0;
> > +     msg.command = request_data[2];
> >       msg.request_data = ret > 3 ? request_data + 3 : 0;
> >       msg.request_size = ret - 3;
> >       msg.response_data = debug_info->raw_data;
> >

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH -next] platform/chrome: Fix off-by-one error in wilco_ec/debugfs.c
  2019-02-20 22:15   ` Nick Crews
@ 2019-02-21  7:58     ` Enric Balletbo i Serra
  2019-02-21 18:31     ` Dan Carpenter
  1 sibling, 0 replies; 6+ messages in thread
From: Enric Balletbo i Serra @ 2019-02-21  7:58 UTC (permalink / raw)
  To: Nick Crews
  Cc: Benson Leung, linux-kernel, kernel-janitors, Dan Carpenter,
	Duncan Laurie

Hi,

On 20/2/19 23:15, Nick Crews wrote:
> Hi Enric,
> 
> On Wed, Feb 20, 2019 at 3:06 PM Enric Balletbo i Serra
> <enric.balletbo@collabora.com> wrote:
>>
>> Hi Nick,
>>
>> Thanks for the patch.
>>
>> On 20/2/19 22:58, Nick Crews wrote:
>>> Before, in debugfs.c it was possible to supply only the message type,
>>> and not supply any other arguments when sending raw commands. However,
>>> this is never used by the EC, and it led to an underflow error. Now,
>>> just don't allow too short of a command, we will never need
>>> that anyways.
>>>
>>> Fixes: 46c7fd06f8c9 ("platform/chrome: wilco_ec: Add support for raw commands in debugfs")
>>
>> As this is -next material I'd like to squash the fix if you don't mind.
> 
> 
> Please do. Fixing something after it's already in the tree was a new
> process for me,
> so I tried to copy other people's examples. Please let me know
> if there's anything else I should do something different next time.
> 

Squashed and pushed for 5.1

Thanks,
 Enric


> Nick
> 
>>
>> -- Enric
>>
>>> Signed-off-by: Nick Crews <ncrews@chromium.org>
>>> ---
>>>  drivers/platform/chrome/wilco_ec/debugfs.c | 6 +++---
>>>  1 file changed, 3 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/platform/chrome/wilco_ec/debugfs.c b/drivers/platform/chrome/wilco_ec/debugfs.c
>>> index 46ff3b6c46c7..c090db2cd5be 100644
>>> --- a/drivers/platform/chrome/wilco_ec/debugfs.c
>>> +++ b/drivers/platform/chrome/wilco_ec/debugfs.c
>>> @@ -136,8 +136,8 @@ static ssize_t raw_write(struct file *file, const char __user *user_buf,
>>>       ret = parse_hex_sentence(buf, kcount, request_data, TYPE_AND_DATA_SIZE);
>>>       if (ret < 0)
>>>               return ret;
>>> -     /* Need at least two bytes for message type */
>>> -     if (ret < 2)
>>> +     /* Need at least two bytes for message type and one for command */
>>> +     if (ret < 3)
>>>               return -EINVAL;
>>>
>>>       /* Clear response data buffer */
>>> @@ -145,7 +145,7 @@ static ssize_t raw_write(struct file *file, const char __user *user_buf,
>>>
>>>       msg.type = request_data[0] << 8 | request_data[1];
>>>       msg.flags = WILCO_EC_FLAG_RAW;
>>> -     msg.command = ret > 2 ? request_data[2] : 0;
>>> +     msg.command = request_data[2];
>>>       msg.request_data = ret > 3 ? request_data + 3 : 0;
>>>       msg.request_size = ret - 3;
>>>       msg.response_data = debug_info->raw_data;
>>>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH -next] platform/chrome: Fix off-by-one error in wilco_ec/debugfs.c
  2019-02-20 22:15   ` Nick Crews
  2019-02-21  7:58     ` Enric Balletbo i Serra
@ 2019-02-21 18:31     ` Dan Carpenter
  2019-02-21 19:09       ` Nick Crews
  1 sibling, 1 reply; 6+ messages in thread
From: Dan Carpenter @ 2019-02-21 18:31 UTC (permalink / raw)
  To: Nick Crews
  Cc: Enric Balletbo i Serra, Benson Leung, linux-kernel,
	kernel-janitors, Duncan Laurie

On Wed, Feb 20, 2019 at 03:15:18PM -0700, Nick Crews wrote:
> Fixing something after it's already in the tree was a new
> process for me, so I tried to copy other people's examples. Please
> let me know if there's anything else I should do something different
> next time.

I seldom mention how much I like Reported-by tags because it makes me
seem needy...  Also in this case it doesn't matter because it's going to
get folded into the original patch so it's going to be lost anyway.  But
since you're asking process questions, the Reported-by cookie is nice.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH -next] platform/chrome: Fix off-by-one error in wilco_ec/debugfs.c
  2019-02-21 18:31     ` Dan Carpenter
@ 2019-02-21 19:09       ` Nick Crews
  0 siblings, 0 replies; 6+ messages in thread
From: Nick Crews @ 2019-02-21 19:09 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Enric Balletbo i Serra, Benson Leung, linux-kernel,
	kernel-janitors, Duncan Laurie

Thanks Dan, noted.

On Thu, Feb 21, 2019 at 11:31 AM Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> On Wed, Feb 20, 2019 at 03:15:18PM -0700, Nick Crews wrote:
> > Fixing something after it's already in the tree was a new
> > process for me, so I tried to copy other people's examples. Please
> > let me know if there's anything else I should do something different
> > next time.
>
> I seldom mention how much I like Reported-by tags because it makes me
> seem needy...  Also in this case it doesn't matter because it's going to
> get folded into the original patch so it's going to be lost anyway.  But
> since you're asking process questions, the Reported-by cookie is nice.
>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> regards,
> dan carpenter
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-02-21 19:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-20 21:58 [PATCH -next] platform/chrome: Fix off-by-one error in wilco_ec/debugfs.c Nick Crews
2019-02-20 22:06 ` Enric Balletbo i Serra
2019-02-20 22:15   ` Nick Crews
2019-02-21  7:58     ` Enric Balletbo i Serra
2019-02-21 18:31     ` Dan Carpenter
2019-02-21 19:09       ` Nick Crews

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).