Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6265988imu; Mon, 21 Jan 2019 06:05:54 -0800 (PST) X-Google-Smtp-Source: ALg8bN4WNp9cmkSpmMq4BZWLqZ2yUCqKocsv9JH/XRGFGKIXZJbp3JNmHX9UxzV589UNUEYdCLAX X-Received: by 2002:a63:3e05:: with SMTP id l5mr26565454pga.96.1548079554446; Mon, 21 Jan 2019 06:05:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548079554; cv=none; d=google.com; s=arc-20160816; b=jcBUavUjYy0adXUc23UlJfG3CWuEtrsU/Wi4h52n9BiQfe6nK9utuXRLY3GriocUxI /qlWk33YleIuPiKRgJmcnScqK6yaJLHktfiUDjMtl2Gaj/IuRxKBlls6AtQjJv8EKEXM K5ceMgWh4JLAWE3TKXYhR3MiJRUSqrDb/tbh1HcEDDRjcL1swZJ/Zdow3jMvqKFpkfqf 9QPgizOgufNkH8WQ9HHrV1tF4b+czvpE2KqwnpVV3miveU/8EV1gVbPAFaXw0b8YiVO5 dLAbnNq+3GROR9GxRzRI1Z/zQ89FCw11Ga3tOguOfQfIR2UGR9sOyzklG+HQgtZy0qjw DV0Q== 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=mJ5VMfW0fT5YTHaxxQNZOZBXGtPC95xIRfaAyCC7RlQ=; b=oKSD/7b0kOUQqLLMM8qi1sECa+OloN+h6pBRtwckyXxRt46R0GhTQ5Ygacrt5zUFLz H1lKGOrkrt7VHxukIFYzsQtskRt1jNVPqtSEFM+2703CK7Chq0VIxg1u03Qgjrky+xVF GZLlVZU0ENEvZ/6P48k7fit1WZCHSe235MjkGddWgIMAD+PsAI5a0VZ9DBTtnxrQsuka eVj4wYArr/DMdylTDfQmtWX4De308bax46DWGBgyRyc5/2zchLLMCTmtL5mJFROiflYp roIhmiwEeGx6lVLzXBoNp6j/vDb38b9Zt1R8nU5xosPVrj0ZGVI6cSnwmF6Jfe/yyavr wi2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xEaPzGpr; 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 y7si6441006pgq.545.2019.01.21.06.05.38; Mon, 21 Jan 2019 06:05:54 -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=xEaPzGpr; 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 S1732952AbfAUODL (ORCPT + 99 others); Mon, 21 Jan 2019 09:03:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:51000 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732471AbfAUODI (ORCPT ); Mon, 21 Jan 2019 09:03:08 -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 7D9D32089F; Mon, 21 Jan 2019 14:03:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548079387; bh=qP43qtXwsck909hhTKuxfNbIGb7S5m9NguopOctAMd0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xEaPzGprX+4ckogdVXFOqi4hrONUycmTsRt787UQwb2OjMu7gdoIyp7lpq7FEodFS N8sjaIZZV7ZokZma7FIKcit+6Zfz0/wFHTqlrardwoEnq6qWnZu8VViZXeXvRiLOdN NCWhy4yb88TcsiVMFl+t1aOsCmwKjvPUxZ6ysDT4= 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.19 77/99] tipc: fix uninit-value in tipc_nl_compat_link_set Date: Mon, 21 Jan 2019 14:49:09 +0100 Message-Id: <20190121134917.007715780@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 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 @@ -762,9 +762,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;