Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6783398ybi; Mon, 8 Jul 2019 08:36:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqwI2GDVSWnnwu4opSkk/2pJ92a7yTg3f9llfj7OO9tp3ivzqvHk6p7dePRBmTShyK+0minz X-Received: by 2002:a17:90a:214e:: with SMTP id a72mr27284779pje.0.1562600183029; Mon, 08 Jul 2019 08:36:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562600183; cv=none; d=google.com; s=arc-20160816; b=lW06uXEnD/W2MTCn/qJKW6CkSgPxgS/e1syuCMw4wyffMN7STcIAXpVW46uWeDRkPX zDGcYZszudCT1/63AT1itbWJy13AtWwsHuHUoslEpv1+8ieAboqAKgsYrRZT7UggNlgq yU/qJ2raCwAZjuvCrcpFfueg2hJhGnZ6NNnd9xSpaT8uGXvAgDOpGyVGtg/eJQauoT7m i5mh8QFOowdRG397WrVIACL2Nwtwioxq9mFoPjCNOUeQvfDrbkIQPDo5pWu2333gqIJm ixdTHO6YY1KA9a+PBULw7lDLBFS1w0GUPL0WUFgfyAzjmQ8SLpMuQK9hL7PmVF3gvKK+ 40Ug== 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=6dBpgNgIwsjr40IVujpBGD4PnRiWU2enj6f/MvqadQA=; b=Oz5gLvqvCpjtpkxa88g3+VCIwgIm3/9XjwN+bJoSbiupeRrcV9u5srAbTDN4V75Ctx W+dek831LvwXJO/U5U0UuunI0RmXm4RFN9MNNeRmBG3sv2SiKW/lUbxmS9F3DnoRPyhN JevmnLcpIoi78InSIBNWx15quxLuN9CC/XULk58+UdfmYEbkI2JdMej3SdNaji7FBDWJ lwsGh1CSRtWhNX2o7UxA7a3D55Wl2JRHkq9gPpcgjYMpyXyxUMo1tzzOExfwNpL3reWI uHPzBb8RJypiKV60+C+DJ9deCpiMKumI0+6quGfyhSHY0AHPnpPht7A7JMfId6D0c5ZV z5gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Lmu1kOdo; 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 o61si19080246pld.392.2019.07.08.08.36.07; Mon, 08 Jul 2019 08:36:23 -0700 (PDT) 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=Lmu1kOdo; 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 S2387705AbfGHPVB (ORCPT + 99 others); Mon, 8 Jul 2019 11:21:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:46270 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387680AbfGHPU5 (ORCPT ); Mon, 8 Jul 2019 11:20:57 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 C25B4216FD; Mon, 8 Jul 2019 15:20:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562599256; bh=cW6dXEbzQ5FFfEr+2oS4Oy2c+x2zJXY56Pe7Lr47RDM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lmu1kOdoHx1lxx+uranVbF5DaBcsa9fOygw+KQDcjpsZRkAZxEjFeZCH5RETyCxDw zON4LuJYC4tPcFwwGGn7gvyUxLlM3NOHWAZqM3wVK0M/PXC4rLdhAuv26ubc2CwtqK 02iqGY9/PRmC+zcwkPgooW7BurouHQaIorcWm4KQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+30eaa8bf392f7fafffaf@syzkaller.appspotmail.com, Xin Long , "David S. Miller" Subject: [PATCH 4.9 056/102] tipc: check msg->req data len in tipc_nl_compat_bearer_disable Date: Mon, 8 Jul 2019 17:12:49 +0200 Message-Id: <20190708150529.357896700@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190708150525.973820964@linuxfoundation.org> References: <20190708150525.973820964@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Xin Long [ Upstream commit 4f07b80c973348a99b5d2a32476a2e7877e94a05 ] This patch is to fix an uninit-value issue, reported by syzbot: BUG: KMSAN: uninit-value in memchr+0xce/0x110 lib/string.c:981 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x191/0x1f0 lib/dump_stack.c:113 kmsan_report+0x130/0x2a0 mm/kmsan/kmsan.c:622 __msan_warning+0x75/0xe0 mm/kmsan/kmsan_instr.c:310 memchr+0xce/0x110 lib/string.c:981 string_is_valid net/tipc/netlink_compat.c:176 [inline] tipc_nl_compat_bearer_disable+0x2a1/0x480 net/tipc/netlink_compat.c:449 __tipc_nl_compat_doit net/tipc/netlink_compat.c:327 [inline] tipc_nl_compat_doit+0x3ac/0xb00 net/tipc/netlink_compat.c:360 tipc_nl_compat_handle net/tipc/netlink_compat.c:1178 [inline] tipc_nl_compat_recv+0x1b1b/0x27b0 net/tipc/netlink_compat.c:1281 TLV_GET_DATA_LEN() may return a negtive int value, which will be used as size_t (becoming a big unsigned long) passed into memchr, cause this issue. Similar to what it does in tipc_nl_compat_bearer_enable(), this fix is to return -EINVAL when TLV_GET_DATA_LEN() is negtive in tipc_nl_compat_bearer_disable(), as well as in tipc_nl_compat_link_stat_dump() and tipc_nl_compat_link_reset_stats(). v1->v2: - add the missing Fixes tags per Eric's request. Fixes: 0762216c0ad2 ("tipc: fix uninit-value in tipc_nl_compat_bearer_enable") Fixes: 8b66fee7f8ee ("tipc: fix uninit-value in tipc_nl_compat_link_reset_stats") Reported-by: syzbot+30eaa8bf392f7fafffaf@syzkaller.appspotmail.com Signed-off-by: Xin Long Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/tipc/netlink_compat.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) --- a/net/tipc/netlink_compat.c +++ b/net/tipc/netlink_compat.c @@ -436,7 +436,11 @@ static int tipc_nl_compat_bearer_disable if (!bearer) return -EMSGSIZE; - len = min_t(int, TLV_GET_DATA_LEN(msg->req), TIPC_MAX_BEARER_NAME); + len = TLV_GET_DATA_LEN(msg->req); + if (len <= 0) + return -EINVAL; + + len = min_t(int, len, TIPC_MAX_BEARER_NAME); if (!string_is_valid(name, len)) return -EINVAL; @@ -528,7 +532,11 @@ static int tipc_nl_compat_link_stat_dump name = (char *)TLV_DATA(msg->req); - len = min_t(int, TLV_GET_DATA_LEN(msg->req), TIPC_MAX_LINK_NAME); + len = TLV_GET_DATA_LEN(msg->req); + if (len <= 0) + return -EINVAL; + + len = min_t(int, len, TIPC_MAX_BEARER_NAME); if (!string_is_valid(name, len)) return -EINVAL; @@ -806,7 +814,11 @@ static int tipc_nl_compat_link_reset_sta if (!link) return -EMSGSIZE; - len = min_t(int, TLV_GET_DATA_LEN(msg->req), TIPC_MAX_LINK_NAME); + len = TLV_GET_DATA_LEN(msg->req); + if (len <= 0) + return -EINVAL; + + len = min_t(int, len, TIPC_MAX_BEARER_NAME); if (!string_is_valid(name, len)) return -EINVAL;