提交 43a5e00f 编写于 作者: F Florian Fainelli 提交者: David S. Miller

net: dsa: bcm_sf2: Fix RX_CLS_LOC_ANY overwrite for last rule

When we let the kernel pick up a rule location with RX_CLS_LOC_ANY, we
would be able to overwrite the last rules because of a number of issues.

The IPv4 code path would not be checking that rule_index is within
bounds, and it would also only be allowed to pick up rules from range
0..126 instead of the full 0..127 range. This would lead us to allow
overwriting the last rule when we let the kernel pick-up the location.

Fixes: 33061458 ("net: dsa: bcm_sf2: Move IPv4 CFP processing to specific functions")
Signed-off-by: NFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 e1b505a6
...@@ -354,10 +354,13 @@ static int bcm_sf2_cfp_ipv4_rule_set(struct bcm_sf2_priv *priv, int port, ...@@ -354,10 +354,13 @@ static int bcm_sf2_cfp_ipv4_rule_set(struct bcm_sf2_priv *priv, int port,
/* Locate the first rule available */ /* Locate the first rule available */
if (fs->location == RX_CLS_LOC_ANY) if (fs->location == RX_CLS_LOC_ANY)
rule_index = find_first_zero_bit(priv->cfp.used, rule_index = find_first_zero_bit(priv->cfp.used,
bcm_sf2_cfp_rule_size(priv)); priv->num_cfp_rules);
else else
rule_index = fs->location; rule_index = fs->location;
if (rule_index > bcm_sf2_cfp_rule_size(priv))
return -ENOSPC;
layout = &udf_tcpip4_layout; layout = &udf_tcpip4_layout;
/* We only use one UDF slice for now */ /* We only use one UDF slice for now */
slice_num = bcm_sf2_get_slice_number(layout, 0); slice_num = bcm_sf2_get_slice_number(layout, 0);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册