public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jiri Slaby <jslaby@suse.cz>
To: Takashi Iwai <tiwai@suse.de>
Cc: johan.hedberg@gmail.com, linux-kernel@vger.kernel.org,
	Marcel Holtmann <marcel@holtmann.org>,
	Gustavo Padovan <gustavo@padovan.org>,
	linux-bluetooth@vger.kernel.org,
	Dmitry Vyukov <dvyukov@google.com>,
	"stable 3 . 13+" <stable@vger.kernel.org>
Subject: Re: [PATCH v2] Bluetooth: vhci, fix open_timeout vs. hdev race
Date: Tue, 22 Mar 2016 16:52:12 +0100	[thread overview]
Message-ID: <56F16A2C.6080303@suse.cz> (raw)
In-Reply-To: <s5hio0e4np7.wl-tiwai@suse.de>

On 03/22/2016, 03:00 PM, Takashi Iwai wrote:
> int main()
> {
> 	int i;
> 	long fd;
>         pthread_t th[32];
> 
> 	fd = open("/dev/vhci", O_RDWR);
> 	if (fd < 0)
> 		err(1, "open");
>         for (i = 0; i < 32; i++)
> 		pthread_create(&th[i], 0, test, (void*)fd);
>         for (i = 0; i < 32; i++)
> 		pthread_join(th[i], NULL);
> 	return 0;
> }
> ================================================================
> 
> For fixing these, we need a proper mutex protection.  A patch like
> below seems helping, at least for the test case above.

I didn't fix this and kept it simple as I believe concurrent accesses
from a single opener are not allowed by design. But if we want to
support this, we of course need locking like this.

Anyway, I would appreciate any input from the BT fellows. There are more
races like this, apparently.

thanks,
-- 
js
suse labs

  reply	other threads:[~2016-03-22 15:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-19  9:47 [PATCH] Bluetooth: vhci, fix open_timeout vs. hdev race Jiri Slaby
2016-03-19 10:05 ` [PATCH v2] " Jiri Slaby
2016-03-22 14:00   ` Takashi Iwai
2016-03-22 15:52     ` Jiri Slaby [this message]
2016-04-08 17:18   ` Marcel Holtmann

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=56F16A2C.6080303@suse.cz \
    --to=jslaby@suse.cz \
    --cc=dvyukov@google.com \
    --cc=gustavo@padovan.org \
    --cc=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcel@holtmann.org \
    --cc=stable@vger.kernel.org \
    --cc=tiwai@suse.de \
    /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