From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755548AbcCVPwY (ORCPT ); Tue, 22 Mar 2016 11:52:24 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:35695 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752245AbcCVPwQ (ORCPT ); Tue, 22 Mar 2016 11:52:16 -0400 Subject: Re: [PATCH v2] Bluetooth: vhci, fix open_timeout vs. hdev race To: Takashi Iwai References: <1458380852-7533-1-git-send-email-jslaby@suse.cz> <1458381918-7886-1-git-send-email-jslaby@suse.cz> Cc: johan.hedberg@gmail.com, linux-kernel@vger.kernel.org, Marcel Holtmann , Gustavo Padovan , linux-bluetooth@vger.kernel.org, Dmitry Vyukov , "stable 3 . 13+" From: Jiri Slaby Message-ID: <56F16A2C.6080303@suse.cz> Date: Tue, 22 Mar 2016 16:52:12 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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