aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/core/fib_rules.c8
-rw-r--r--net/core/rtnetlink.c9
-rw-r--r--net/decnet/dn_rules.c2
-rw-r--r--net/ipv4/devinet.c2
-rw-r--r--net/ipv4/fib_frontend.c2
-rw-r--r--net/ipv4/fib_rules.c2
-rw-r--r--net/ipv6/fib6_rules.c6
-rw-r--r--net/ipv6/route.c2
-rw-r--r--net/netlink/genetlink.c10
9 files changed, 17 insertions, 26 deletions
diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c
index 7b2e9bb1a605..a99d87d82b7f 100644
--- a/net/core/fib_rules.c
+++ b/net/core/fib_rules.c
@@ -161,9 +161,6 @@ int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
161 if (err < 0) 161 if (err < 0)
162 goto errout; 162 goto errout;
163 163
164 if (tb[FRA_IFNAME] && nla_len(tb[FRA_IFNAME]) > IFNAMSIZ)
165 goto errout;
166
167 rule = kzalloc(ops->rule_size, GFP_KERNEL); 164 rule = kzalloc(ops->rule_size, GFP_KERNEL);
168 if (rule == NULL) { 165 if (rule == NULL) {
169 err = -ENOMEM; 166 err = -ENOMEM;
@@ -177,10 +174,7 @@ int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
177 struct net_device *dev; 174 struct net_device *dev;
178 175
179 rule->ifindex = -1; 176 rule->ifindex = -1;
180 if (nla_strlcpy(rule->ifname, tb[FRA_IFNAME], 177 nla_strlcpy(rule->ifname, tb[FRA_IFNAME], IFNAMSIZ);
181 IFNAMSIZ) >= IFNAMSIZ)
182 goto errout_free;
183
184 dev = __dev_get_by_name(rule->ifname); 178 dev = __dev_get_by_name(rule->ifname);
185 if (dev) 179 if (dev)
186 rule->ifindex = dev->ifindex; 180 rule->ifindex = dev->ifindex;
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 8f225499e32e..0ebcf8488e99 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -371,8 +371,8 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
371} 371}
372 372
373static struct nla_policy ifla_policy[IFLA_MAX+1] __read_mostly = { 373static struct nla_policy ifla_policy[IFLA_MAX+1] __read_mostly = {
374 [IFLA_IFNAME] = { .type = NLA_STRING }, 374 [IFLA_IFNAME] = { .type = NLA_STRING, .len = IFNAMSIZ-1 },
375 [IFLA_MAP] = { .minlen = sizeof(struct rtnl_link_ifmap) }, 375 [IFLA_MAP] = { .len = sizeof(struct rtnl_link_ifmap) },
376 [IFLA_MTU] = { .type = NLA_U32 }, 376 [IFLA_MTU] = { .type = NLA_U32 },
377 [IFLA_TXQLEN] = { .type = NLA_U32 }, 377 [IFLA_TXQLEN] = { .type = NLA_U32 },
378 [IFLA_WEIGHT] = { .type = NLA_U32 }, 378 [IFLA_WEIGHT] = { .type = NLA_U32 },
@@ -392,9 +392,8 @@ static int rtnl_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
392 if (err < 0) 392 if (err < 0)
393 goto errout; 393 goto errout;
394 394
395 if (tb[IFLA_IFNAME] && 395 if (tb[IFLA_IFNAME])
396 nla_strlcpy(ifname, tb[IFLA_IFNAME], IFNAMSIZ) >= IFNAMSIZ) 396 nla_strlcpy(ifname, tb[IFLA_IFNAME], IFNAMSIZ);
397 return -EINVAL;
398 397
399 err = -EINVAL; 398 err = -EINVAL;
400 ifm = nlmsg_data(nlh); 399 ifm = nlmsg_data(nlh);
diff --git a/net/decnet/dn_rules.c b/net/decnet/dn_rules.c
index 63ad63dfd252..3e0c882c90bf 100644
--- a/net/decnet/dn_rules.c
+++ b/net/decnet/dn_rules.c
@@ -112,7 +112,7 @@ errout:
112} 112}
113 113
114static struct nla_policy dn_fib_rule_policy[FRA_MAX+1] __read_mostly = { 114static struct nla_policy dn_fib_rule_policy[FRA_MAX+1] __read_mostly = {
115 [FRA_IFNAME] = { .type = NLA_STRING }, 115 [FRA_IFNAME] = { .type = NLA_STRING, .len = IFNAMSIZ - 1 },
116 [FRA_PRIORITY] = { .type = NLA_U32 }, 116 [FRA_PRIORITY] = { .type = NLA_U32 },
117 [FRA_SRC] = { .type = NLA_U16 }, 117 [FRA_SRC] = { .type = NLA_U16 },
118 [FRA_DST] = { .type = NLA_U16 }, 118 [FRA_DST] = { .type = NLA_U16 },
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 0487677729cf..8e8d1f17d77a 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -85,7 +85,7 @@ static struct nla_policy ifa_ipv4_policy[IFA_MAX+1] __read_mostly = {
85 [IFA_ADDRESS] = { .type = NLA_U32 }, 85 [IFA_ADDRESS] = { .type = NLA_U32 },
86 [IFA_BROADCAST] = { .type = NLA_U32 }, 86 [IFA_BROADCAST] = { .type = NLA_U32 },
87 [IFA_ANYCAST] = { .type = NLA_U32 }, 87 [IFA_ANYCAST] = { .type = NLA_U32 },
88 [IFA_LABEL] = { .type = NLA_STRING }, 88 [IFA_LABEL] = { .type = NLA_STRING, .len = IFNAMSIZ - 1 },
89}; 89};
90 90
91static void rtmsg_ifa(int event, struct in_ifaddr *, struct nlmsghdr *, u32); 91static void rtmsg_ifa(int event, struct in_ifaddr *, struct nlmsghdr *, u32);
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index d0abeab16e66..cfb527c060e4 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -462,7 +462,7 @@ struct nla_policy rtm_ipv4_policy[RTA_MAX+1] __read_mostly = {
462 [RTA_PRIORITY] = { .type = NLA_U32 }, 462 [RTA_PRIORITY] = { .type = NLA_U32 },
463 [RTA_PREFSRC] = { .type = NLA_U32 }, 463 [RTA_PREFSRC] = { .type = NLA_U32 },
464 [RTA_METRICS] = { .type = NLA_NESTED }, 464 [RTA_METRICS] = { .type = NLA_NESTED },
465 [RTA_MULTIPATH] = { .minlen = sizeof(struct rtnexthop) }, 465 [RTA_MULTIPATH] = { .len = sizeof(struct rtnexthop) },
466 [RTA_PROTOINFO] = { .type = NLA_U32 }, 466 [RTA_PROTOINFO] = { .type = NLA_U32 },
467 [RTA_FLOW] = { .type = NLA_U32 }, 467 [RTA_FLOW] = { .type = NLA_U32 },
468 [RTA_MP_ALGO] = { .type = NLA_U32 }, 468 [RTA_MP_ALGO] = { .type = NLA_U32 },
diff --git a/net/ipv4/fib_rules.c b/net/ipv4/fib_rules.c
index 280f424ca9c9..52b2adae4f22 100644
--- a/net/ipv4/fib_rules.c
+++ b/net/ipv4/fib_rules.c
@@ -179,7 +179,7 @@ static struct fib_table *fib_empty_table(void)
179} 179}
180 180
181static struct nla_policy fib4_rule_policy[FRA_MAX+1] __read_mostly = { 181static struct nla_policy fib4_rule_policy[FRA_MAX+1] __read_mostly = {
182 [FRA_IFNAME] = { .type = NLA_STRING }, 182 [FRA_IFNAME] = { .type = NLA_STRING, .len = IFNAMSIZ - 1 },
183 [FRA_PRIORITY] = { .type = NLA_U32 }, 183 [FRA_PRIORITY] = { .type = NLA_U32 },
184 [FRA_SRC] = { .type = NLA_U32 }, 184 [FRA_SRC] = { .type = NLA_U32 },
185 [FRA_DST] = { .type = NLA_U32 }, 185 [FRA_DST] = { .type = NLA_U32 },
diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c
index 2fbc71d90187..34f5bfaddfc2 100644
--- a/net/ipv6/fib6_rules.c
+++ b/net/ipv6/fib6_rules.c
@@ -137,10 +137,10 @@ static int fib6_rule_match(struct fib_rule *rule, struct flowi *fl, int flags)
137} 137}
138 138
139static struct nla_policy fib6_rule_policy[FRA_MAX+1] __read_mostly = { 139static struct nla_policy fib6_rule_policy[FRA_MAX+1] __read_mostly = {
140 [FRA_IFNAME] = { .type = NLA_STRING }, 140 [FRA_IFNAME] = { .type = NLA_STRING, .len = IFNAMSIZ - 1 },
141 [FRA_PRIORITY] = { .type = NLA_U32 }, 141 [FRA_PRIORITY] = { .type = NLA_U32 },
142 [FRA_SRC] = { .minlen = sizeof(struct in6_addr) }, 142 [FRA_SRC] = { .len = sizeof(struct in6_addr) },
143 [FRA_DST] = { .minlen = sizeof(struct in6_addr) }, 143 [FRA_DST] = { .len = sizeof(struct in6_addr) },
144 [FRA_FWMARK] = { .type = NLA_U32 }, 144 [FRA_FWMARK] = { .type = NLA_U32 },
145 [FRA_FWMASK] = { .type = NLA_U32 }, 145 [FRA_FWMASK] = { .type = NLA_U32 },
146 [FRA_TABLE] = { .type = NLA_U32 }, 146 [FRA_TABLE] = { .type = NLA_U32 },
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index ba1b3d11865e..75f4bb9611ce 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1865,7 +1865,7 @@ void rt6_mtu_change(struct net_device *dev, unsigned mtu)
1865} 1865}
1866 1866
1867static struct nla_policy rtm_ipv6_policy[RTA_MAX+1] __read_mostly = { 1867static struct nla_policy rtm_ipv6_policy[RTA_MAX+1] __read_mostly = {
1868 [RTA_GATEWAY] = { .minlen = sizeof(struct in6_addr) }, 1868 [RTA_GATEWAY] = { .len = sizeof(struct in6_addr) },
1869 [RTA_OIF] = { .type = NLA_U32 }, 1869 [RTA_OIF] = { .type = NLA_U32 },
1870 [RTA_IIF] = { .type = NLA_U32 }, 1870 [RTA_IIF] = { .type = NLA_U32 },
1871 [RTA_PRIORITY] = { .type = NLA_U32 }, 1871 [RTA_PRIORITY] = { .type = NLA_U32 },
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
index d32599116c56..3ac942cdb677 100644
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
@@ -455,7 +455,8 @@ static struct sk_buff *ctrl_build_msg(struct genl_family *family, u32 pid,
455 455
456static struct nla_policy ctrl_policy[CTRL_ATTR_MAX+1] __read_mostly = { 456static struct nla_policy ctrl_policy[CTRL_ATTR_MAX+1] __read_mostly = {
457 [CTRL_ATTR_FAMILY_ID] = { .type = NLA_U16 }, 457 [CTRL_ATTR_FAMILY_ID] = { .type = NLA_U16 },
458 [CTRL_ATTR_FAMILY_NAME] = { .type = NLA_STRING }, 458 [CTRL_ATTR_FAMILY_NAME] = { .type = NLA_NUL_STRING,
459 .len = GENL_NAMSIZ - 1 },
459}; 460};
460 461
461static int ctrl_getfamily(struct sk_buff *skb, struct genl_info *info) 462static int ctrl_getfamily(struct sk_buff *skb, struct genl_info *info)
@@ -470,12 +471,9 @@ static int ctrl_getfamily(struct sk_buff *skb, struct genl_info *info)
470 } 471 }
471 472
472 if (info->attrs[CTRL_ATTR_FAMILY_NAME]) { 473 if (info->attrs[CTRL_ATTR_FAMILY_NAME]) {
473 char name[GENL_NAMSIZ]; 474 char *name;
474
475 if (nla_strlcpy(name, info->attrs[CTRL_ATTR_FAMILY_NAME],
476 GENL_NAMSIZ) >= GENL_NAMSIZ)
477 goto errout;
478 475
476 name = nla_data(info->attrs[CTRL_ATTR_FAMILY_NAME]);
479 res = genl_family_find_byname(name); 477 res = genl_family_find_byname(name);
480 } 478 }
481 479