All of lore.kernel.org
 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; 3+ 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] 3+ messages in thread

* Re: [PATCH] [v2] netfilter: ipset: fix a missing check of nla_parse
  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
  0 siblings, 0 replies; 3+ messages in thread
From: Kadlecsik József @ 2019-01-08 20:01 UTC (permalink / raw)
  To: Aditya Pakki
  Cc: kjlu, Pablo Neira Ayuso, Florian Westphal, David S. Miller,
	Kirill Tkhai, Stefano Brivio, Gustavo A. R. Silva,
	Andrey Ryabinin, netfilter-devel, coreteam, netdev, linux-kernel

Hi,

On Sat, 5 Jan 2019, Aditya Pakki wrote:

> 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.

Patch is applied in the ipset git tree, thanks!

Best regards,
Jozsef

> 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
> 
> 

--
E-mail : kadlecsik.jozsef@wigner.mta.hu
PGP key: http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address: Wigner Research Centre for Physics, Hungarian Academy of Sciences
         H-1525 Budapest 114, POB. 49, Hungary

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

* Re: [PATCH] [v2] netfilter: ipset: fix a missing check of nla_parse
@ 2019-01-08 20:01   ` Kadlecsik József
  0 siblings, 0 replies; 3+ messages in thread
From: Kadlecsik József @ 2019-01-08 20:01 UTC (permalink / raw)
  To: Aditya Pakki
  Cc: kjlu, Pablo Neira Ayuso, Florian Westphal, David S. Miller,
	Kirill Tkhai, Stefano Brivio, Gustavo A. R. Silva,
	Andrey Ryabinin, netfilter-devel, coreteam, netdev, linux-kernel

Hi,

On Sat, 5 Jan 2019, Aditya Pakki wrote:

> 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.

Patch is applied in the ipset git tree, thanks!

Best regards,
Jozsef

> 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	[flat|nested] 3+ messages in thread

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

Thread overview: 3+ 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
2019-01-08 20:01   ` Kadlecsik József

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.