Patchwork [v2,3/4] neigh: disallow un-init_net to change thresh of neigh

login
register
mail settings
Submitter Gao feng
Date June 14, 2013, 2:06 a.m.
Message ID <1371175607-1405-3-git-send-email-gaofeng@cn.fujitsu.com>
Download mbox | patch
Permalink /patch/251204/
State Changes Requested
Delegated to: David Miller
Headers show

Comments

Gao feng - June 14, 2013, 2:06 a.m.
thresh and interval are global resources,
only init net can change them.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
---
 net/core/neighbour.c | 6 ++++++
 1 file changed, 6 insertions(+)

Patch

diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 2ec1faf..5e0fe89 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -2049,6 +2049,12 @@  static int neightbl_set(struct sk_buff *skb, struct nlmsghdr *nlh)
 		}
 	}
 
+	err = -ENOENT;
+	if ((tb[NDTA_THRESH1] || tb[NDTA_THRESH2] ||
+	     tb[NDTA_THRESH3] || tb[NDTA_GC_INTERVAL]) &&
+	    !net_eq(net, &init_net))
+		goto errout_tbl_lock;
+
 	if (tb[NDTA_THRESH1])
 		tbl->gc_thresh1 = nla_get_u32(tb[NDTA_THRESH1]);