Received: by 10.192.165.148 with SMTP id m20csp3992741imm; Mon, 30 Apr 2018 09:49:12 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoRPnMofFD29cebzFVTjhQc89N4bYtQLqRXzcs9zS4PRa8xZoC7Zvq1xlc/6gItvc437LTX X-Received: by 2002:a17:902:7082:: with SMTP id z2-v6mr1319357plk.373.1525106952283; Mon, 30 Apr 2018 09:49:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525106952; cv=none; d=google.com; s=arc-20160816; b=IA/KSwu9gzJQTc9k1eCdqq+XJ8zUoOCTGE4qnaWlwjo8roUha+ZO1LG+2pfL60K7eW 5rSKthIAGkVSMAv4nUtMPdK03lWeRdAftSDeORqtw4dB5Kzr82+qYia8a86tuUisiPMD 3hffD2THKKZSI0Kbk2xA8QMuMzMTtUCXgXPLWyTNDBIKlJ868YGl2mIoQIMpUxKEGBqc mrw++J7683TJh3t2n4QUN4RRvKM8pCiYKumbCqTLUxSLMAIf5IYXnESyuAASpIQAnX3E xL+qonGkqfv9eWo8vDi1K5MA0zZ1iWXOnkn2dEtUann6bID804MkwuT/6fkdTLaX5q65 4cIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :dkim-signature:arc-authentication-results; bh=byiRosZ8USN1hNJnPpIOJEPQbINU9VWw6PbusoTSQoE=; b=S5zrRZy4kwoqojd6D2oZm5BlapfHqML0hbAQA/xR/lkTOueBIPGHWRjSr6zkQJ3HDS 9F1dfKmhRYAYaChyL5Ije+cGv3QGOkxwzhOo1dgDRM3LyXk+nfCVmPh2ZKkkrKkFi96h tFjcNLlH+BgN6uBuDjVMPIT+l3DLL/mT1/wnCLtvq8l80CQjzVtn5Y1ilFEXKK8o51pD KReW0R6J5R1QSZwhb02Pz7A8IL6uC3vgcTDsP5NwIb9hhLekp2MdO0pf60iecwZOr84U 43N6mLlHwYbyNyjggMWAXVFYAHQDq3vXW6Ub59YLnV9iGCu0s25XCkrurnjieIEn4PgU WeJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=fL1VaMqk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 202si7859066pfx.61.2018.04.30.09.48.57; Mon, 30 Apr 2018 09:49:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=fL1VaMqk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755088AbeD3Qrh (ORCPT + 99 others); Mon, 30 Apr 2018 12:47:37 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:38166 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753334AbeD3Qrf (ORCPT ); Mon, 30 Apr 2018 12:47:35 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w3UGjrqd141334; Mon, 30 Apr 2018 16:46:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2017-10-26; bh=byiRosZ8USN1hNJnPpIOJEPQbINU9VWw6PbusoTSQoE=; b=fL1VaMqkB4mFp3ICUYxaMsBiV1Cwu7acGS2B8DaDS22dXCi7sRAJRiFpMe016l+Qkm9/ 4wsv+z7eIXj9kuM4+afl6Djy7e+xtSNROhO4rPsf8J8nncFVJ/2EwahSmKS+FnP4JsQa +JQ5WbmU0+2zz3aV+2MVaG+PXAa5TAoB+igus3z1FaUMzJhQNyaWg9Jg/BZk1rUEOzsg lqtCQflOqyQbzCCdTq39ESQZP2/qQTteUqTAtn6UZthTzjOoBNCxJOkoVPLG6qpzW9se P/NI6nTZc6X4+0pWAsJO8X1bVCQxJeKcjqOBl5N60BxeOkzcbNf95JPtCkkFg2wVj5hU Zg== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2hmgdjcxc6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 30 Apr 2018 16:46:56 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w3UGkt0T027687 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 30 Apr 2018 16:46:55 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w3UGksc9027010; Mon, 30 Apr 2018 16:46:54 GMT Received: from [10.159.248.65] (/10.159.248.65) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 30 Apr 2018 09:46:54 -0700 Subject: Re: [PATCH] ethtool: fix a potential missing-check bug To: Wenwen Wang Cc: Kangjie Lu , "David S. Miller" , Florian Fainelli , Andrew Lunn , Russell King , Edward Cree , Inbar Karmy , Eugenia Emantayev , Al Viro , Yury Norov , Vidya Sagar Ravipati , Alan Brady , Stephen Hemminger , "open list:NETWORKING [GENERAL]" , open list References: <1525051915-31944-1-git-send-email-wang6495@umn.edu> From: Shannon Nelson Organization: Oracle Corporation Message-ID: <1546193f-ed07-9a10-d2b3-d1d28138e291@oracle.com> Date: Mon, 30 Apr 2018 09:46:51 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <1525051915-31944-1-git-send-email-wang6495@umn.edu> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8879 signatures=668698 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1804300161 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/29/2018 6:31 PM, Wenwen Wang wrote: > In ethtool_get_rxnfc(), the object "info" is firstly copied from > user-space. If the FLOW_RSS flag is set in the member field flow_type of > "info" (and cmd is ETHTOOL_GRXFH), info needs to be copied again from > user-space because FLOW_RSS is newer and has new definition, as mentioned > in the comment. However, given that the user data resides in user-space, a > malicious user can race to change the data after the first copy. By doing > so, the user can inject inconsistent data. For example, in the second > copy, the FLOW_RSS flag could be cleared in the field flow_type of "info". > In the following execution, "info" will be used in the function > ops->get_rxnfc(). Such inconsistent data can potentially lead to unexpected > information leakage since ops->get_rxnfc() will prepare various types of > data according to flow_type, and the prepared data will be eventually > copied to user-space. This inconsistent data may also cause undefined > behaviors based on how ops->get_rxnfc() is implemented. > > This patch re-verifies the flow_type field of "info" after the second copy. > If the value is not as expected, an error code will be returned. > > Signed-off-by: Wenwen Wang > --- > net/core/ethtool.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/net/core/ethtool.c b/net/core/ethtool.c > index 03416e6..a121034 100644 > --- a/net/core/ethtool.c > +++ b/net/core/ethtool.c > @@ -1032,6 +1032,8 @@ static noinline_for_stack int ethtool_get_rxnfc(struct net_device *dev, > info_size = sizeof(info); > if (copy_from_user(&info, useraddr, info_size)) > return -EFAULT; You might add a comment here to explain why the second check; otherwise someone might come along later and remove this check as redundant code. sln > + if (!(info.flow_type & FLOW_RSS)) > + return -EINVAL; > } > > if (info.cmd == ETHTOOL_GRXCLSRLALL) { >