From: Jens Axboe <axboe@kernel.dk>
To: Eric Dumazet <edumazet@google.com>,
"David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org, eric.dumazet@gmail.com,
syzbot <syzkaller@googlegroups.com>
Subject: Re: [PATCH net] net: clear msg_get_inq in __sys_recvfrom() and __copy_msghdr_from_user()
Date: Wed, 22 Jun 2022 09:24:38 -0600 [thread overview]
Message-ID: <4d281429-8ac0-c85b-5f8d-3f6fc925d9b7@kernel.dk> (raw)
In-Reply-To: <20220622150220.1091182-1-edumazet@google.com>
On 6/22/22 9:02 AM, Eric Dumazet wrote:
> syzbot reported uninit-value in tcp_recvmsg() [1]
>
> Issue here is that msg->msg_get_inq should have been cleared,
> otherwise tcp_recvmsg() might read garbage and perform
> more work than needed, or have undefined behavior.
>
> Given CONFIG_INIT_STACK_ALL_ZERO=y is probably going to be
> the default soon, I chose to change __sys_recvfrom() to clear
> all fields but msghdr.addr which might be not NULL.
>
> For __copy_msghdr_from_user(), I added an explicit clear
> of kmsg->msg_get_inq.
>
> [1]
> BUG: KMSAN: uninit-value in tcp_recvmsg+0x6cf/0xb60 net/ipv4/tcp.c:2557
> tcp_recvmsg+0x6cf/0xb60 net/ipv4/tcp.c:2557
> inet_recvmsg+0x13a/0x5a0 net/ipv4/af_inet.c:850
> sock_recvmsg_nosec net/socket.c:995 [inline]
> sock_recvmsg net/socket.c:1013 [inline]
> __sys_recvfrom+0x696/0x900 net/socket.c:2176
> __do_sys_recvfrom net/socket.c:2194 [inline]
> __se_sys_recvfrom net/socket.c:2190 [inline]
> __x64_sys_recvfrom+0x122/0x1c0 net/socket.c:2190
> do_syscall_x64 arch/x86/entry/common.c:50 [inline]
> do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
> entry_SYSCALL_64_after_hwframe+0x46/0xb0
>
> Local variable msg created at:
> __sys_recvfrom+0x81/0x900 net/socket.c:2154
> __do_sys_recvfrom net/socket.c:2194 [inline]
> __se_sys_recvfrom net/socket.c:2190 [inline]
> __x64_sys_recvfrom+0x122/0x1c0 net/socket.c:2190
>
> CPU: 0 PID: 3493 Comm: syz-executor170 Not tainted 5.19.0-rc3-syzkaller-30868-g4b28366af7d9 #0
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Thanks Eric, looks good to me:
Reviewed-by: Jens Axboe <axboe@kernel.dk>
--
Jens Axboe
next prev parent reply other threads:[~2022-06-22 15:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-22 15:02 [PATCH net] net: clear msg_get_inq in __sys_recvfrom() and __copy_msghdr_from_user() Eric Dumazet
2022-06-22 15:24 ` Jens Axboe [this message]
2022-06-23 4:42 ` Eric Dumazet
2022-06-24 4:20 ` patchwork-bot+netdevbpf
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=4d281429-8ac0-c85b-5f8d-3f6fc925d9b7@kernel.dk \
--to=axboe@kernel.dk \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eric.dumazet@gmail.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=syzkaller@googlegroups.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.