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=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 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 8EF31C4363A for ; Mon, 5 Oct 2020 15:22:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3C7C7207BC for ; Mon, 5 Oct 2020 15:22:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726847AbgJEPWU (ORCPT ); Mon, 5 Oct 2020 11:22:20 -0400 Received: from netrider.rowland.org ([192.131.102.5]:36983 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1726727AbgJEPWT (ORCPT ); Mon, 5 Oct 2020 11:22:19 -0400 Received: (qmail 380154 invoked by uid 1000); 5 Oct 2020 11:22:18 -0400 Date: Mon, 5 Oct 2020 11:22:18 -0400 From: Alan Stern To: Andrey Konovalov Cc: Valentina Manea , Shuah Khan , Greg Kroah-Hartman , USB list , LKML , Dmitry Vyukov , Nazime Hande Harputluoglu , syzkaller Subject: Re: Is usb_hcd_giveback_urb() allowed in task context? Message-ID: <20201005152218.GF376584@rowland.harvard.edu> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(). Alan Stern