netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: check the return value of the copy_from_sockptr
@ 2024-09-11  5:04 Qianqiang Liu
  2024-09-11  6:51 ` D. Wythe
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Qianqiang Liu @ 2024-09-11  5:04 UTC (permalink / raw)
  To: xiyou.wangcong, davem, edumazet, kuba, pabeni
  Cc: netdev, linux-kernel, Qianqiang Liu

We must check the return value of the copy_from_sockptr. Otherwise, it
may cause some weird issues.

Signed-off-by: Qianqiang Liu <qianqiang.liu@163.com>
---
 net/socket.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/net/socket.c b/net/socket.c
index 0a2bd22ec105..6b9a414d01d5 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -2370,8 +2370,11 @@ int do_sock_getsockopt(struct socket *sock, bool compat, int level,
 	if (err)
 		return err;
 
-	if (!compat)
-		copy_from_sockptr(&max_optlen, optlen, sizeof(int));
+	if (!compat) {
+		err = copy_from_sockptr(&max_optlen, optlen, sizeof(int));
+		if (err)
+			return -EFAULT;
+	}
 
 	ops = READ_ONCE(sock->ops);
 	if (level == SOL_SOCKET) {
-- 
2.39.2


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

end of thread, other threads:[~2024-09-18 13:12 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-11  5:04 [PATCH] net: check the return value of the copy_from_sockptr Qianqiang Liu
2024-09-11  6:51 ` D. Wythe
2024-09-11  7:13 ` Eric Dumazet
2024-09-11  8:23   ` Qianqiang Liu
2024-09-11  9:12     ` Eric Dumazet
2024-09-11 10:24       ` Qianqiang Liu
2024-09-11 12:40         ` Eric Dumazet
2024-09-11 16:58       ` Cong Wang
2024-09-11 17:15         ` Eric Dumazet
2024-09-11 17:35           ` Cong Wang
2024-09-11 18:49             ` Stanislav Fomichev
2024-09-11 19:48               ` Cong Wang
2024-09-11 20:05                 ` Stanislav Fomichev
2024-09-14  0:49                   ` Cong Wang
2024-09-14 18:01                     ` Stanislav Fomichev
2024-09-18 13:11 ` David Laight

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