Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6027786rwd; Mon, 5 Jun 2023 11:52:09 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Ww81CB7JADRpEbC4rSkbOD/j3rO6kTIHBSpBXGhnXeeOgH3MWKBpKMu+z8On29oHwWGjl X-Received: by 2002:a05:622a:349:b0:3f3:8f39:3473 with SMTP id r9-20020a05622a034900b003f38f393473mr9686385qtw.26.1685991129443; Mon, 05 Jun 2023 11:52:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685991129; cv=none; d=google.com; s=arc-20160816; b=gdocga1w9p8IgZ6aLQrGiBWjGSXtO7nB32w+c0ozylDVUkQ6sO2KMp/+URbf7hFNG4 ZcWaf8R24xUfqqDHccCy8mQmtHKbbMfXsQu5CcGCoyPLZs3zRi28wlpvbfn625qciGhz nHfNGq/iZZwRNyFsE8N88T36oa7EvLFakyTmYpRiTZBJjDWYzLNINvu3di4Dlarx2XUc oa4lFrujp1Nrps0BzEg+kjzlZeQNd2vxBYyWzuJuCMlz7aOJYKkiB39mbVxw8oWFjDvr +4lw2QOCbTJlZ/UlsRT1tdGeAVCX+KGHYeoHbDP+M92UZ4qyQ9qXnvVdFWPtpHeCP30s rmcQ== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=VPvneT+PI7uUAwmOFqeKlEhEc8Vv8Ilxi248OnsSKgM=; b=fn5QyFbRpYSN8ySzxhtfrZSWWSQtJiW6qZ7Z+c1uPxgdv5yTMG+ezo4hIidXLcLwCk tjIoEt8qvlgISdEFK8ed+ZU4GKItgnirq0F4udCkSHUi2lUB9vIxOpO0NZ1xRMG6LTEf bqsmu1c3ot3rtKdLdRqdsyyfRDiSaHvHqi4lgtly5B39YvQAHiNfnwkY2Q0rBB1hgGh4 5+8ISPL1lZatGmi7zLOtS2M5waON+FG4qywo7DrvvZ+8lgUqlqugTQCvRouwtFbPqDAH HGs32ekFVnZ8swDARNmnpfNJNl1S3D/2pUROIXfNu6KAu8b1wbcAZVAy9x/pYkd1McuD fWYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="o/iwLQHC"; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x16-20020a05622a001000b003f91729aed0si1862325qtw.157.2023.06.05.11.51.54; Mon, 05 Jun 2023 11:52:09 -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=@kernel.org header.s=k20201202 header.b="o/iwLQHC"; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232353AbjFESjU (ORCPT + 99 others); Mon, 5 Jun 2023 14:39:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229529AbjFESjS (ORCPT ); Mon, 5 Jun 2023 14:39:18 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB0BAEC for ; Mon, 5 Jun 2023 11:39:17 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 6DC6561597 for ; Mon, 5 Jun 2023 18:39:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6422CC433D2; Mon, 5 Jun 2023 18:39:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685990356; bh=33+KTPIjPakdBxCr6qfiCLnamUiHY+NjSa8DozXb0qo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=o/iwLQHCoNd7FLrkgJNiVjXsBomsWPngNGuK9A/Zf0WcwHYrFOLpEoooPn8j0t79T +rg5f8MTO/QxHt46ePHsDL5Waf/h6XNHmjw9bPLGEuen+YIJnIcdCdhcr3Tk6MA+fv R30t50LVXJ4LpX06A4Y+EnqFhFML5fPCattWPxGfob4GVQUxQDUgEXFo82F+MusJ54 14mCk5vMS78FLCoeeulOEYrS3s50gG/e4vhqTXSMqex7myFHUXzhf/20RvQQVhBdhK bbS++cVXnht0zwzUc/uOF3WOFMoyOZZx7TX+M9ejUL72dTuK86/aqbPZgk68Ca+Zmd F+gvWp2C248bw== Date: Mon, 5 Jun 2023 11:39:15 -0700 From: Jakub Kicinski To: Ding Hui Cc: Alexander Duyck , Andrew Lunn , davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, pengdonglin@sangfor.com.cn, huangcun@sangfor.com.cn Subject: Re: [PATCH net-next] net: ethtool: Fix out-of-bounds copy to user Message-ID: <20230605113915.4258af7f@kernel.org> In-Reply-To: References: <20230601112839.13799-1-dinghui@sangfor.com.cn> <135a45b2c388fbaf9db4620cb01b95230709b9ac.camel@gmail.com> <6110cf9f-c10e-4b9b-934d-8d202b7f5794@lunn.ch> <6e28cea9-d615-449d-9c68-aa155efc8444@lunn.ch> <44905acd-3ac4-cfe5-5e91-d182c1959407@sangfor.com.cn> <20230602225519.66c2c987@kernel.org> <5f0f2bab-ae36-8b13-2c6d-c69c6ff4a43f@sangfor.com.cn> <20230604104718.4bf45faf@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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 Mon, 5 Jun 2023 11:39:59 +0800 Ding Hui wrote: > Case 1: > If the user len/n_stats is not zero, we will treat it as correct usage > (although we cannot distinguish between the real correct usage and > uninitialized usage). Return -EINVAL if current length exceed the one > user specified. This assumes user will zero-initialize the value rather than do something like: buf = malloc(1 << 16); // 64k should always be enough ioctl(s, ETHTOOL_GSTATS, buf) for (i = 0; i < buf.n_stats; i++) /* use stats */ :( > Case 2: > If it is zero, we will treat it as incorrect usage, we can add a > pr_err_once() for it and keep to be compatible with it for a period of time. > At a suitable time in the future, this part can be removed by maintainers.