Linux Input/HID development
 help / color / mirror / Atom feed
From: Jiri Kosina <jikos@kernel.org>
To: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Cc: Gary King <gary.king@oculus.com>, linux-input@vger.kernel.org
Subject: Re: [PATCH] hidraw: fix list->buffer race condition
Date: Fri, 7 Oct 2016 10:43:55 +0200 (CEST)	[thread overview]
Message-ID: <alpine.LNX.2.00.1610071043080.31629@cbobk.fhfr.pm> (raw)
In-Reply-To: <20161005075329.GZ19261@mail.corp.redhat.com>

On Wed, 5 Oct 2016, Benjamin Tissoires wrote:

> > @@ -98,7 +99,9 @@ static ssize_t hidraw_read(struct file *file, char __user *buffer, size_t count,
> >  
> >  		kfree(list->buffer[list->tail].value);
> >  		list->buffer[list->tail].value = NULL;
> > +		smp_wmb();
> >  		list->tail = (list->tail + 1) & (HIDRAW_BUFFER_SIZE - 1);
> > +		smp_wmb();
> 
> How does these barriers be needed? To me, list->tail gets accessed just
> before, so I doubt the compiler would decide to reorder the code without
> changing the semantic.

These are CPU barriers, not compiler barriers.

(that's just a clarification, it doesn't imply in any way that I'd think 
the barriers are correct :) ).

Thanks,

-- 
Jiri Kosina
SUSE Labs


  reply	other threads:[~2016-10-07  8:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-05  0:44 [PATCH] hidraw: fix list->buffer race condition Gary King
2016-10-05  7:53 ` Benjamin Tissoires
2016-10-07  8:43   ` Jiri Kosina [this message]
2016-10-07  8:43 ` Jiri Kosina
2016-10-07 17:30   ` Gary King
2016-10-10  8:36     ` Jiri Kosina
2016-10-11  3:12       ` Dmitry Torokhov
2016-10-14  1:29       ` Gary King

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=alpine.LNX.2.00.1610071043080.31629@cbobk.fhfr.pm \
    --to=jikos@kernel.org \
    --cc=benjamin.tissoires@redhat.com \
    --cc=gary.king@oculus.com \
    --cc=linux-input@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