Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5103311rwd; Sun, 4 Jun 2023 20:58:25 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5tOeNDzBlHWkxi2wSzIt6yWBsdQ4ErBBuGGF0ZmaMUpdJ8I8tRwp7iMpx7ANq2hlxV1f9C X-Received: by 2002:a05:6358:c0e:b0:127:ae14:208 with SMTP id f14-20020a0563580c0e00b00127ae140208mr7758207rwj.7.1685937504869; Sun, 04 Jun 2023 20:58:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685937504; cv=none; d=google.com; s=arc-20160816; b=dqYD0B/QjzkXQAt9gN75ZPmJhigpczpjyt04dVzajaLeJZo+oGaUIRRhYm596Vd8OW aZ9m0/JP3oEXPrz8AKY372oXI0z4rWRpI6JHlQnV44rpEJz9M/Z8PtPqCiTY51hU27u1 UCNF1tA0j7Z5XWtaGvniPqPZWcpqxqIP+9bcFmM1nC7mKwPTWddlg4I8Gb9HkaXAfBcg rdQfk5gHciqfV5ghtWR08XcaHdHR1DkEFzH1vTFgf0U7zS8xxej9uyuDMIyxBx2wzwBR Ud/gMzBv264bejnsHW94pr/msNXqZZM6XQg8Ch6GWoWH2IALMElXPlW76SoPvPfKb/ig 5xpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id; bh=nTxbUSDKT/4MohsULShVTQM9JWRZ2Y1M5ddHDP4B7cY=; b=U7+2bc1qtUaA0xue7u4iKbB0mylo2PCye9sPWjNvZ5CI1mY9dhgui9sDGz3vxnjxJM HugYe3PYn4bDFfw4UHZ9M59cQTbStn2jRlTRVt7FtkDFrTDCl/Yq1s0+41LZ+D22t+Vs OiigHil6Ia5iIxJnGxuLPWYYECPVbvKRX7TStT1P8kw9t64ArZ2mi7tqTdp9NTag1G3d YIkxvQyl2IZ0qcmVnJyz8Yb2ZaBpli02h9emdBIGXDS/RqfwkzamtLs/v6PCBy0xXcR4 fljIzkUPSUaUZhRNMKSHPk5HoXNbxY8c9LJofoc9dYoTWLcbV1tr4d277qzHyeSBkXG+ drrg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=sangfor.com.cn Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u2-20020a17090a400200b00256917c7851si6552366pjc.107.2023.06.04.20.58.11; Sun, 04 Jun 2023 20:58:24 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=sangfor.com.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232752AbjFEDkQ (ORCPT + 99 others); Sun, 4 Jun 2023 23:40:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230193AbjFEDkP (ORCPT ); Sun, 4 Jun 2023 23:40:15 -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 964B7B1; Sun, 4 Jun 2023 20:40:12 -0700 (PDT) Received: from [0.0.0.0] (unknown [172.96.223.238]) by mail-m11875.qiye.163.com (Hmail) with ESMTPA id AFA5228027E; Mon, 5 Jun 2023 11:40:01 +0800 (CST) Message-ID: Date: Mon, 5 Jun 2023 11:39:59 +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 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> Content-Language: en-US From: Ding Hui In-Reply-To: <20230604104718.4bf45faf@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWS1ZQUlXWQ8JGhUIEh9ZQVlCSEhIVk5PQ0kfSR9OQx9OHlUTARMWGhIXJBQOD1 lXWRgSC1lBWUpMSVVCTVVJSUhVSUhDWVdZFhoPEhUdFFlBWU9LSFVKSktISkxVSktLVUtZBg++ X-HM-Tid: 0a8889a3ff7c2eb1kusnafa5228027e X-HM-MType: 1 X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6K1E6MSo*Nz0BFDAyOQgtHlY* CjQwCjRVSlVKTUNOQkhNT0tMSEhJVTMWGhIXVR8SFRwTDhI7CBoVHB0UCVUYFBZVGBVFWVdZEgtZ QVlKTElVQk1VSUlIVUlIQ1lXWQgBWUFPS0JDNwY+ X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,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 2023/6/5 1:47, Jakub Kicinski wrote: > On Sat, 3 Jun 2023 15:11:29 +0800 Ding Hui wrote: >> Yes. >> >> I checked the others ioctl (e.g. ethtool_get_eeprom(), ethtool_get_features()), >> and searched the git log of ethtool utility, so I think that is an implicit >> rule and the check is missed in kernel where the patch involves. >> >> Without this rule, we cannot guarantee the safety of copy to user. >> >> Should we keep to be compatible with that incorrect userspace usage? > > If such incorrect user space exists we do, if it doesn't we don't. > Problem is that we don't know what exists out there. > > Maybe we can add a pr_err_once() complaining about bad usage for now > and see if anyone reports back that they are hitting it? > How about this: 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. 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