Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1152721iob; Sat, 14 May 2022 01:04:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw86iZweEdYQKIa/W74Hg7AhADsyoGF/S1QBuGT8h0wLP1j7MA40W+8KDwFh8aRF76UwG4+ X-Received: by 2002:a05:6000:230:b0:209:87ac:4cf5 with SMTP id l16-20020a056000023000b0020987ac4cf5mr6735889wrz.80.1652515466937; Sat, 14 May 2022 01:04:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652515466; cv=none; d=google.com; s=arc-20160816; b=B3O0CDfXp5T7KDV/8J3EMBYL5iCrStYeYdORl1gjhNtqmQDE9f7hi0JGbilO1TX9nM LLbxoMnJvRLigS4wj8PSLDKqcbDzsx3HI+7/+OUg5yog63pE0Hx95XDfR4wP8ICrhlrE Q9PoNAY3D9aX3Rt88vAxygi24SdRAaORC9qH5GhRd87ofLKe/t64ndsVP/jIrmWtWrLd 5Ke/zQkd9YzgGknzX1/oVV/GgGGjmY6dZJ/+uDCjbEkP0YJUuFHW293yLmx772MphhzE paRc0w3DTFU7mMJl9lEQGSSH0S4Z5Ru7E2B6ttRFGOLl41RO9RS2a+uebaEKVJCn4tK7 fyTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=CkRQVn20d/Rtn1x/T0GCKNuA+4t+gPtwq4pNXR1ofsY=; b=z/f/zJ15b4X2ekeTW290NXnGy/AbF2RJzTetB1yxb0iOMvWXMiC3YG+QWmU0Vlj6Ft K9sPRuol1IiBhfzt+ph8gqY53/bH7W6Awr1uoXnHoTrQ3dMl254Iyy82qEZBEL2J/oiq TBKe/CpfF+hCFJ+5CMlFIbOUAiLGVOf+Z71ycnB1yyiFJcHugsv8+hugalu4w7nDg96b zGwCdWe1+d9M39aO8aZBvPQTzSzxi/005q9fNHxe1UezmCi33HAi7tnDqqzvGLgWm9sQ nV2qvaiExE3rn8A4tz8k3/qJFW/2r1FftNg9QofCsCmo+QPupnQodF9Q5T9NYYwiaBCi jXbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1mysqPVm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e7-20020a5d5947000000b0020a878263f9si3872229wri.457.2022.05.14.01.03.57; Sat, 14 May 2022 01:04:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1mysqPVm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229464AbiENHSf (ORCPT + 99 others); Sat, 14 May 2022 03:18:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229457AbiENHSb (ORCPT ); Sat, 14 May 2022 03:18:31 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70198CCC for ; Sat, 14 May 2022 00:18:30 -0700 (PDT) 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 15B64B82CD9 for ; Sat, 14 May 2022 07:18:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 62D8BC340EE; Sat, 14 May 2022 07:18:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1652512707; bh=h/WVTZYcRvheFzmWypCAOaDVrx4HZe4HVRhe4SlC1XE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=1mysqPVmQ5JY5H0x3iIpKNP4fGl37eimBAoxQUJpMjz4KKaXs5VbNEBruqTDaUdGy ju8EzTnFcaaVBLAQEIoiTxZPnUFts8RI+ZhMBnOaGCCCLNh+TpHmmzfTg0R6nV4j3C ax+QDZckn1ac6a47ffTKNRZNAovafjQEh3jFY3LA= Date: Sat, 14 May 2022 09:18:24 +0200 From: Greg KH To: Zheyu Ma Cc: eli.billauer@gmail.com, arnd@arndb.de, linux-kernel@vger.kernel.org Subject: Re: [PATCH] char: xillybus: Check endpoint type properly Message-ID: References: <20220514071436.2517776-1-zheyuma97@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220514071436.2517776-1-zheyuma97@gmail.com> X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 On Sat, May 14, 2022 at 03:14:35PM +0800, Zheyu Ma wrote: > The driver submits bulk urb without checking the endpoint type is > actually bulk. > > [ 3.108411] ------------[ cut here ]------------ > [ 3.108690] usb 1-1: BOGUS urb xfer, pipe 3 != type 1 > [ 3.108983] WARNING: CPU: 0 PID: 211 at drivers/usb/core/urb.c:503 usb_submit_urb+0xcd9/0x18b0 > [ 3.110976] RIP: 0010:usb_submit_urb+0xcd9/0x18b0 > [ 3.115318] Call Trace: > [ 3.115452] > [ 3.115570] try_queue_bulk_in+0x43c/0x6e0 [xillyusb] > [ 3.115838] xillyusb_probe+0x488/0x1230 [xillyusb] > > Add a check to fix it. > > Fixes: a53d1202aef1 ("char: xillybus: Add driver for XillyUSB (Xillybus variant for USB)") > Signed-off-by: Zheyu Ma > --- > drivers/char/xillybus/xillyusb.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/drivers/char/xillybus/xillyusb.c b/drivers/char/xillybus/xillyusb.c > index 39bcbfd908b4..2ec2e087b2e7 100644 > --- a/drivers/char/xillybus/xillyusb.c > +++ b/drivers/char/xillybus/xillyusb.c > @@ -730,6 +730,11 @@ static void try_queue_bulk_in(struct xillyusb_endpoint *ep) > > usb_anchor_urb(urb, &ep->anchor); > > + if (usb_urb_ep_type_check(urb)) { > + report_io_error(xdev, -EINVAL); > + goto unanchor; > + } > + > rc = usb_submit_urb(urb, GFP_KERNEL); > > if (rc) { > @@ -834,6 +839,11 @@ static void try_queue_bulk_out(struct xillyusb_endpoint *ep) > > usb_anchor_urb(urb, &ep->anchor); > > + if (usb_urb_ep_type_check(urb)) { > + report_io_error(xdev, -EINVAL); > + goto unanchor; > + } > + > rc = usb_submit_urb(urb, GFP_KERNEL); > > if (rc) { > -- > 2.25.1 > This should all be checked much earlier, in your probe function, to make sure you have the endpoints correct. Just refuse to bind to a device that is not correct. Don't check late here when you are submitting the urb. thanks, greg k-h