Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3702178imu; Mon, 28 Jan 2019 09:17:27 -0800 (PST) X-Google-Smtp-Source: ALg8bN44CIVApy+RdM4wIGXDl1RFEDfTrRcsnpXOY9dj929hAq9bcLlQNGk5db1IVhOFySimaiwp X-Received: by 2002:a62:798f:: with SMTP id u137mr22866285pfc.168.1548695847012; Mon, 28 Jan 2019 09:17:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548695846; cv=none; d=google.com; s=arc-20160816; b=sulZcyIHR8FmGAOwU6uNBT/St7UKXTbTw11/YhEHfYjrgHgEGsiyu90gKp83ubtpKB FPPydT738RE6JDE7rU8vAJzeKOZVEMn4Ap6Skc/uy1rI7bQJf0jUH99t2BLlcWpcJw55 TgE7Up58eXyHD4AgoCBxAhcPfeD7YCz77/YwT01GT2dvEIFcu/EaG8LCfaTFrbiOz9mI GtaoBXWpUMbQzJYX+4jnPai3tG9Ovu6GcIA+SyXFQUWLsCmn8vhqvni1nS5eIRISZH/h AlsKfntNeaHL5cu4+A8veB9u84M1BrZ941Pvu+XJPlOgoICXYgHurPXNs/q7ztMzvOmS HDaQ== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2VibUKQJz6sye8qBEPnDe9MkSPGGOPFCwDcQll5FIPM=; b=Su1dAtRvyKYVuPkE8i/RCjKviJ4cKvlE/XBIj277gUef3GWTC2rW2msEvLLyzKBg6Z xyySgqI8aS/cWSJUJLlVl8ohBMbm+RkK4sSYuRste2+PS4+tAwl5nu4oKpEH6UtemqBi j6E/3KZ87J91F3EvJEoD+75nzgQ84I0H3wZHJiwyiNMnVh6KfqSluXd3ofmMHWeMqNBh rnE8xRf3hRx9gCIV2HmHHWr5c6N0ehVXQSq1qWkdRM8ZGBMEgt3jeXU25x1QUNCnnfnK RRzE0OEV/4Rfzm7m5QJNf+SITx/B3j9bS4FydXdhP2Qt9Mivqmy2zz6ug9mSEHNMaUSW 2TtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vO2ccZpY; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k26si3054555pgb.72.2019.01.28.09.17.11; Mon, 28 Jan 2019 09:17:26 -0800 (PST) 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=@kernel.org header.s=default header.b=vO2ccZpY; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730670AbfA1QGH (ORCPT + 99 others); Mon, 28 Jan 2019 11:06:07 -0500 Received: from mail.kernel.org ([198.145.29.99]:54154 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731469AbfA1QGF (ORCPT ); Mon, 28 Jan 2019 11:06:05 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D24542147A; Mon, 28 Jan 2019 16:06:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691564; bh=RoBQAU8TVZYQgxtYRK5Pzr23g+VjWa5ktoRyXdwpbTk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vO2ccZpYIRKdRICCH9J/EHCznwrl5YKMzxhSy+lUKWRJzDx75w/JzNnWIrwiPJ/3w Ml8Ivj9pRMnZGlPWHJ1wFkwhS062izXUrjgop0w9HmDDd9o95DEb2tMDEFuBqv6Bp0 KL0+BXYbvqoRUXTIPo7CVgqvMoYokuWRoVp3QPEE= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Nir Dotan , Ido Schimmel , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 143/258] mlxsw: spectrum_acl: Limit priority value Date: Mon, 28 Jan 2019 10:57:29 -0500 Message-Id: <20190128155924.51521-143-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nir Dotan [ Upstream commit d7263ab35be25505ab57ebecd93cbc5dba8be717 ] In Spectrum-2, higher priority value wins and priority valid values are in the range of {1,cap_kvd_size-1}. mlxsw_sp_acl_tcam_priority_get converts from lower-bound priorities alike tc flower to Spectrum-2 HW range. Up until now tc flower did not provide priority 0 or reached the maximal value, however multicast routing does provide priority 0. Therefore, Change mlxsw_sp_acl_tcam_priority_get to verify priority is in the correct range. Make sure priority is never set to zero and never exceeds the maximal allowed value. Signed-off-by: Nir Dotan Reviewed-by: Jiri Pirko Signed-off-by: Ido Schimmel Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c index e171513bb32a..30931a2c025b 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c @@ -95,8 +95,9 @@ int mlxsw_sp_acl_tcam_priority_get(struct mlxsw_sp *mlxsw_sp, if (!MLXSW_CORE_RES_VALID(mlxsw_sp->core, KVD_SIZE)) return -EIO; - max_priority = MLXSW_CORE_RES_GET(mlxsw_sp->core, KVD_SIZE); - if (rulei->priority > max_priority) + /* Priority range is 1..cap_kvd_size-1. */ + max_priority = MLXSW_CORE_RES_GET(mlxsw_sp->core, KVD_SIZE) - 1; + if (rulei->priority >= max_priority) return -EINVAL; /* Unlike in TC, in HW, higher number means higher priority. */ -- 2.19.1