From: JingYi Hou <houjingyi647@gmail.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] fix double-fetch bug in sock_getsockopt()
Date: Thu, 13 Jun 2019 18:44:57 +0800 [thread overview]
Message-ID: <20190613104457.GA6296@hjy-HP-Notebook> (raw)
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 <houjingyi647@gmail.com>
---
net/core/sock.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/core/sock.c b/net/core/sock.c
index 2b3701958486..577780c935ee 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -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);
--
2.20.1
next reply other threads:[~2019-06-13 15:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-13 10:44 JingYi Hou [this message]
2019-06-15 20:32 ` [PATCH] fix double-fetch bug in sock_getsockopt() David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190613104457.GA6296@hjy-HP-Notebook \
--to=houjingyi647@gmail.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox