From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D33A0C7EE29 for ; Thu, 8 Jun 2023 09:06:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235584AbjFHJG5 (ORCPT ); Thu, 8 Jun 2023 05:06:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233071AbjFHJGv (ORCPT ); Thu, 8 Jun 2023 05:06:51 -0400 Received: from mail-m11875.qiye.163.com (mail-m11875.qiye.163.com [115.236.118.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4ACA3E50; Thu, 8 Jun 2023 02:06:44 -0700 (PDT) Received: from [0.0.0.0] (unknown [172.96.223.238]) by mail-m11875.qiye.163.com (Hmail) with ESMTPA id ADB3928086B; Thu, 8 Jun 2023 17:06:34 +0800 (CST) Message-ID: <034f5393-e519-1e8d-af76-ae29677a1bf5@sangfor.com.cn> Date: Thu, 8 Jun 2023 17:06:31 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.11.2 Subject: Re: [PATCH net-next] net: ethtool: Fix out-of-bounds copy to user Content-Language: en-US To: Jakub Kicinski 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 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> <20230605113915.4258af7f@kernel.org> From: Ding Hui In-Reply-To: <20230605113915.4258af7f@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWS1ZQUlXWQ8JGhUIEh9ZQVlCTEgYVk9IHUJOGhhNShpIGlUTARMWGhIXJBQOD1 lXWRgSC1lBWUpMSVVCTVVJSUhVSUhDWVdZFhoPEhUdFFlBWU9LSFVKSktISkxVSktLVUtZBg++ X-HM-Tid: 0a889a420a612eb1kusnadb3928086b X-HM-MType: 1 X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6OAg6Nyo*TT1MDC8qST8tLUkD Sw4KCzNVSlVKTUNNSUpOSUtLSUxMVTMWGhIXVR8SFRwTDhI7CBoVHB0UCVUYFBZVGBVFWVdZEgtZ QVlKTElVQk1VSUlIVUlIQ1lXWQgBWUFIQkxNNwY+ Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023/6/6 2:39, Jakub Kicinski wrote: > 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 */ > > :( > Sorry for late. Now I'm not sure what can I do next besides reporting the issue. >> 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. > -- Thanks, - Ding Hui