net: remove duplicate fetch in sock_getsockopt
authorJingYi Hou <houjingyi647@gmail.com>
Mon, 17 Jun 2019 06:56:05 +0000 (14:56 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 3 Jul 2019 11:16:01 +0000 (13:16 +0200)
commit9032157250fb1be76edd1aa8fe652c22da211690
treef1740d86cefbddd9c72ac05e5dc5f8a3ea2cb16e
parentdc948de356f4348cc8e65f0435ea82d12c1219d3
net: remove duplicate fetch in sock_getsockopt

[ Upstream commit d0bae4a0e3d8c5690a885204d7eb2341a5b4884d ]

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>
net/core/sock.c