* [PATCH] Input: wacom_w8001 - Ignore bogus idx values in interrupt
@ 2016-05-23 1:42 Chris J Arges
2016-05-23 5:21 ` Ping Cheng
0 siblings, 1 reply; 4+ messages in thread
From: Chris J Arges @ 2016-05-23 1:42 UTC (permalink / raw)
To: linux-input
Cc: Chris J Arges, Dmitry Torokhov, Peter Hutterer,
Benjamin Tissoires, Ping Cheng, linux-kernel
I've noticed crashes when using my x60t using a coreboot bios. When using
the pen I can produce a crash simply by tapping a few times. This
generates an event which has an idx of 0xc. This in turn crashes the
machine because the array access is greater than W8001_MAX_LENGTH. This
patch checks for bogus values and filters them in order to prevent crashes.
Signed-off-by: Chris J Arges <christopherarges@gmail.com>
---
drivers/input/touchscreen/wacom_w8001.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/input/touchscreen/wacom_w8001.c b/drivers/input/touchscreen/wacom_w8001.c
index bab3c6a..c858200 100644
--- a/drivers/input/touchscreen/wacom_w8001.c
+++ b/drivers/input/touchscreen/wacom_w8001.c
@@ -283,6 +283,15 @@ static irqreturn_t w8001_interrupt(struct serio *serio,
unsigned char tmp;
w8001->data[w8001->idx] = data;
+
+ /* ignore bogus idx values */
+ if (w8001->idx >= W8001_MAX_LENGTH) {
+ pr_info("w8001: ignored interrupt: data 0x%02x idx %d\n", data,
+ w8001->idx);
+ w8001->idx = 0;
+ return IRQ_HANDLED;
+ }
+
switch (w8001->idx++) {
case 0:
if ((data & W8001_LEAD_MASK) != W8001_LEAD_BYTE) {
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Input: wacom_w8001 - Ignore bogus idx values in interrupt
2016-05-23 1:42 [PATCH] Input: wacom_w8001 - Ignore bogus idx values in interrupt Chris J Arges
@ 2016-05-23 5:21 ` Ping Cheng
2016-05-23 16:52 ` Dmitry Torokhov
0 siblings, 1 reply; 4+ messages in thread
From: Ping Cheng @ 2016-05-23 5:21 UTC (permalink / raw)
To: Chris J Arges
Cc: linux-input, Dmitry Torokhov, Peter Hutterer, Benjamin Tissoires,
Ping Cheng, linux-kernel@vger.kernel.org
Hi Chris,
On Sun, May 22, 2016 at 6:42 PM, Chris J Arges
<christopherarges@gmail.com> wrote:
> I've noticed crashes when using my x60t using a coreboot bios. When using
> the pen I can produce a crash simply by tapping a few times. This
> generates an event which has an idx of 0xc. This in turn crashes the
> machine because the array access is greater than W8001_MAX_LENGTH. This
> patch checks for bogus values and filters them in order to prevent crashes.
Thank you for submitting a patch in addition to reporting the issue.
> Signed-off-by: Chris J Arges <christopherarges@gmail.com>
> ---
> drivers/input/touchscreen/wacom_w8001.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/drivers/input/touchscreen/wacom_w8001.c b/drivers/input/touchscreen/wacom_w8001.c
> index bab3c6a..c858200 100644
> --- a/drivers/input/touchscreen/wacom_w8001.c
> +++ b/drivers/input/touchscreen/wacom_w8001.c
> @@ -283,6 +283,15 @@ static irqreturn_t w8001_interrupt(struct serio *serio,
> unsigned char tmp;
>
> w8001->data[w8001->idx] = data;
> +
> + /* ignore bogus idx values */
> + if (w8001->idx >= W8001_MAX_LENGTH) {
> + pr_info("w8001: ignored interrupt: data 0x%02x idx %d\n", data,
> + w8001->idx);
> + w8001->idx = 0;
> + return IRQ_HANDLED;
> + }
> +
I don't have an x60t system to test with. I wonder if your system
supports two finger touch or not. We at least have a bug in the code
since W8001_MAX_LENGTH should be 13 instead of 11. How come no one had
encountered that issue before?
I'm going to email a patch to the list. Please test it and let us know
your result. Maybe we still need your patch if your device doesn't
support two finger touch or the idx=0xc can't be fixed by
W8001_MAX_LENGTH=13.
Thanks,
Ping
> switch (w8001->idx++) {
> case 0:
> if ((data & W8001_LEAD_MASK) != W8001_LEAD_BYTE) {
> --
> 2.7.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-input" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Input: wacom_w8001 - Ignore bogus idx values in interrupt
2016-05-23 5:21 ` Ping Cheng
@ 2016-05-23 16:52 ` Dmitry Torokhov
2016-05-23 18:00 ` Ping Cheng
0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Torokhov @ 2016-05-23 16:52 UTC (permalink / raw)
To: Ping Cheng
Cc: Chris J Arges, linux-input, Peter Hutterer, Benjamin Tissoires,
Ping Cheng, linux-kernel@vger.kernel.org
On Sun, May 22, 2016 at 10:21:45PM -0700, Ping Cheng wrote:
> Hi Chris,
>
> On Sun, May 22, 2016 at 6:42 PM, Chris J Arges
> <christopherarges@gmail.com> wrote:
> > I've noticed crashes when using my x60t using a coreboot bios. When using
> > the pen I can produce a crash simply by tapping a few times. This
> > generates an event which has an idx of 0xc. This in turn crashes the
> > machine because the array access is greater than W8001_MAX_LENGTH. This
> > patch checks for bogus values and filters them in order to prevent crashes.
>
> Thank you for submitting a patch in addition to reporting the issue.
>
> > Signed-off-by: Chris J Arges <christopherarges@gmail.com>
> > ---
> > drivers/input/touchscreen/wacom_w8001.c | 9 +++++++++
> > 1 file changed, 9 insertions(+)
> >
> > diff --git a/drivers/input/touchscreen/wacom_w8001.c b/drivers/input/touchscreen/wacom_w8001.c
> > index bab3c6a..c858200 100644
> > --- a/drivers/input/touchscreen/wacom_w8001.c
> > +++ b/drivers/input/touchscreen/wacom_w8001.c
> > @@ -283,6 +283,15 @@ static irqreturn_t w8001_interrupt(struct serio *serio,
> > unsigned char tmp;
> >
> > w8001->data[w8001->idx] = data;
> > +
> > + /* ignore bogus idx values */
> > + if (w8001->idx >= W8001_MAX_LENGTH) {
> > + pr_info("w8001: ignored interrupt: data 0x%02x idx %d\n", data,
> > + w8001->idx);
> > + w8001->idx = 0;
> > + return IRQ_HANDLED;
> > + }
> > +
>
> I don't have an x60t system to test with. I wonder if your system
> supports two finger touch or not. We at least have a bug in the code
> since W8001_MAX_LENGTH should be 13 instead of 11. How come no one had
> encountered that issue before?
>
> I'm going to email a patch to the list. Please test it and let us know
> your result. Maybe we still need your patch if your device doesn't
> support two finger touch or the idx=0xc can't be fixed by
> W8001_MAX_LENGTH=13.
Just so we are clear this version of the patch is buggy as we check the
index only after [potentially] writing past the array bounds of
w8001->data[].
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Input: wacom_w8001 - Ignore bogus idx values in interrupt
2016-05-23 16:52 ` Dmitry Torokhov
@ 2016-05-23 18:00 ` Ping Cheng
0 siblings, 0 replies; 4+ messages in thread
From: Ping Cheng @ 2016-05-23 18:00 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Chris J Arges, linux-input, Peter Hutterer, Benjamin Tissoires,
Ping Cheng, linux-kernel@vger.kernel.org
On Mon, May 23, 2016 at 9:52 AM, Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
> On Sun, May 22, 2016 at 10:21:45PM -0700, Ping Cheng wrote:
>> Hi Chris,
>>
>> On Sun, May 22, 2016 at 6:42 PM, Chris J Arges
>> <christopherarges@gmail.com> wrote:
>> > I've noticed crashes when using my x60t using a coreboot bios. When using
>> > the pen I can produce a crash simply by tapping a few times. This
>> > generates an event which has an idx of 0xc. This in turn crashes the
>> > machine because the array access is greater than W8001_MAX_LENGTH. This
>> > patch checks for bogus values and filters them in order to prevent crashes.
>>
>> Thank you for submitting a patch in addition to reporting the issue.
>>
>> > Signed-off-by: Chris J Arges <christopherarges@gmail.com>
>> > ---
>> > drivers/input/touchscreen/wacom_w8001.c | 9 +++++++++
>> > 1 file changed, 9 insertions(+)
>> >
>> > diff --git a/drivers/input/touchscreen/wacom_w8001.c b/drivers/input/touchscreen/wacom_w8001.c
>> > index bab3c6a..c858200 100644
>> > --- a/drivers/input/touchscreen/wacom_w8001.c
>> > +++ b/drivers/input/touchscreen/wacom_w8001.c
>> > @@ -283,6 +283,15 @@ static irqreturn_t w8001_interrupt(struct serio *serio,
>> > unsigned char tmp;
>> >
>> > w8001->data[w8001->idx] = data;
>> > +
>> > + /* ignore bogus idx values */
>> > + if (w8001->idx >= W8001_MAX_LENGTH) {
>> > + pr_info("w8001: ignored interrupt: data 0x%02x idx %d\n", data,
>> > + w8001->idx);
>> > + w8001->idx = 0;
>> > + return IRQ_HANDLED;
>> > + }
>> > +
>>
>> I don't have an x60t system to test with. I wonder if your system
>> supports two finger touch or not. We at least have a bug in the code
>> since W8001_MAX_LENGTH should be 13 instead of 11. How come no one had
>> encountered that issue before?
>>
>> I'm going to email a patch to the list. Please test it and let us know
>> your result. Maybe we still need your patch if your device doesn't
>> support two finger touch or the idx=0xc can't be fixed by
>> W8001_MAX_LENGTH=13.
>
> Just so we are clear this version of the patch is buggy as we check the
> index only after [potentially] writing past the array bounds of
> w8001->data[].
Thanks for the heads up. I noticed that last night. Since it breaks
two-finger touch, we won't use it anyway.
My other patch is still necessary though. You'll need to change:
From: wacom <wacom@localhost.localdomain>
to
From: Ping Cheng <pingc@wacom.com>
I made it on a brand new system, which I didn't setup the environment
properly. I can update the patch if that's what you like...
Ping
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-05-23 18:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-23 1:42 [PATCH] Input: wacom_w8001 - Ignore bogus idx values in interrupt Chris J Arges
2016-05-23 5:21 ` Ping Cheng
2016-05-23 16:52 ` Dmitry Torokhov
2016-05-23 18:00 ` Ping Cheng
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).