Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753410AbbETOso (ORCPT ); Wed, 20 May 2015 10:48:44 -0400 Received: from collab.rosalab.ru ([195.19.76.181]:60052 "EHLO collab.rosalab.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751609AbbETOsn (ORCPT ); Wed, 20 May 2015 10:48:43 -0400 Message-ID: <555C9EC9.40303@rosalab.ru> Date: Wed, 20 May 2015 17:48:41 +0300 From: Eugene Shatokhin Organization: ROSA User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Laurent Pinchart CC: Mauro Carvalho Chehab , LKML Subject: uvcvideo: Race on dev->state between uvc_disconnect() and uvc_v4l2_open() Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1258 Lines: 38 Hi, There is a race in uvcvideo module between uvc_disconnect() and uvc_v4l2_open() on dev->state. Checked and reproduced that with kernel 4.1-rc1. drivers/media/usb/uvc/uvc_driver.c, uvc_disconnect(): dev->state |= UVC_DEV_DISCONNECTED; drivers/media/usb/uvc/uvc_v4l2.c, uvc_v4l2_open(): if (stream->dev->state & UVC_DEV_DISCONNECTED) return -ENODEV; I checked that the race does happen by introducing a delay in uvc_disconnect() right before that assignment and armed a hardware breakpoint to detect the access to stream->dev->state from uvc_v4l2_open(). When I disconnected the webcam while Google Hangout was running, the hardware breakpoint triggered several times for that read in uvc_v4l2_open (uvc_v4l2.c:484). uvc_v4l2_open() was called in the context of GoogleTalkPlugin processes. Not sure if the race is intentional but I guess, better to report it anyway. Nothing has crashed during my (brief) testing yet, but still. Regards, Eugene -- Eugene Shatokhin, ROSA www.rosalab.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/