diff mbox series

[net] net: sched: initialize with 0 before setting erspan md->u

Message ID cf5da3ba7ceb318ced1555f42795fcebfb0b870f.1599997383.git.lucien.xin@gmail.com
State Accepted
Delegated to: David Miller
Headers show
Series [net] net: sched: initialize with 0 before setting erspan md->u | expand

Commit Message

Xin Long Sept. 13, 2020, 11:43 a.m. UTC
In fl_set_erspan_opt(), all bits of erspan md was set 1, as this
function is also used to set opt MASK. However, when setting for
md->u.index for opt VALUE, the rest bits of the union md->u will
be left 1. It would cause to fail the match of the whole md when
version is 1 and only index is set.

This patch is to fix by initializing with 0 before setting erspan
md->u.

Reported-by: Shuang Li <shuali@redhat.com>
Fixes: 79b1011cb33d ("net: sched: allow flower to match erspan options")
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 net/sched/cls_flower.c | 1 +
 1 file changed, 1 insertion(+)

Comments

David Miller Sept. 14, 2020, 11:54 p.m. UTC | #1
From: Xin Long <lucien.xin@gmail.com>
Date: Sun, 13 Sep 2020 19:43:03 +0800

> In fl_set_erspan_opt(), all bits of erspan md was set 1, as this
> function is also used to set opt MASK. However, when setting for
> md->u.index for opt VALUE, the rest bits of the union md->u will
> be left 1. It would cause to fail the match of the whole md when
> version is 1 and only index is set.
> 
> This patch is to fix by initializing with 0 before setting erspan
> md->u.
> 
> Reported-by: Shuang Li <shuali@redhat.com>
> Fixes: 79b1011cb33d ("net: sched: allow flower to match erspan options")
> Signed-off-by: Xin Long <lucien.xin@gmail.com>

Applied and queued up for -stable, thank you.
diff mbox series

Patch

diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
index a4f7ef1..19a8fa2 100644
--- a/net/sched/cls_flower.c
+++ b/net/sched/cls_flower.c
@@ -1221,6 +1221,7 @@  static int fl_set_erspan_opt(const struct nlattr *nla, struct fl_flow_key *key,
 		}
 		if (tb[TCA_FLOWER_KEY_ENC_OPT_ERSPAN_INDEX]) {
 			nla = tb[TCA_FLOWER_KEY_ENC_OPT_ERSPAN_INDEX];
+			memset(&md->u, 0x00, sizeof(md->u));
 			md->u.index = nla_get_be32(nla);
 		}
 	} else if (md->version == 2) {