netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: remove duplicate fetch in sock_getsockopt
@ 2019-06-17  6:56 JingYi Hou
  2019-06-18 17:04 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: JingYi Hou @ 2019-06-17  6:56 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-kernel

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>
---
 net/core/sock.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/net/core/sock.c b/net/core/sock.c
index 2b3701958486..932bcbf2d565 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));
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] net: remove duplicate fetch in sock_getsockopt
  2019-06-17  6:56 [PATCH] net: remove duplicate fetch in sock_getsockopt JingYi Hou
@ 2019-06-18 17:04 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2019-06-18 17:04 UTC (permalink / raw)
  To: houjingyi647; +Cc: netdev, linux-kernel

From: JingYi Hou <houjingyi647@gmail.com>
Date: Mon, 17 Jun 2019 14:56:05 +0800

> 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>

Applied and queued up for -stable, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-06-18 17:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-17  6:56 [PATCH] net: remove duplicate fetch in sock_getsockopt JingYi Hou
2019-06-18 17:04 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).