Skip to content

Commit

Permalink
net: remove duplicate fetch in sock_getsockopt
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
JingYi Hou authored and David S. Miller committed Jun 18, 2019
1 parent d0f84d0 commit d0bae4a
Showing 1 changed file with 0 additions and 3 deletions.
3 changes: 0 additions & 3 deletions net/core/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit d0bae4a

Please sign in to comment.