netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] netfilter: ipset: Fix an error code in ip_set_sockfn_get()
@ 2019-08-21  7:18 Dan Carpenter
  2019-08-22  9:11 ` Kadlecsik József
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2019-08-21  7:18 UTC (permalink / raw)
  To: Pablo Neira Ayuso, Jozsef Kadlecsik
  Cc: Florian Westphal, Florent Fourcot, Kate Stewart, Allison Randal,
	Aditya Pakki, Qian Cai, Andrey Ryabinin, Johannes Berg,
	Stefano Brivio, netfilter-devel, coreteam, kernel-janitors

The copy_to_user() function returns the number of bytes remaining to be
copied.  In this code, that positive return is checked at the end of the
function and we return zero/success.  What we should do instead is
return -EFAULT.

Fixes: a7b4f989a629 ("netfilter: ipset: IP set core support")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 net/netfilter/ipset/ip_set_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
index e64d5f9a89dd..15b8d4318207 100644
--- a/net/netfilter/ipset/ip_set_core.c
+++ b/net/netfilter/ipset/ip_set_core.c
@@ -2129,7 +2129,8 @@ ip_set_sockfn_get(struct sock *sk, int optval, void __user *user, int *len)
 	}	/* end of switch(op) */
 
 copy:
-	ret = copy_to_user(user, data, copylen);
+	if (copy_to_user(user, data, copylen))
+		ret = -EFAULT;
 
 done:
 	vfree(data);
-- 
2.20.1


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

end of thread, other threads:[~2019-08-27 18:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-21  7:18 [PATCH] netfilter: ipset: Fix an error code in ip_set_sockfn_get() Dan Carpenter
2019-08-22  9:11 ` Kadlecsik József
2019-08-22  9:41   ` Dan Carpenter
2019-08-24 14:49   ` [PATCH v2] " Dan Carpenter
2019-08-27 18:21     ` 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).