[Devel] [PATCH RH7 2/6] ms/netfilter: ipset: fix a missing check of nla_parse

Vasily Averin vvs at virtuozzo.com
Tue Dec 1 11:47:01 MSK 2020


From: Aditya Pakki <pakki001 at umn.edu>

When nla_parse fails, we should not use the results (the first
argument). The fix checks if it fails, and if so, returns its error code
upstream.

Signed-off-by: Aditya Pakki <pakki001 at umn.edu>
Signed-off-by: Jozsef Kadlecsik <kadlec at blackhole.kfki.hu>

(cherry-picked from commit f4f5748bfec94cf418e49bf05f0c81a1b9ebc95)
VvS: replaced original nla_parse_deprecated() by nla_parse()
https://jira.sw.ru/browse/PSBM-122965
Signed-off-by: Vasily Averin <vvs at virtuozzo.com>
---
 net/netfilter/ipset/ip_set_core.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
index 6ef5898..d5344e5 100644
--- a/net/netfilter/ipset/ip_set_core.c
+++ b/net/netfilter/ipset/ip_set_core.c
@@ -1542,10 +1542,14 @@ call_ad(struct sock *ctnl, struct sk_buff *skb, struct ip_set *set,
 		memcpy(&errmsg->msg, nlh, nlh->nlmsg_len);
 		cmdattr = (void *)&errmsg->msg + min_len;
 
-		nla_parse(cda, IPSET_ATTR_CMD_MAX,
+		ret = nla_parse(cda, IPSET_ATTR_CMD_MAX,
 			  cmdattr, nlh->nlmsg_len - min_len,
 			  ip_set_adt_policy);
 
+		if (ret) {
+			nlmsg_free(skb2);
+			return ret;
+		}
 		errline = nla_data(cda[IPSET_ATTR_LINENO]);
 
 		*errline = lineno;
-- 
1.8.3.1



More information about the Devel mailing list