Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5947050pxb; Mon, 14 Feb 2022 11:23:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJy9e3nKWl+EIma1bhuy9OnlxUzSGp0xEeOWqIuCIvuZ0aHGpEkNL6Ukgs3MwgdnmlD3Vxla X-Received: by 2002:a17:902:d3c6:: with SMTP id w6mr402866plb.4.1644866615395; Mon, 14 Feb 2022 11:23:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644866615; cv=none; d=google.com; s=arc-20160816; b=pSjPDeOKWFk5HO8rGjuNqYlvabnqL4TcQB1RuMOgeGHJUQPlxzLVSjoBmmBIST0i1d T6w/eDukEnUggDdhA04Bi/eyRNj9UK7mAscvB4iyHkcEg0OXIX6Jrp5m2t0MeKVIHGpk LgjRfxEGN8zUfzrjAeGfbmrdM8xVK/YN9ZNPZLVacSz5IIo1Z2LkKDCO8pYq9WZSog3S 1Sy0SAuj5aqNGUQi0hvfO4OIPT462pSF3a4qkt2ABqmMOBPGZgfUJ1h8uT/KfBbSU6bL JQe2T5u3qgW9YHn3SCpiEeLdVsG0vAf9aZKMNUg/RV5DDN0CiAsLQqYXE/yjQErzrnjl DLKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vlXFW5NSFKyJwKJigfEK8JsumGYdbiCDu5S0FxnfpkY=; b=OraalcQkNL5R0WcpeDVno89oo/+XWoHuq5ziLfkok5+Gp5vU/W9Z2WJImiVUE2l7Jh 0DxOMYZwMjJq3UT1TTX58qhI4+Z3GNCVksm/rWhGXRUYzGkbWCp7NFle3C0nM8N+Ldb7 ZyR0EuDW95JiF6ckhjXk8JwyJ0raKVQGeZvgKfS8O2CICoo/61c9Hr00bsMUhCTr8RJW OQnC1kEHbTsFZXw3b7gB1UOGxfrjrQ62gHpnCt68c/f7KvQWW0H6QZDN4tfL3h4vJwCL dr8nQQFNU9i7CiDQeYMlwP31pmG/j1y9Vm7jHqgo+ggmj3pOZ+B+CRHnbkP+5+fhkUHV Yv5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BLHXGviO; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id j62si540874pge.8.2022.02.14.11.23.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 11:23:35 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BLHXGviO; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D35D0CE918; Mon, 14 Feb 2022 11:14:27 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233206AbiBNJ5P (ORCPT + 99 others); Mon, 14 Feb 2022 04:57:15 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:34404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344930AbiBNJwH (ORCPT ); Mon, 14 Feb 2022 04:52:07 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B598C7B568; Mon, 14 Feb 2022 01:43:28 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 6C2BCB80DC4; Mon, 14 Feb 2022 09:43:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79F83C340E9; Mon, 14 Feb 2022 09:43:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644831806; bh=h6DUSLEzM5nWMlU2QZLed3g8W6f2bQcqsOY1Ce/iF+I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BLHXGviOmKQYecad+yERLkHmIH7NqnWuklPAH53auepInl18BUNhovBkv29Igfyx2 Hbbvb+fVaAgT6oLfH/kUFuqjcDYZZnixyxaFdSZ3h7TUOcnW1HacxauPUPL0c/glb+ m0zeMVEQyA2slK6hPXdmYXgOCEIfhBUehR5FG/Jg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andrey Konovalov , Jann Horn Subject: [PATCH 5.10 101/116] usb: raw-gadget: fix handling of dual-direction-capable endpoints Date: Mon, 14 Feb 2022 10:26:40 +0100 Message-Id: <20220214092502.270989110@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220214092458.668376521@linuxfoundation.org> References: <20220214092458.668376521@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jann Horn commit 292d2c82b105d92082c2120a44a58de9767e44f1 upstream. Under dummy_hcd, every available endpoint is *either* IN or OUT capable. But with some real hardware, there are endpoints that support both IN and OUT. In particular, the PLX 2380 has four available endpoints that each support both IN and OUT. raw-gadget currently gets confused and thinks that any endpoint that is usable as an IN endpoint can never be used as an OUT endpoint. Fix it by looking at the direction in the configured endpoint descriptor instead of looking at the hardware capabilities. With this change, I can use the PLX 2380 with raw-gadget. Fixes: f2c2e717642c ("usb: gadget: add raw-gadget interface") Cc: stable Tested-by: Andrey Konovalov Reviewed-by: Andrey Konovalov Signed-off-by: Jann Horn Link: https://lore.kernel.org/r/20220126205214.2149936-1-jannh@google.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/legacy/raw_gadget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/usb/gadget/legacy/raw_gadget.c +++ b/drivers/usb/gadget/legacy/raw_gadget.c @@ -1003,7 +1003,7 @@ static int raw_process_ep_io(struct raw_ ret = -EBUSY; goto out_unlock; } - if ((in && !ep->ep->caps.dir_in) || (!in && ep->ep->caps.dir_in)) { + if (in != usb_endpoint_dir_in(ep->ep->desc)) { dev_dbg(&dev->gadget->dev, "fail, wrong direction\n"); ret = -EINVAL; goto out_unlock;