Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3055463ybi; Tue, 2 Jul 2019 01:15:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqwRV3/KK7KpofTZZfTxy0c5YzXXw1jQDJMOEXYYZTGqfQsUxBj/kXvmmCo7sc/Eb1Cex60h X-Received: by 2002:a17:902:be12:: with SMTP id r18mr23694200pls.341.1562055320980; Tue, 02 Jul 2019 01:15:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562055320; cv=none; d=google.com; s=arc-20160816; b=h1j2YsnothN0NfY2Y9XczenwP+42ZnUAv6yuDHgEfPM3QSBrtA28twyTOGQdMvH3vn 0eqmwOBAKU55WwMo27trZ3Cc7rWy5hJQCfZXEuP7dspzTEk7CnuT6eKvHsbdAQca8GMv /SfJ0ZUvX0/4cXPmKvModi/EJweFq9n42vyFZ9OzJE/AaNt1Pr3JhQhveTaygVybZu1P ME/rGTBq4rKqjJSe5fUSnzJq9pVso9e4Y7nbHIZGyzCPPxICMFhEXsFCD16I5lDdsFmF yJQY2BzzfX6p2q6ykTe1jyB2HyE0JHKtQg7mSI9gp56Ob4lC3wJjeT1/mjPyFKioLZAc PP2g== 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=l1R9mDLCTytO7OplGW7+0lPQccfxde0RjlMDOrrnMHM=; b=KzyWAeAzjtliVUu6mKBzH9xQV+rOd1jGC76falv5wM1KpEJsRNCIdJm3GZmEY0Gch5 kXox0VRMxlHE0HqHHm2b79+Iv/iJEdp4FVCGXOSXjRBphZ4XTC4kD8FJkjYeCJjVbypf S2Axh84rDs3b/mrrJrKvnMT5Kc187+oAxgj3z+iUfmnkCvpQmCqavOlG//VnGHSv8HHF 3HH9IA//Q8LzQHI5lIW4etja/DGESPCBkNts9OpAehPGZXlbXgzG/uxmjHge7tJMMrz+ EkCGiMrys+SgPb/ZPDCUUGJBHoB8sIgNi2LnerEMYlg1WfV7T/nsLbtbFoPDUl6r/Jmc PlhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=r2KCTUyz; 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 a187si5484269pge.269.2019.07.02.01.15.06; Tue, 02 Jul 2019 01:15:20 -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=r2KCTUyz; 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 S1728385AbfGBINU (ORCPT + 99 others); Tue, 2 Jul 2019 04:13:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:55322 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727825AbfGBIHz (ORCPT ); Tue, 2 Jul 2019 04:07:55 -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 BE7A721479; Tue, 2 Jul 2019 08:07:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562054874; bh=otaSQYiXjKh+fTkj0sHdoUcmjs71OqyqyJJbv8MaroQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r2KCTUyzzqi2PwfnrwS2YWXwVInJucHXVfwdM0k81e7jOxQVITXpJA0gbbiwjo924 uSphx3XFEF0ibM3Af6YpqFtRQJ6QLqQsNT4UraWrABYLhmZ52aOkwhcCCMoSr5tjWF XCKrZURTY8NU4mkCp6nZwQENJ6wicFHvcqUNfBRM= 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.19 60/72] tipc: check msg->req data len in tipc_nl_compat_bearer_disable Date: Tue, 2 Jul 2019 10:02:01 +0200 Message-Id: <20190702080127.737966746@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190702080124.564652899@linuxfoundation.org> References: <20190702080124.564652899@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 @@ -445,7 +445,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; @@ -537,7 +541,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; @@ -815,7 +823,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;