Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1471486ybh; Thu, 23 Jul 2020 09:39:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3RqCAnoHzw0Lcom6/zePc41V2NF+4KcBnN7UZ7n3hpfqZ2tlbSqhdqTE8WmH3uSExi/cl X-Received: by 2002:a17:906:538e:: with SMTP id g14mr5178199ejo.300.1595522365493; Thu, 23 Jul 2020 09:39:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595522365; cv=none; d=google.com; s=arc-20160816; b=ESWx2nj3gpkuuVsqsJW2VZDM6tJ3jN3GCntKjCbVovcC02bMClu52tuff6hUCA53xE Uf+g1sR2HMQ1Ph9rM1y9JXWQ2rOBXua54QBwSAZGXaR0OJLT2urwi8lDkA+Q4dnnG1NY hCzBGzZFnora8p3aUVY2Bkumys/0iJjKwtU1s8DFrIVCpbmMDyhFPa3dmKSd+v3Td7tn KlvMiijAl51IrhzSIy5/jyWOt7z6M2viOD89Fn4kFeag1k7JUGIBytlBzJbAzo7M9TDM Lp8K1fXcZI2G8wvwyTjuEbWHR1sua/tOix2yLMXNZY+PP1PQEzb+Sl3jD4dvh0MoJ4Un h6ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=igZDOFxeiOdhZzx3aleHuXn1wSgX0GaxlVbeAHZyZ/0=; b=mLEWjAuNaoEauZkR7UH0zkUmPp8eBmI1ynNh4uGJd1xXcflVZD0nM2XadLJL8z/Xb8 Si/t9TXSwsvjdWKikC8nxbFmGGhIqpPr9AuddVbGAk8flMcsHLh17ZbphuAuPX0TC8TJ i4NHpInI7m5xqEi99HKO08fNW9nwl7jTsbY5vfFMbTGRA4dgdUJy62nd/Q+ThbBiPJ4J D/nlMCVFtI62bzYL9gOw8mUZo9hCIrKmenB7n+1pe/Q2kXTW1TznPicYItXtG7DeXlpP /rPj4Iw3iy9VWdRmNqrtRkuUXI2IXac/yQh+hRobeg1OsuxAXuQwonwiiK3NVgMLUKce N4hQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v21si2188829edw.286.2020.07.23.09.39.02; Thu, 23 Jul 2020 09:39:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729838AbgGWQih (ORCPT + 99 others); Thu, 23 Jul 2020 12:38:37 -0400 Received: from netrider.rowland.org ([192.131.102.5]:58361 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1727044AbgGWQig (ORCPT ); Thu, 23 Jul 2020 12:38:36 -0400 Received: (qmail 1358681 invoked by uid 1000); 23 Jul 2020 12:38:35 -0400 Date: Thu, 23 Jul 2020 12:38:35 -0400 From: Alan Stern To: Alex Williamson Cc: "Weitao Wang\(BJ-RD\)" , Greg KH , WeitaoWang-oc , "mathias.nyman@linux.intel.com" , "ulf.hansson@linaro.org" , "vkoul@kernel.org" , "hslester96@gmail.com" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "Carsten_Schmid@mentor.com" , "efremov@linux.com" , "Tony W. Wang\(XA-RD\)" , "Cobe Chen\(BJ-RD\)" , "Tim Guo\(BJ-RD\)" , "wwt8723@163.com" Subject: Re: [PATCH] USB:Fix kernel NULL pointer when unbind UHCI form vfio-pci Message-ID: <20200723163835.GA1357775@rowland.harvard.edu> References: <1595419068-4812-1-git-send-email-WeitaoWang-oc@zhaoxin.com> <20200722124414.GA3153105@kroah.com> <20200722145913.GB1310843@rowland.harvard.edu> <1bf449377e3448bc9c8bc7b64d7b7990@zhaoxin.com> <20200722221817.542971a2@x1.home> <20200723153821.GC1352396@rowland.harvard.edu> <20200723101735.3222c289@w520.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200723101735.3222c289@w520.home> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 23, 2020 at 10:17:35AM -0600, Alex Williamson wrote: > The IOMMU grouping restriction does solve the hardware issue, so long > as one driver doesn't blindly assume the driver private data for > another device and modify it. Correction: The IOMMU grouping restriction solves the hardware issue for vfio-pci. It won't necessarily help if some other driver comes along and wants to bind to this hardware. > I do agree that your solution would > work, requiring all devices are unbound before any can be bound, but it > also seems difficult to manage. The issue is largely unique to USB > AFAIK. On the other hand, drivers coordinating with each other to > register their _private_ data as share-able within a set of drivers > seems like a much more direct and explicit interaction between the > drivers. Thanks, Yes, that makes sense. But it would have to be implemented in the driver core, not in particular subsystems like USB or PCI. And it might be seen as overkill, given that only UHCI/OHCI/EHCI devices require this sort of sharing AFAIK. Also, when you think about it, what form would such coordination among drivers take? From your description, it sounds like the drivers would agree to avoid accessing each other's private data if the proper registration wasn't in place. On the other hand, a stronger and perhaps more robust approach would be to enforce the condition that non-cooperating drivers are never bound to devices in the same group at the same time. That's basically what I'm proposing here -- the question is whether the enforcement should be instituted in the kernel or should merely be part of a standard protocol followed by userspace drivers. Given that it's currently needed in only one place, it seems reasonable to leave this as a "gentlemen's agreement" in userspace for the time being instead of adding it to the kernel. Alan Stern