Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3001682rwd; Fri, 2 Jun 2023 19:17:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6Qsx44Zuyk21UlplsVfI68jXhHi/0JEFoPN7+QBOdgWtKVmnuUyEKO2Uoxo98tDDDFjF2i X-Received: by 2002:a05:6358:7e0e:b0:125:7d1c:7f64 with SMTP id o14-20020a0563587e0e00b001257d1c7f64mr8367508rwm.31.1685758619858; Fri, 02 Jun 2023 19:16:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685758619; cv=none; d=google.com; s=arc-20160816; b=BlwV5i6vlcgQ3QcoQUncR//iXCLscjBZVTFZMRiD2v6ZviBhJu1BrBaDS9SI6JF6tA QxQbnNCuLui734hgDq1tBczie0oGOE8KIi34GrRJfSZ+uSF1yd80c1rvVrmPl9iektIC A6gLtwXjh5wUH3UUjrBmCbw3eNkFOP9pXKYekJUrs4ZZj7ql4ydNAqRbvIncMWkEGlvJ aebFC3e4C6ihw9dvsb0P89LlXwH5uHcjsiFj2baY+/HjXZBb6CTDMf58wcQaIzxx/qsM t3vG/ykAO7z672ljfPMabIVKT8T3O5RDHCeguodEEnAOvdqHu3rFnfA5M0Iw4OFYBdOG 4Z6g== 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=p+lLn2X7RI77Dv9ZfRpqckgT1MVZQpu5rkRvVEZ3/ko=; b=pn19/+10/6rBqT77oEOYKhdmsFxBTy6k4aaaridqqFr5huFg/sAUqnvP/zCoPmPiko BqVBPUECINgOco99HL3i/ZoGnZ793dJFQtdZ74iZAmjGRtLNtrsOySnWeSWY1Wa2i0hN hpfSUgi9S7/SBnIgmTCbSNgCnGVWuqabsZkY+6inu4K2fnOQGo0F0ecLnVpvNseBZ6na IEEWenSZzY1fiqvakTLYGPvnkpsP2Mb7RBgRnklINvXcnusiLXiC+SbpLCxBTAnv5c1m uQdjcqTSWFHwBWQsXIIUScBrsvi5YkalFlWEoiQIM5U8UqOkMXqDWyrtgL2jiCkOdCOo IN3A== 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 pf11-20020a17090b1d8b00b002565931f7c0si3829764pjb.127.2023.06.02.19.16.44; Fri, 02 Jun 2023 19:16:59 -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 S236976AbjFCBvv (ORCPT + 99 others); Fri, 2 Jun 2023 21:51:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231202AbjFCBvu (ORCPT ); Fri, 2 Jun 2023 21:51:50 -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 428B8E45; Fri, 2 Jun 2023 18:51:48 -0700 (PDT) Received: from [0.0.0.0] (unknown [172.96.223.238]) by mail-m11875.qiye.163.com (Hmail) with ESMTPA id D42C928025B; Sat, 3 Jun 2023 09:51:37 +0800 (CST) Message-ID: <44905acd-3ac4-cfe5-5e91-d182c1959407@sangfor.com.cn> Date: Sat, 3 Jun 2023 09:51:34 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.11.1 Subject: Re: [PATCH net-next] net: ethtool: Fix out-of-bounds copy to user To: Alexander Duyck , Andrew Lunn Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, 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> Content-Language: en-US From: Ding Hui In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWS1ZQUlXWQ8JGhUIEh9ZQVlCTR8ZVkJKTBlKSE9KGEJCHVUTARMWGhIXJBQOD1 lXWRgSC1lBWUpMSVVCTVVJSUhVSUhDWVdZFhoPEhUdFFlBWU9LSFVKSktISkxVSktLVUtZBg++ X-HM-Tid: 0a887ef4098b2eb1kusnd42c928025b X-HM-MType: 1 X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6Pwg6Mjo5Pz1DPjMOFC0TC0Mp QxMwFAFVSlVKTUNOTE5MSktISEhKVTMWGhIXVR8SFRwTDhI7CBoVHB0UCVUYFBZVGBVFWVdZEgtZ QVlKTElVQk1VSUlIVUlIQ1lXWQgBWUFIQkpPNwY+ 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/3 2:02, Alexander Duyck wrote: > On Fri, Jun 2, 2023 at 9:37 AM Andrew Lunn wrote: >> >>> What this change is essentially doing is clamping the copied data to >>> the lesser of the current value versus the value when the userspace >>> was allocated. However I am wondering now if we shouldn't just update >>> the size value and return that as some sort of error for the userspace >>> to potentially reallocate and repeat until it has the right size. >> >> I'm not sure we should be putting any effort into the IOCTL >> interface. It is deprecated. We should fix overrun problems, but i >> would not change the API. Netlink handles this atomically, and that is >> the interface tools should be using, not this IOCTL. > > If that is the case maybe it would just make more sense to just return > an error if we are at risk of overrunning the userspace allocated > buffer. > In that case, I can modify to return an error, however, I think the ENOSPC or EFBIG mentioned in a previous email may not be suitable, maybe like others length/size checking return EINVAL. Another thing I wondered is that should I update the current length back to user if user buffer is not enough, assuming we update the new length with error returned, the userspace can use it to reallocate buffer if he wants to, which can avoid re-call previous ioctl to get the new length. -- Thanks, - Ding Hui