Hi Dan,
On Wed, 21 Aug 2019, Dan Carpenter wrote:
> 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.
Yes, you are right. There's another usage of copy_to_user() in this
function, could you fix it as well?
Best regards,
Jozsef
> Fixes: a7b4f989a629 ("netfilter: ipset: IP set core support")
> Signed-off-by: Dan Carpenter <[email protected]>
> ---
> 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
>
>
-
E-mail : [email protected], [email protected]
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