Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6260039imu; Mon, 21 Jan 2019 06:01:35 -0800 (PST) X-Google-Smtp-Source: ALg8bN55Ogx58J83RbT45ws2V6kV9oEOlomhGqakn78al2VZ3lJFVk9iyxD87M/f638lynUe5/qw X-Received: by 2002:a63:91c1:: with SMTP id l184mr28412005pge.29.1548079295674; Mon, 21 Jan 2019 06:01:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548079295; cv=none; d=google.com; s=arc-20160816; b=Am+VNMubu9uPcl02FLY5fZHe5oH1K4bHXFp496Ed3kKBSlCEUQDeqtMBd2ecl/G7m0 ZIlNdHrzAPfYnUdUbFz7Vec2CnUEkNA7anXvQMqtJ2v1OvqV7FbShE7EeeQ66cE1r3UO X+mrWLePiaPbLdFb17UHn3xnZEcb5aK5ruls01SfS24z8APiQUanCe8spy2hM75vzIo0 3sjMQe0RYhnpq2Tz/2JRgjHCmQjwF24gfqec+T2t7IFTcHhn+Q8OrtuM/snstOmoA1Hk zpe5bl1xQvJ0/rfHbdrKwodG+iE61gtnVTbA9FjfNEaE4phk/FKpKPVL14HUkBYWeBAG kAKg== 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=H8jjWU4cp+qWY2JEmas6G2zcjo9MigBnzuWQj/Q70Uo=; b=pj+8ao3cUEwRoGkfnPFAO0xruRMOSodckaUsul5oCjVVrJo+qWOojz5wmYzMx0YObP HVINA8Is2I7DZzoQwqGfVIltDJ0SPJ3KdMje2Kl7zDASBsLzqD1WEtKaAivuvqD18phm u9+5S7+dTWtpMPTbBQRG5WqaDdc69stU1YH7nImKfcAxJU/zs1lAeY89b2/AK2xpvOTL 42WOqeU2ZLNHkYCtZFInjp+cNuplyi+mg8YPnMIwM8LdfKZhdOkY2Da3zTWgtJ0KQO1W 6qaj/uO+u6n0oHmsVAcSH+44Akaee33dug3onhsns/gI1GPjHsXtf6hQmPcDiUxZIT8C q5Hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Tr9nUxe1; 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 b70si12191062pfe.168.2019.01.21.06.01.19; Mon, 21 Jan 2019 06:01:35 -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=Tr9nUxe1; 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 S1731550AbfAUN6H (ORCPT + 99 others); Mon, 21 Jan 2019 08:58:07 -0500 Received: from mail.kernel.org ([198.145.29.99]:40854 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731368AbfAUNz5 (ORCPT ); Mon, 21 Jan 2019 08:55:57 -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 6EBE020879; Mon, 21 Jan 2019 13:55:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548078956; bh=U8b9cY9rz4gb5qRGaw64iW/0DxPyeKI2OPKe1PgvVwM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tr9nUxe1FbBLp/EZnQxeAL5dxoYrEbA5V3u0ch/7Ap9MgcC8HTQ3L+pyq1h9/jhOI 0V+BnU+Fgpp/CvQY5MxpPh16QXGQ2/1tns4/XMDMA2iAfurr7dA+mT1H+MGYxvCEJP BwM6qSS7HpBkaaRFGdDlTPIi59kG/nP35fTIhcvU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+d78b8a29241a195aefb8@syzkaller.appspotmail.com, Ying Xue , "David S. Miller" Subject: [PATCH 4.9 43/51] tipc: fix uninit-value in tipc_nl_compat_link_set Date: Mon, 21 Jan 2019 14:44:39 +0100 Message-Id: <20190121122457.957000139@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190121122453.700446926@linuxfoundation.org> References: <20190121122453.700446926@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.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ying Xue commit edf5ff04a45750ac8ce2435974f001dc9cfbf055 upstream. syzbot reports following splat: BUG: KMSAN: uninit-value in strlen+0x3b/0xa0 lib/string.c:486 CPU: 1 PID: 9306 Comm: syz-executor172 Not tainted 4.20.0-rc7+ #2 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x173/0x1d0 lib/dump_stack.c:113 kmsan_report+0x12e/0x2a0 mm/kmsan/kmsan.c:613 __msan_warning+0x82/0xf0 mm/kmsan/kmsan_instr.c:313 strlen+0x3b/0xa0 lib/string.c:486 nla_put_string include/net/netlink.h:1154 [inline] __tipc_nl_compat_link_set net/tipc/netlink_compat.c:708 [inline] tipc_nl_compat_link_set+0x929/0x1220 net/tipc/netlink_compat.c:744 __tipc_nl_compat_doit net/tipc/netlink_compat.c:311 [inline] tipc_nl_compat_doit+0x3aa/0xaf0 net/tipc/netlink_compat.c:344 tipc_nl_compat_handle net/tipc/netlink_compat.c:1107 [inline] tipc_nl_compat_recv+0x14d7/0x2760 net/tipc/netlink_compat.c:1210 genl_family_rcv_msg net/netlink/genetlink.c:601 [inline] genl_rcv_msg+0x185f/0x1a60 net/netlink/genetlink.c:626 netlink_rcv_skb+0x444/0x640 net/netlink/af_netlink.c:2477 genl_rcv+0x63/0x80 net/netlink/genetlink.c:637 netlink_unicast_kernel net/netlink/af_netlink.c:1310 [inline] netlink_unicast+0xf40/0x1020 net/netlink/af_netlink.c:1336 netlink_sendmsg+0x127f/0x1300 net/netlink/af_netlink.c:1917 sock_sendmsg_nosec net/socket.c:621 [inline] sock_sendmsg net/socket.c:631 [inline] ___sys_sendmsg+0xdb9/0x11b0 net/socket.c:2116 __sys_sendmsg net/socket.c:2154 [inline] __do_sys_sendmsg net/socket.c:2163 [inline] __se_sys_sendmsg+0x305/0x460 net/socket.c:2161 __x64_sys_sendmsg+0x4a/0x70 net/socket.c:2161 do_syscall_64+0xbc/0xf0 arch/x86/entry/common.c:291 entry_SYSCALL_64_after_hwframe+0x63/0xe7 The uninitialised access happened in nla_put_string(skb, TIPC_NLA_LINK_NAME, lc->name) This is because lc->name string is not validated before it's used. Reported-by: syzbot+d78b8a29241a195aefb8@syzkaller.appspotmail.com Signed-off-by: Ying Xue Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/tipc/netlink_compat.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/net/tipc/netlink_compat.c +++ b/net/tipc/netlink_compat.c @@ -753,9 +753,14 @@ static int tipc_nl_compat_link_set(struc struct tipc_link_config *lc; struct tipc_bearer *bearer; struct tipc_media *media; + int len; lc = (struct tipc_link_config *)TLV_DATA(msg->req); + len = min_t(int, TLV_GET_DATA_LEN(msg->req), TIPC_MAX_LINK_NAME); + if (!string_is_valid(lc->name, len)) + return -EINVAL; + media = tipc_media_find(lc->name); if (media) { cmd->doit = &tipc_nl_media_set;