fix double-fetch bug in sock_getsockopt()
Subsystems (3)
PATCH 1/1 fix double-fetch bug 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 without check.
if a malicious user can change it between two fetches may cause security problems or unexpected behaivor.
To fix this, we need to recheck it in the second fetch.
--- net/core/sock.c | 2 ++ 1 file changed, 2 insertions(+)
net/core/sock.c +2 -0
@@ -1479,6 +1479,8 @@ int sock_getsockopt(struct socket *sock, int level, int optname,if (get_user (len, optlen))return -EFAULT ; +if (len <0 ) +return -EINVAL ;sk_get_meminfo (sk, meminfo);
Signature · 1 line
2.20.1
David Miller
maintainerFrom: JingYi Hou <[email protected]>
Date: Thu, 13 Jun 2019 18:44:57 +0800
Quoted 10 lines
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 without check.if a malicious user can change it between two fetches may cause security problems or unexpected behaivor.
To fix this, we need to recheck it in the second fetch.
Signed-off-by JingYi Hou <[email protected]>
THere is no reason to fetch len a second time, so please just remove the get_user() call here instead.
Also, please format your Subject line properly with appropriate subsystem prefixes etc.