Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2136510iof; Tue, 7 Jun 2022 20:58:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzsPAjXw9E0DtRd2hIxjPwaWjm2gGyVOBWmIUW5L0HA7c5Z4SgIvCfDv9i9DmPVPWv7uUnW X-Received: by 2002:a05:6a00:1a8f:b0:51c:2f82:cdba with SMTP id e15-20020a056a001a8f00b0051c2f82cdbamr8929620pfv.85.1654660730355; Tue, 07 Jun 2022 20:58:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654660730; cv=none; d=google.com; s=arc-20160816; b=LLu+1RvkO0ceF0IvfUpogV8X9tWVgGLh9InSyzkdEkXKmoCki4ZIfAdjTfPAIxoyrw +IUFMP9GyBPyIKVqfn5utLECmEudUc1vbt8xJse+Xy+pykj7EO0q8Lp/7J5qd4E5VqJi 2EkEt9q6+5Hev8koxlJAixSOCBOk8M+kVpnzRNh82xIbQpOkPZPSVpSyPhkQuL4JtS8D AkCLIs4aII8oWhq98/rQZTaPv5vCFS4G+DMavH0USbS0ZZuM4mirQXGuLKOIHch4/CDZ nAsEA//ZYGx9++yKYYlWAKmLcfI4JBys5IFg3DjYKz1lBUiGH5WU0VR+MOLtd8L41mA9 8nHQ== 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=TsseGzWR9dwSaQDPNHdQEQdBWUHTUPGtoc5HmqoKoqA=; b=dg6DR/uZjw2VSAdNkqaWJ60f6VHy0UFuBV+Y6r9SwUcQFMN8TGWBV5oITry0PGXaSa J6trTo5ypTWnyFg83VE7P0E71BbDLc+u2Vhqw7PV5nHU6Pgxiv/7aQ3GOM4FzSsFy7u7 1AOXYn4ZN4IXRCCnp6Y1GFfomp06eIbWa7YDx1Sx1aCUPJGNc3osGib2sY1Yjn9snEhB cJurgx+bXlijHfiz4Bu+ErdOaB1m7cCUFTDWDvIKOO2yrgIzwZ9rwfbORmpwWvbsgZFk 2B0MKjz6lCMPPpcGvVPWBRxo7J8ZYqD0x6wtzMJIRNv5SL/HXJiya8Uk+Yn76QXbqOXN 8zAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zHqwtQR4; 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 p1-20020a170902b08100b0016895725854si985182plr.328.2022.06.07.20.58.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 20:58:50 -0700 (PDT) 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=zHqwtQR4; 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 9B27039A3D8; Tue, 7 Jun 2022 20:22:08 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244234AbiFGMsd (ORCPT + 99 others); Tue, 7 Jun 2022 08:48:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244205AbiFGMsY (ORCPT ); Tue, 7 Jun 2022 08:48:24 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 021731D331 for ; Tue, 7 Jun 2022 05:48:19 -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 4A076B81F6F for ; Tue, 7 Jun 2022 12:48:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 624B9C385A5; Tue, 7 Jun 2022 12:48:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654606097; bh=mtxqza0gI9LzuBdAaUvRx2Y1GByfp78MN6I6ID87xUY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=zHqwtQR4GRvIUM8GjKkTmWoLj/so+ZFC8V3/9nC7YpOHbbXu8wrzqt4HmbEtIMz8q h65SBD5a3WPhnI9HhIj74fkFGXxgX2vNJiaKR8ZM3wcgaMIeydyKlldWJZFkJ3KOtp nJGTgiv+x5Y+o7oCDz0rUn/dEfYp37Utz17+W/o0= Date: Tue, 7 Jun 2022 14:48:14 +0200 From: Greg Kroah-Hartman To: Xiaohui Zhang Cc: Ian Abbott , H Hartley Sweeten , Johan Hovold , linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/1] comedi: ni_usb6501: fix transfer-buffer overflows Message-ID: References: <20220607111802.13311-1-xiaohuizhang@ruc.edu.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220607111802.13311-1-xiaohuizhang@ruc.edu.cn> X-Spam-Status: No, score=-3.1 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 Tue, Jun 07, 2022 at 07:18:02PM +0800, Xiaohui Zhang wrote: > Similar to the handling of vmk80xx_alloc_usb_buffers in commit > a23461c47482("comedi: vmk80xx: fix transfer-buffer overflows"), > we thought a patch might be needed here as well. > > The driver uses endpoint-sized USB transfer buffers but up until > recently had no sanity checks on the sizes. > > Signed-off-by: Xiaohui Zhang > --- > drivers/comedi/drivers/ni_usb6501.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/comedi/drivers/ni_usb6501.c b/drivers/comedi/drivers/ni_usb6501.c > index 0dd9edf7bced..8303bfc305c5 100644 > --- a/drivers/comedi/drivers/ni_usb6501.c > +++ b/drivers/comedi/drivers/ni_usb6501.c > @@ -90,6 +90,7 @@ > #include > > #define NI6501_TIMEOUT 1000 > +#define MIN_BUF_SIZE 64 > > /* Port request packets */ > static const u8 READ_PORT_REQUEST[] = {0x00, 0x01, 0x00, 0x10, > @@ -459,12 +460,12 @@ static int ni6501_alloc_usb_buffers(struct comedi_device *dev) > struct ni6501_private *devpriv = dev->private; > size_t size; > > - size = usb_endpoint_maxp(devpriv->ep_rx); > + size = max(usb_endpoint_maxp(devpriv->ep_rx), MIN_BUF_SIZE); > devpriv->usb_rx_buf = kzalloc(size, GFP_KERNEL); > if (!devpriv->usb_rx_buf) > return -ENOMEM; > > - size = usb_endpoint_maxp(devpriv->ep_tx); > + size = max(usb_endpoint_maxp(devpriv->ep_tx), MIN_BUF_SIZE); > devpriv->usb_tx_buf = kzalloc(size, GFP_KERNEL); > if (!devpriv->usb_tx_buf) > return -ENOMEM; > -- > 2.17.1 > Hi, This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him a patch that has triggered this response. He used to manually respond to these common problems, but in order to save his sanity (he kept writing the same thing over and over, yet to different people), I was created. Hopefully you will not take offence and will fix the problem in your patch and resubmit it so that it can be accepted into the Linux kernel tree. You are receiving this message because of the following common error(s) as indicated below: - You did not specify a description of why the patch is needed, or possibly, any description at all, in the email body. Please read the section entitled "The canonical patch format" in the kernel file, Documentation/SubmittingPatches for what is needed in order to properly describe the change. - You did not write a descriptive Subject: for the patch, allowing Greg, and everyone else, to know what this patch is all about. Please read the section entitled "The canonical patch format" in the kernel file, Documentation/SubmittingPatches for what a proper Subject: line should look like. - This looks like a new version of a previously submitted patch, but you did not list below the --- line any changes from the previous version. Please read the section entitled "The canonical patch format" in the kernel file, Documentation/SubmittingPatches for what needs to be done here to properly describe this. If you wish to discuss this problem further, or you have questions about how to resolve this issue, please feel free to respond to this email and Greg will reply once he has dug out from the pending patches received from other developers. thanks, greg k-h's patch email bot