Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6265682imu; Mon, 21 Jan 2019 06:05:37 -0800 (PST) X-Google-Smtp-Source: ALg8bN5O5BqnV7Njhz6/Pf9S9bJFculB/0c/76wJE6m3W/PcU3xDIhvcf1UpeNVEne1u4zNNE/Yc X-Received: by 2002:a62:32c4:: with SMTP id y187mr30818359pfy.195.1548079537327; Mon, 21 Jan 2019 06:05:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548079537; cv=none; d=google.com; s=arc-20160816; b=xaTZ0eQA5b9rqZx+TaxDpUEpNVJKlKh0minM73uVy4HULMHYfvScQ+6qWoqsUj4q4x UO/iRDovcm3p6minJ9S949pWiuk3xg9CHACIVNX1ZwWNpDZ6KHthJMp8X20IEGJ/IjW+ PkuPD/oBanVREg6NcO54aj+9MHMnuums9PHg/GKHwwS62Q5HUZ0J0YsYya0EQSWAYEWv bPNDXa7GUkjIvt1qBDjCh85/hgs0yamgIwEBQmCH6SGxTWGmLEoUfiteBK8bWBhuhGjG Wrr0qbVAuMCWa/edr/ksSWtbUHuTC7mxgMCprFKXLj7h5dGfliZe/oarkKxWDCi3qWD6 5rSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3HU5ykhPoWZz0NoBymH73cYcyLNAjByDm/s35jaDCPA=; b=XxrntPxwSXczgzCB8n1I35yBGAfe06T/BfTRCnM1IYuNY/b0cUXZNZgwAofMuPkGZd QUXLi6bCz8o0HbO6BGhMY/al2vRJGZCxoTXdquzKKnnquvL8GWvhm1aEQHTg8t+/hmCJ jju/Y890mpOev5isFIF5LqSRs9RQUrxSJyl/iE2mRyLuJw86tk0vmDBaVamp48YUiY4u VyBfsRTxJgIRt+0+EQVyTLTWRUvdK/5ElS+rLJ/r32330svLl+hNLsuBueqhvLjfrW1a ZgYME9XGh+LXFUFFS3cbFJgHh8IGy+bBlXzenQmcvMXXGaD/O3I4IryGl1gLnDRhH3hf LTYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sfiK6haD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p10si9944876pgi.549.2019.01.21.06.05.12; Mon, 21 Jan 2019 06:05:37 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sfiK6haD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732665AbfAUOBk (ORCPT + 99 others); Mon, 21 Jan 2019 09:01:40 -0500 Received: from mail.kernel.org ([198.145.29.99]:48716 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732207AbfAUOBh (ORCPT ); Mon, 21 Jan 2019 09:01:37 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 207652089F; Mon, 21 Jan 2019 14:01:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548079296; bh=O9kf+tQRFyKVJ4PbL2/vl6RyU4AOiMBjVRTRrzw04lI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sfiK6haDj0FeFP3/EQXHt3DhxshONZtNTDUZGOcxcC4MTC6sZ/usxrs4DnKhmykJt HUaCr+Nj7MvjA4HIj5hIbI8q8p1OEzxLHOdcSsj6xkrZO/fLrOzzqzqru3hapnWQzS 5v9HzGd/5LhEdWfwEnxmUqU9ukop9QHYGT9IPerA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+8951a3065ee7fd6d6e23@syzkaller.appspotmail.com, syzbot+75e6e042c5bbf691fc82@syzkaller.appspotmail.com, Ying Xue , "David S. Miller" Subject: [PATCH 4.19 74/99] tipc: fix uninit-value in in tipc_conn_rcv_sub Date: Mon, 21 Jan 2019 14:49:06 +0100 Message-Id: <20190121134916.858335225@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190121134913.924726465@linuxfoundation.org> References: <20190121134913.924726465@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ying Xue commit a88289f4ddee4165d5f796bd99e09eec3133c16b upstream. 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 Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/tipc/topsrv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/tipc/topsrv.c +++ b/net/tipc/topsrv.c @@ -404,7 +404,7 @@ static int tipc_conn_rcv_from_sock(struc 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);