net: remove duplicate fetch in sock_getsockopt
[ Upstream commit d0bae4a0e3
]
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 <houjingyi647@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
dc948de356
commit
9032157250
@ -1358,9 +1358,6 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
|
|||||||
{
|
{
|
||||||
u32 meminfo[SK_MEMINFO_VARS];
|
u32 meminfo[SK_MEMINFO_VARS];
|
||||||
|
|
||||||
if (get_user(len, optlen))
|
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
sk_get_meminfo(sk, meminfo);
|
sk_get_meminfo(sk, meminfo);
|
||||||
|
|
||||||
len = min_t(unsigned int, len, sizeof(meminfo));
|
len = min_t(unsigned int, len, sizeof(meminfo));
|
||||||
|
Reference in New Issue
Block a user