Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp3680146lfo; Mon, 23 May 2022 11:13:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmZ10bk+pztuTWv0zXXXtu9JiFQeJNK7QfFuDfSv+BU5jN4grRB0nuivhR9/Y3kDRQfvzR X-Received: by 2002:a17:902:e5cb:b0:161:872d:6ed3 with SMTP id u11-20020a170902e5cb00b00161872d6ed3mr24186806plf.62.1653329593357; Mon, 23 May 2022 11:13:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653329593; cv=none; d=google.com; s=arc-20160816; b=ST/Ns4RZpqRqEr61JiYzMmpRgDGTJRjYTBtarXzBNloXL3/RluEhFE9gn/IKjz+x/z RAQ9ISiVBJvXs6vDYSZ5dA+erVy2l0tz4znsBgCd5pm+WwHGHdTipO8NCvIt1+xoOsz7 2i+FDjDS2YF085sWkQvs0ypoUWCR09iQD1Z8zuHZ4TIjjnRyrTdL4cbv0utmzMJF/1NS TDijzABeOXFQBk93P4gtk6U6V+cuB/O6SlCoxOzMq0rvmsh8Z61UTIZmJO7U6y8Oq4sX QbPlb6bQMlKaYIB4SQLvUVXTr6P4zxnz4e3EO4AXjfh8XCg6U9XHDHn9LCCNL63rkUw/ /4Rw== 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=Ct1BQ/0jksh4K7f3JtJduQNZ9hNGeTgFHKPDIjEXJoM=; b=B5xfJqSsIiBqBNf5wvR7vwEbMZbqUWbgSFvCplmIk6BLwWScjmbSHcMsfBJ7k1PQEk rLavCtfOKvSpHpVBwCySfT0Vb2Q3n8u9tvy3uEKlTO/c8gIaQYECMaE0uGdW6nQlbrDN 7C+wtSHyEilKIJrO4LdIPy1Wjldt/7TVyDe2LLygvJXTsncs6bnDjuLnLPhycVBFCUuD Vi6Gga+vLw62dXoqiJjERynB+8QtVXKIOu5fuRqREKmnmzZUfx2ANBze2cG0jw6z1os5 a+6jLDVDyXI51Kv9eod6v4nqpoJ4simOnxmM56dz3tGVymKVEkWdDWzKJV35T4StUlja jlCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dlJAw0+f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id cm18-20020a056a00339200b0050dd6ccf178si11558431pfb.381.2022.05.23.11.13.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 11:13:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dlJAw0+f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 E896428711; Mon, 23 May 2022 11:11:06 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343589AbiEWSIX (ORCPT + 99 others); Mon, 23 May 2022 14:08:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243645AbiEWRiW (ORCPT ); Mon, 23 May 2022 13:38:22 -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 910BF939B9 for ; Mon, 23 May 2022 10:32:36 -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 CC3F3B8121A for ; Mon, 23 May 2022 17:32:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2C17AC385A9; Mon, 23 May 2022 17:32:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1653327137; bh=sjJ34GcqhXoKGZ5Q8UWMhx1olSPo7NFZtw3Y5PKxEh4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=dlJAw0+fvw7YYSd+9g7GsfEddRb3tWM3fIU7cl7Z0lStSu+8/iF8BamcptK+vO6jX eq75ZsX91MLz9G/uDOUndCCxQyU1EAQ1ib3pQMSNXuI89tfXSm5zvUmc6/vSfKk08L VMOkb9EbsuG4WAT8RRh3+WGdU7DkjAKumAcSjWJI= Date: Mon, 23 May 2022 19:15:39 +0200 From: Greg KH To: Eli Billauer Cc: Zheyu Ma , arnd@arndb.de, Linux Kernel Mailing List Subject: Re: [PATCH v2] char: xillybus: Check endpoint type before allocing Message-ID: References: <20220514114819.2773691-1-zheyuma97@gmail.com> <628BBEEB.9010306@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <628BBEEB.9010306@gmail.com> X-Spam-Status: No, score=-2.6 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=unavailable 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 Mon, May 23, 2022 at 08:05:47PM +0300, Eli Billauer wrote: > On 23/05/22 19:06, Greg KH wrote: > > If the device does not have the EXACT USB endpoints that you are > > expecting (size, address, direction, type, etc.) at probe time reject > > the device. > This is probably a good time to add some information about XillyUSB. > > All XillyUSB devices have EP 1 IN and EP 1 OUT as bulk endpoints. > > On top of that, they *may* have up to 14 additional bulk OUT endpoints, > having the addresses EP 2 OUT to EP 15 OUT. The population of endpoint > addresses is not necessarily continuous. Any set of OUT endpoint addresses > is allowed. The driver doesn't know which of these endpoints are available > initially. > > Rather, it works like this: The driver uses the EP 1 IN and OUT endpoints to > query the device for a data structure, which contains information on the > device's communication channels. The driver sets up device files > accordingly, and it also gets informed on which bulk OUT endpoints are > present. > > For what it's worth, I think it's fairly safe to assume that if a device > returns a legal data structure (which passes a CRC test), it's a XillyUSB > device. Why? You still need to verify that the requested endpoints match up with what the device really has. Again, we are talking about "fake" devices that are being used to find problems in the kernel drivers, this is not a "real" device, yet can look a lot like one. Look at the fuzzing tools that are running for examples of this. > Either way, it's impossible to verify that all of the device's bulk > OUT endpoints are correct before obtaining the data structure from the > device. The fact that each device has a different set of communication > channels, and that the driver learns about them in run-time is the whole > trick with Xillybus and XillyUSB. That's fine, but that can still be done a probe() time, not open() time, like the current patch was attempting. That's much too late. thanks, greg k-h