linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali.rohar@gmail.com>
To: dmitry.torokhov@gmail.com
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	andreyknvl@google.com, kcc@google.com, glider@google.com,
	ktsan@googlegroups.com, Dmitry Vyukov <dvyukov@google.com>
Subject: Re: [PATCH] input: fix data race __ps2_command
Date: Fri, 25 Sep 2015 13:38:11 +0200	[thread overview]
Message-ID: <20150925113811.GG27119@pali> (raw)
In-Reply-To: <1441634675-114118-1-git-send-email-dvyukov@google.com>

On Monday 07 September 2015 16:04:35 Dmitry Vyukov wrote:
> The data race happens on ps2dev->cmdcnt and ps2dev->cmdbuf contents.
> __ps2_command reads that data concurrently with the interrupt handler.
> As the result, for example, if a response arrives just after the
> timeout, __ps2_command can copy out garbage from ps2dev->cmdbuf
> but then see that ps2dev->cmdcnt is 0 and return success.
> 
> Stop the interrupt handler with serio_pause_rx() before
> reading the results.
> 
> The data race was found with KernelThreadSanitizer (KTSAN).
> 
> Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
> ---
>  drivers/input/serio/libps2.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/input/serio/libps2.c b/drivers/input/serio/libps2.c
> index 7551699..8f93336 100644
> --- a/drivers/input/serio/libps2.c
> +++ b/drivers/input/serio/libps2.c
> @@ -234,17 +234,19 @@ int __ps2_command(struct ps2dev *ps2dev, unsigned char *param, int command)
>  				   !(ps2dev->flags & PS2_FLAG_CMD), timeout);
>  	}
>  
> +	serio_pause_rx(ps2dev->serio);
>  	if (param)
>  		for (i = 0; i < receive; i++)
>  			param[i] = ps2dev->cmdbuf[(receive - 1) - i];
>  
>  	if (ps2dev->cmdcnt && (command != PS2_CMD_RESET_BAT || ps2dev->cmdcnt != 1))
> -		goto out;
> -
> +		goto out_paused;
>  	rc = 0;
> +	goto out_paused;
>  
>   out:
>  	serio_pause_rx(ps2dev->serio);
> +out_paused:
>  	ps2dev->flags = 0;
>  	serio_continue_rx(ps2dev->serio);
>  

Hi! Was this patch queued? Or is there any problem with it? Because I
did not see any response for more weeks on any mailing list.

-- 
Pali Rohár
pali.rohar@gmail.com
--
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

      reply	other threads:[~2015-09-25 11:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-07 14:04 [PATCH] input: fix data race __ps2_command Dmitry Vyukov
2015-09-25 11:38 ` Pali Rohár [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150925113811.GG27119@pali \
    --to=pali.rohar@gmail.com \
    --cc=andreyknvl@google.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=dvyukov@google.com \
    --cc=glider@google.com \
    --cc=kcc@google.com \
    --cc=ktsan@googlegroups.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).