From: JingYi Hou Date: Mon, 17 Jun 2019 06:56:05 +0000 (+0800) Subject: net: remove duplicate fetch in sock_getsockopt X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=d0bae4a0e3d8c5690a885204d7eb2341a5b4884d;p=linux.git net: remove duplicate fetch in sock_getsockopt In sock_getsockopt(), 'optlen' is fetched the first time from userspace. 'len < 0' is then checked. Then in condition 'SO_MEMINFO', 'optlen' is fetched the second time from userspace. If change it between two fetches may cause security problems or unexpected behaivor, and there is no reason to fetch it a second time. To fix this, we need to remove the second fetch. Signed-off-by: JingYi Hou Signed-off-by: David S. Miller --- diff --git a/net/core/sock.c b/net/core/sock.c index af09a23e48226..aa4a00d381e38 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -1477,9 +1477,6 @@ int sock_getsockopt(struct socket *sock, int level, int optname, { u32 meminfo[SK_MEMINFO_VARS]; - if (get_user(len, optlen)) - return -EFAULT; - sk_get_meminfo(sk, meminfo); len = min_t(unsigned int, len, sizeof(meminfo));