* [PATCH v2] net: initialize msg.msg_flags in recvfrom
@ 2017-03-08 17:08 Alexander Potapenko
2017-03-10 1:21 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Alexander Potapenko @ 2017-03-08 17:08 UTC (permalink / raw)
To: dvyukov, kcc, edumazet, davem; +Cc: linux-kernel, netdev
KMSAN reports a use of uninitialized memory in put_cmsg() because
msg.msg_flags in recvfrom haven't been initialized properly.
The flag values don't affect the result on this path, but it's still a
good idea to initialize them explicitly.
Signed-off-by: Alexander Potapenko <glider@google.com>
---
Changes since v1:
- removed KMSAN report and reproducer from the description
---
net/socket.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/socket.c b/net/socket.c
index 2c1e8677ff2d..e0757e648c0c 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -1731,6 +1731,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
/* We assume all kernel code knows the size of sockaddr_storage */
msg.msg_namelen = 0;
msg.msg_iocb = NULL;
+ msg.msg_flags = 0;
if (sock->file->f_flags & O_NONBLOCK)
flags |= MSG_DONTWAIT;
err = sock_recvmsg(sock, &msg, flags);
--
2.12.0.246.ga2ecc84866-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] net: initialize msg.msg_flags in recvfrom
2017-03-08 17:08 [PATCH v2] net: initialize msg.msg_flags in recvfrom Alexander Potapenko
@ 2017-03-10 1:21 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2017-03-10 1:21 UTC (permalink / raw)
To: glider; +Cc: dvyukov, kcc, edumazet, linux-kernel, netdev
From: Alexander Potapenko <glider@google.com>
Date: Wed, 8 Mar 2017 18:08:16 +0100
> KMSAN reports a use of uninitialized memory in put_cmsg() because
> msg.msg_flags in recvfrom haven't been initialized properly.
> The flag values don't affect the result on this path, but it's still a
> good idea to initialize them explicitly.
>
> Signed-off-by: Alexander Potapenko <glider@google.com>
> ---
> Changes since v1:
> - removed KMSAN report and reproducer from the description
Applied, thank you.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-03-10 1:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-08 17:08 [PATCH v2] net: initialize msg.msg_flags in recvfrom Alexander Potapenko
2017-03-10 1:21 ` 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).