Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7152001ybi; Mon, 8 Jul 2019 15:41:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqzg6cMycanUP3aDc+NEaeoy7/8+gFWSlykDf8Kt82Ne3qA2RxbWPBUrJSGwiML1ru9aZonl X-Received: by 2002:a63:8a43:: with SMTP id y64mr26384368pgd.104.1562625705024; Mon, 08 Jul 2019 15:41:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562625705; cv=none; d=google.com; s=arc-20160816; b=tsi/ZUfxAnvRbzdSDIUxHEYwgBB/AV1Nul+f9R69xEP27JocSNYbUJLL4W/4HxpCDc smx+p7QErrQjI9lCiA5l0hbx5La4vbcUom8Xy/nhksf549rUGcS1GvgumXRnZxd+cdWT B+J/OIb0wNqDzWQSLqJwFFjNgqohX7d76sRXaVoiv34EBf3IcEMlUUd6TWpo9/+XyZro GNY0gOLzNERt37INovCwgng4PTs5RiTbd7ndHdK0X0SXiYk80T7KpToVw2HtYtIZxh7i k+12oMfgvkXn+icT+nxa6BVis2qJEp8e2vLVLch5zUF4Ve+Jwb1odEmsQS721sF7PVlt sDzQ== 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=IrCbT8t683ob//Pkrpm7NDrAHqq96+0w5uE2DVfQR/M=; b=bDFR4Zn/WXbfUhf8EPM0qiCWoO61GfQqbt2J0pjuz6tTfle7Z7kDX+7iNXGEQqmAlV ulONuwMBDg797RDrfnSr+x4SmXaLiOe6F0obyWNGpum7ur+H57CuV4z2xReotL1ELw4l +bozyeU0iiRftRDhfFoq8slWqIjpYSDvr552DZAR04deu44Yl3vuk5NbAKCp5rYtQmbi 4w0NwXYxY8qJedoLYXzVs5brXq9OAJIB5VW5aPK7xKUB69yceZyFmtTwChJnW4/nqJcE HCFYxRz5E6FkMUFa4Hls96cc6Z8fFFTH8ijONIWEikIESnjo9u27ZuexrdFJJGZkL43g Dhgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="d/odtrky"; 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 r63si19785784plb.136.2019.07.08.15.41.30; Mon, 08 Jul 2019 15:41:45 -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="d/odtrky"; 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 S2387822AbfGHPt2 (ORCPT + 99 others); Mon, 8 Jul 2019 11:49:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:39518 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732572AbfGHPQb (ORCPT ); Mon, 8 Jul 2019 11:16:31 -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 8BF6E214C6; Mon, 8 Jul 2019 15:16:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562598991; bh=sEOKUAq4GKM6/x3X6t11Te2cyR2Z3lcEGdyZJaXBlmM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d/odtrky+JN8DFeAUX9y+KyzjZXSBraWpUdaeaRdlaOToRiXza9EEAzlMp5WUMv5Z J5eP3VWYIVxfQf7mVX0OR+Nd880KGROslRI19A6Gmyf870Zs/SdaX/pWm/Xguwm/la I9Q1l6d/CIzT44zWdsO7d1PkpkYiTtAEhVPX8s80= 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.4 42/73] tipc: check msg->req data len in tipc_nl_compat_bearer_disable Date: Mon, 8 Jul 2019 17:12:52 +0200 Message-Id: <20190708150523.590792309@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190708150513.136580595@linuxfoundation.org> References: <20190708150513.136580595@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 @@ -430,7 +430,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; @@ -505,7 +509,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; @@ -776,7 +784,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;