Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3385657pxk; Mon, 5 Oct 2020 08:24:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPod8kxdlelD/R1xqL8A7pecb44zOIR4BIJgQf+CYkrhzVIZL+NGH/llZhg2salRVQC0WO X-Received: by 2002:a17:907:7292:: with SMTP id dt18mr203665ejc.265.1601911473597; Mon, 05 Oct 2020 08:24:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601911473; cv=none; d=google.com; s=arc-20160816; b=dUjq5S1c40QasORtBW5TQMvWww6k0Is0Q/IcVgZu/THSvo1Jev1KxG1KrIk/cCmcxs oKjvrCSorjOCQAZq4ob+pSnOdj4n4SF2nWWenP6JvYJzr+8dxfjx3qWt73APXTBOi5f8 +O9qE8xMxNE2ZmewcP7xoFD2+BFQIVWMrTc9HJM//KJ03Q4EOecD9fRKBLDwieRKtXjA P25xQc6C9kRQcjK2ssonNorhI0oDNhUXaOsNznXZ1hj6vyD9kL50nl9RCg+sbGhSui2e HC8PzncVOOrs0u6lFUunVQxnTN2QGrSLxIWbgwKm4iErDIHShRYdLPqErPLzpo7QoYnA dzOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=p6rBwXCQD7pzHE3fFURXhtGI9yod0jdnugFLoF6xXQk=; b=JU4fG6iLWMf3FQLtunJhs/NWjzQ7k1FGiDwCdaZ8rl2izsaTJBgV7GsRcyt4T34FP7 4VG3t+R0+KaDNDUNcXSg8imiStsRgz5DQed1YeKvv6Y/OPpgMM6cWdifD2vhpC8o5frI XB+a00opOVbJhFRvDYjeDJlTv7VcE5YOnUSKaWuEtRUf/CTQZBkGzL8JmQgwneRANjOY namxg/KyrAouqWM8+ewDZcnFn5k17x9voDDmGeUJiFnYITHaC3YHhIfqTGtEdTHiXv0c +IVlOTrTrp6SCvm7aFBXmSiwUW6Bik6JdPchgGRo8cT0q5qdC5TaEvpSYK1IJM5sauqh R/GQ== 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 16si7277633ejx.486.2020.10.05.08.24.10; Mon, 05 Oct 2020 08:24:33 -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 S1726429AbgJEPWU (ORCPT + 99 others); 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