From: Ying Xue <ying.xue@windriver.com> To: <netdev@vger.kernel.org> Cc: syzkaller-bugs@googlegroups.com, tipc-discussion@lists.sourceforge.net Subject: [net 1/6] tipc: fix uninit-value in in tipc_conn_rcv_sub Date: Mon, 14 Jan 2019 17:22:24 +0800 [thread overview] Message-ID: <1547457749-24831-2-git-send-email-ying.xue@windriver.com> (raw) In-Reply-To: <1547457749-24831-1-git-send-email-ying.xue@windriver.com> syzbot reported: BUG: KMSAN: uninit-value in tipc_conn_rcv_sub+0x184/0x950 net/tipc/topsrv.c:373 CPU: 0 PID: 66 Comm: kworker/u4:4 Not tainted 4.17.0-rc3+ #88 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: tipc_rcv tipc_conn_recv_work Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x185/0x1d0 lib/dump_stack.c:113 kmsan_report+0x142/0x240 mm/kmsan/kmsan.c:1067 __msan_warning_32+0x6c/0xb0 mm/kmsan/kmsan_instr.c:683 tipc_conn_rcv_sub+0x184/0x950 net/tipc/topsrv.c:373 tipc_conn_rcv_from_sock net/tipc/topsrv.c:409 [inline] tipc_conn_recv_work+0x3cd/0x560 net/tipc/topsrv.c:424 process_one_work+0x12c6/0x1f60 kernel/workqueue.c:2145 worker_thread+0x113c/0x24f0 kernel/workqueue.c:2279 kthread+0x539/0x720 kernel/kthread.c:239 ret_from_fork+0x35/0x40 arch/x86/entry/entry_64.S:412 Local variable description: ----s.i@tipc_conn_recv_work Variable was created at: tipc_conn_recv_work+0x65/0x560 net/tipc/topsrv.c:419 process_one_work+0x12c6/0x1f60 kernel/workqueue.c:2145 In tipc_conn_rcv_from_sock(), it always supposes the length of message received from sock_recvmsg() is not smaller than the size of struct tipc_subscr. However, this assumption is false. Especially when the length of received message is shorter than struct tipc_subscr size, we will end up touching uninitialized fields in tipc_conn_rcv_sub(). Reported-by: syzbot+8951a3065ee7fd6d6e23@syzkaller.appspotmail.com Reported-by: syzbot+75e6e042c5bbf691fc82@syzkaller.appspotmail.com Signed-off-by: Ying Xue <ying.xue@windriver.com> --- net/tipc/topsrv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/tipc/topsrv.c b/net/tipc/topsrv.c index efb16f6..a457c0f 100644 --- a/net/tipc/topsrv.c +++ b/net/tipc/topsrv.c @@ -398,7 +398,7 @@ static int tipc_conn_rcv_from_sock(struct tipc_conn *con) ret = sock_recvmsg(con->sock, &msg, MSG_DONTWAIT); if (ret == -EWOULDBLOCK) return -EWOULDBLOCK; - if (ret > 0) { + if (ret == sizeof(s)) { read_lock_bh(&sk->sk_callback_lock); ret = tipc_conn_rcv_sub(srv, con, &s); read_unlock_bh(&sk->sk_callback_lock); -- 2.7.4
WARNING: multiple messages have this Message-ID (diff)
From: Ying Xue <ying.xue@windriver.com> To: <netdev@vger.kernel.org> Cc: <jon.maloy@ericsson.com>, <tipc-discussion@lists.sourceforge.net>, <syzkaller-bugs@googlegroups.com> Subject: [net 1/6] tipc: fix uninit-value in in tipc_conn_rcv_sub Date: Mon, 14 Jan 2019 17:22:24 +0800 [thread overview] Message-ID: <1547457749-24831-2-git-send-email-ying.xue@windriver.com> (raw) Message-ID: <20190114092224.Q1tdCZzZTjXEDT1_wMoltdvnicxtcGAGxwTE-FTfzLc@z> (raw) In-Reply-To: <1547457749-24831-1-git-send-email-ying.xue@windriver.com> syzbot reported: BUG: KMSAN: uninit-value in tipc_conn_rcv_sub+0x184/0x950 net/tipc/topsrv.c:373 CPU: 0 PID: 66 Comm: kworker/u4:4 Not tainted 4.17.0-rc3+ #88 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: tipc_rcv tipc_conn_recv_work Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x185/0x1d0 lib/dump_stack.c:113 kmsan_report+0x142/0x240 mm/kmsan/kmsan.c:1067 __msan_warning_32+0x6c/0xb0 mm/kmsan/kmsan_instr.c:683 tipc_conn_rcv_sub+0x184/0x950 net/tipc/topsrv.c:373 tipc_conn_rcv_from_sock net/tipc/topsrv.c:409 [inline] tipc_conn_recv_work+0x3cd/0x560 net/tipc/topsrv.c:424 process_one_work+0x12c6/0x1f60 kernel/workqueue.c:2145 worker_thread+0x113c/0x24f0 kernel/workqueue.c:2279 kthread+0x539/0x720 kernel/kthread.c:239 ret_from_fork+0x35/0x40 arch/x86/entry/entry_64.S:412 Local variable description: ----s.i@tipc_conn_recv_work Variable was created at: tipc_conn_recv_work+0x65/0x560 net/tipc/topsrv.c:419 process_one_work+0x12c6/0x1f60 kernel/workqueue.c:2145 In tipc_conn_rcv_from_sock(), it always supposes the length of message received from sock_recvmsg() is not smaller than the size of struct tipc_subscr. However, this assumption is false. Especially when the length of received message is shorter than struct tipc_subscr size, we will end up touching uninitialized fields in tipc_conn_rcv_sub(). Reported-by: syzbot+8951a3065ee7fd6d6e23@syzkaller.appspotmail.com Reported-by: syzbot+75e6e042c5bbf691fc82@syzkaller.appspotmail.com Signed-off-by: Ying Xue <ying.xue@windriver.com> --- net/tipc/topsrv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/tipc/topsrv.c b/net/tipc/topsrv.c index efb16f6..a457c0f 100644 --- a/net/tipc/topsrv.c +++ b/net/tipc/topsrv.c @@ -398,7 +398,7 @@ static int tipc_conn_rcv_from_sock(struct tipc_conn *con) ret = sock_recvmsg(con->sock, &msg, MSG_DONTWAIT); if (ret == -EWOULDBLOCK) return -EWOULDBLOCK; - if (ret > 0) { + if (ret == sizeof(s)) { read_lock_bh(&sk->sk_callback_lock); ret = tipc_conn_rcv_sub(srv, con, &s); read_unlock_bh(&sk->sk_callback_lock); -- 2.7.4
next prev parent reply other threads:[~2019-01-14 9:22 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-01-14 9:22 [net 0/6] tipc: fix uninit-value issues reported by syzbot Ying Xue 2019-01-14 9:22 ` Ying Xue 2019-01-14 9:22 ` Ying Xue [this message] 2019-01-14 9:22 ` [net 1/6] tipc: fix uninit-value in in tipc_conn_rcv_sub Ying Xue 2019-01-14 9:22 ` [net 2/6] tipc: fix uninit-value in tipc_nl_compat_link_reset_stats Ying Xue 2019-01-14 9:22 ` Ying Xue 2019-01-14 9:22 ` [net 3/6] tipc: fix uninit-value in tipc_nl_compat_bearer_enable Ying Xue 2019-01-14 9:22 ` Ying Xue 2019-01-14 9:22 ` [net 4/6] tipc: fix uninit-value in tipc_nl_compat_link_set Ying Xue 2019-01-14 9:22 ` [net 5/6] tipc: fix uninit-value in tipc_nl_compat_name_table_dump Ying Xue 2019-01-14 9:22 ` Ying Xue 2019-01-14 9:22 ` [net 6/6] tipc: fix uninit-value in tipc_nl_compat_doit Ying Xue 2019-01-14 9:22 ` Ying Xue 2019-01-16 4:29 ` [net 0/6] tipc: fix uninit-value issues reported by syzbot 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=1547457749-24831-2-git-send-email-ying.xue@windriver.com \ --to=ying.xue@windriver.com \ --cc=netdev@vger.kernel.org \ --cc=syzkaller-bugs@googlegroups.com \ --cc=tipc-discussion@lists.sourceforge.net \ /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: linkBe 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; as well as URLs for NNTP newsgroup(s).