net/smc: add error handling for get_user()
authorUrsula Braun <ursula.braun@linux.ibm.com>
Wed, 18 Jul 2018 13:22:50 +0000 (15:22 +0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 18 Jul 2018 17:58:27 +0000 (10:58 -0700)
For security reasons the return code of get_user() should always be
checked.

Fixes: 01d2f7e2cdd31 ("net/smc: sockopts TCP_NODELAY and TCP_CORK")
Reported-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Ursula Braun <ubraun@linux.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/smc/af_smc.c

index c12a7fc18f56da4d70f0c767b239bf09cfa220a3..6e5479067db0c8ef82e780c56b0e81e06bc70d7f 100644 (file)
@@ -1456,7 +1456,8 @@ static int smc_setsockopt(struct socket *sock, int level, int optname,
 
        if (optlen < sizeof(int))
                return -EINVAL;
-       get_user(val, (int __user *)optval);
+       if (get_user(val, (int __user *)optval))
+               return -EFAULT;
 
        lock_sock(sk);
        switch (optname) {