From: Ursula Braun Date: Wed, 18 Jul 2018 13:22:50 +0000 (+0200) Subject: net/smc: add error handling for get_user() X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=ac0107edba253a6e58e923f9e68825decef3e681;p=people%2Fpauldu%2Flinux.git net/smc: add error handling for get_user() 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 Signed-off-by: Ursula Braun Signed-off-by: David S. Miller --- diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c index c12a7fc18f56..6e5479067db0 100644 --- a/net/smc/af_smc.c +++ b/net/smc/af_smc.c @@ -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) {