Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1826876imm; Mon, 3 Sep 2018 10:26:52 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZUPo1miXDMLBdNIMsJ7cJSL+b5dVTans5GxEvMV5oZ/DDW1uqWHpPF3kzK5feU+0WCb/UT X-Received: by 2002:a17:902:74ca:: with SMTP id f10-v6mr29795579plt.260.1535995611983; Mon, 03 Sep 2018 10:26:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535995611; cv=none; d=google.com; s=arc-20160816; b=AM6DYtgd2YjigL+LNkk2Z9mDvn4T90nKYgA7zGkSxf1Mxxvb9pQQd5e7zJIbMZLNNf SuXjKmtzMYejjDfrYz4FE7CupkxhY8ZW9zfg+8gX+YZsOchIHs/dgOErRlMpmdNnOK4K ZU4eMr78xSy61PIDYo+ww/KlCCnJLbBQdmRQSRccC4YMlhMl2+ajeRB4JqleQrbVmSXr kY1bMJTqK48/7MeyrqQGSWdxIcs9arS7yLVcajlkywt08/AK4lwGXi9GTcKObYkji6OQ uHE+UKqeTuPQxvpnrcfWjf4cjPSj6fkog5l6sVbfYWSNa5DuPy1xk+FhjlvIKvLKNxQf nYGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Kp04fuyGbOnbba367VBv7dpI+C4i+9EeiuSvFnk5Wi0=; b=mWIFoCzCWdCY2KiaqlNXB6lE84mTAGzT1VYygzE3ZfMvqnxjH4fpsm4eJGe+L0Acva GMomHdMRxSI4sQoN3MePPUm2xfu+nQy9UI43E55GC7NrtRZS3fF/gGYwch2lDLEZaKez 9oZMtIUwITu0GEybuBqUMPT7awvs9P4rYCiyNWg9dWo2Ezwclc2tK2KZpgudVYkusWh1 Z2i6XJe8ERFs3Ep/alWvlR//HwkyIZ2jSn9gAyRn7esQgLdpmzQ/LNWLKAQw3LsgoHGy XC3qHsKQIE5XU9un2BZ19hhMr373JZltOBLM2hZBxYwSk6Xeg5XBjJkS3u/yCgfQAFLU lAew== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c5-v6si17701026pgk.327.2018.09.03.10.26.36; Mon, 03 Sep 2018 10:26:51 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730142AbeICVpB (ORCPT + 99 others); Mon, 3 Sep 2018 17:45:01 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45436 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727516AbeICVpA (ORCPT ); Mon, 3 Sep 2018 17:45:00 -0400 Received: from localhost (ip-213-127-74-90.ip.prioritytelecom.net [213.127.74.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 4B2CFD24; Mon, 3 Sep 2018 17:23:53 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, John Hurley , Jakub Kicinski , "David S. Miller" , Sasha Levin Subject: [PATCH 4.14 062/165] nfp: flower: fix port metadata conversion bug Date: Mon, 3 Sep 2018 18:55:48 +0200 Message-Id: <20180903165658.230155897@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180903165655.003605184@linuxfoundation.org> References: <20180903165655.003605184@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: John Hurley [ Upstream commit ee614c871014045b45fae149b7245fc22a0bbdd8 ] Function nfp_flower_repr_get_type_and_port expects an enum nfp_repr_type return value but, if the repr type is unknown, returns a value of type enum nfp_flower_cmsg_port_type. This means that if FW encodes the port ID in a way the driver does not understand instead of dropping the frame driver may attribute it to a physical port (uplink) provided the port number is less than physical port count. Fix this and ensure a net_device of NULL is returned if the repr can not be determined. Fixes: 1025351a88a4 ("nfp: add flower app") Signed-off-by: John Hurley Signed-off-by: Jakub Kicinski Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/netronome/nfp/flower/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/net/ethernet/netronome/nfp/flower/main.c +++ b/drivers/net/ethernet/netronome/nfp/flower/main.c @@ -79,7 +79,7 @@ nfp_flower_repr_get_type_and_port(struct return NFP_REPR_TYPE_VF; } - return NFP_FLOWER_CMSG_PORT_TYPE_UNSPEC; + return __NFP_REPR_TYPE_MAX; } static struct net_device * @@ -90,6 +90,8 @@ nfp_flower_repr_get(struct nfp_app *app, u8 port = 0; repr_type = nfp_flower_repr_get_type_and_port(app, port_id, &port); + if (repr_type > NFP_REPR_TYPE_MAX) + return NULL; reprs = rcu_dereference(app->reprs[repr_type]); if (!reprs)