netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [v2] netfilter: ipset: fix a missing check of nla_parse
@ 2019-01-05 15:31 Aditya Pakki
  2019-01-08 20:01 ` Kadlecsik József
  0 siblings, 1 reply; 2+ messages in thread
From: Aditya Pakki @ 2019-01-05 15:31 UTC (permalink / raw)
  To: pakki001
  Cc: kjlu, Pablo Neira Ayuso, Jozsef Kadlecsik, Florian Westphal,
	David S. Miller, Kirill Tkhai, Stefano Brivio,
	Gustavo A. R. Silva, Andrey Ryabinin, netfilter-devel, coreteam,
	netdev, linux-kernel

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@umn.edu>
---
 net/netfilter/ipset/ip_set_core.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
index 45a257695bef..3ee0fda05a3b 100644
--- a/net/netfilter/ipset/ip_set_core.c
+++ b/net/netfilter/ipset/ip_set_core.c
@@ -1546,8 +1546,13 @@ 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, cmdattr,
-			  nlh->nlmsg_len - min_len, ip_set_adt_policy, NULL);
+		ret = nla_parse(cda, IPSET_ATTR_CMD_MAX, cmdattr,
+				nlh->nlmsg_len - min_len, ip_set_adt_policy,
+				NULL);
+		if (ret) {
+			nlmsg_free(skb2);
+			return ret;
+		}
 
 		errline = nla_data(cda[IPSET_ATTR_LINENO]);
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-01-08 20:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-05 15:31 [PATCH] [v2] netfilter: ipset: fix a missing check of nla_parse Aditya Pakki
2019-01-08 20:01 ` Kadlecsik József

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).