From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D83DAC4363D for ; Mon, 5 Oct 2020 15:34:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9299720637 for ; Mon, 5 Oct 2020 15:34:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601912098; bh=mF2qM+6mrTEqba8z30D+KHTocD0MO7WUZFPMHbfyAHg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=eBs0koQtfp5T4G049UsaSNB1fN8MP2tGYzuFQbkJXciVG49QLpIhAMpKW7aivszyK WLerie8UG/bWP514gJFgdLQt0Z9XFPS21o/ai6gsoVI9GX6Z49giW+X12XmHPIRD47 7gNdj7ZhSyiLAztwYgQko/XwjUPBVqFsRL+y9858= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728334AbgJEPe5 (ORCPT ); Mon, 5 Oct 2020 11:34:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:35490 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727844AbgJEPem (ORCPT ); Mon, 5 Oct 2020 11:34:42 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 56443207BC; Mon, 5 Oct 2020 15:34:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601912081; bh=mF2qM+6mrTEqba8z30D+KHTocD0MO7WUZFPMHbfyAHg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=eKd5HdT+CahXqJNJmbyW0ZVxWv35HGrt0Htw3b9urf1y2lKSM+FprzeHoBaLF4xul YAQK3bIf0MVlrh7Uo9Dh2VXoq/cyPHVc2U4nDrfZVaTxhphgBeNAZVj5WfwJhUA9ib 5SOkFhrFWYcqG6Xbq5aJ/kntyowaaQNeQqxiU9To= Date: Mon, 5 Oct 2020 17:28:40 +0200 From: Greg Kroah-Hartman To: Alan Stern Cc: Andrey Konovalov , Valentina Manea , Shuah Khan , USB list , LKML , Dmitry Vyukov , Nazime Hande Harputluoglu , syzkaller Subject: Re: Is usb_hcd_giveback_urb() allowed in task context? Message-ID: <20201005152840.GA2372768@kroah.com> References: <20201005152218.GF376584@rowland.harvard.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201005152218.GF376584@rowland.harvard.edu> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 05, 2020 at 11:22:18AM -0400, Alan Stern wrote: > On Mon, Oct 05, 2020 at 05:08:11PM +0200, Andrey Konovalov wrote: > > Dear USB and USB/IP maintainers, > > > > While fuzzing the USB/IP stack with syzkaller we've stumbled upon an issue. > > > > Currently kcov (the subsystem that is used for coverage collection) > > USB-related callbacks assume that usb_hcd_giveback_urb() can only be > > called from interrupt context, as indicated by the comment before the > > function definition. > > The primary reason for this restriction (as far as I'm aware) is because > the routine uses spin_lock/spin_unlock rather than the > _irqsave/_irqrestore variants. There's also a small efficiency issue: > In the vast majority of cases involving real host controllers, the > routine _will_ be called in interrupt context. So we optimized for that > case. > > > In the USB/IP code, however, it's called from the > > task context (see the stack trace below). > > > > Is this something that is allowed and we need to fix kcov? Or is this > > a bug in USB/IP? > > It's a bug in USB/IP. Interrupts should be disabled when it calls > usb_hcd_giveback_urb(). But that's not always the case when we have host controllers running with threaded interrupts, right? Or do they still disable interrupts? thanks, greg k-h