Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4812454yba; Tue, 30 Apr 2019 04:56:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqx6PxhkwyQBxCYzm5KnSxqHndO8FFFe4i12POMWTBu7C/CNCk5RcChQJlXmWfKdDdp61isY X-Received: by 2002:a63:445d:: with SMTP id t29mr51412053pgk.303.1556625375630; Tue, 30 Apr 2019 04:56:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556625375; cv=none; d=google.com; s=arc-20160816; b=G7piQTwwGd+OIj7sCQ3uooyyOPDoIcboUQYDL74CTmrwU1Aw6vpJpwG0aR6+zeZxUI uWiRBMGN7sG5OVmxdbEuouCPjnaj5JikqnsYqmONYktDxtUWc6RNFqFtgaBLXCQZbhEV K3ai4a3GogI6slu9Oq+L9QwFSQw6+cHv8IhizFUxEmwiaVSnIIvlV43T8IXIF92osC2w if0G7Gtd80fYbmwASjvYZEmaxykkMy/8gKvn78q9ua/L21XpvSdW5/FXkFMMcCZzwcUY MQrqkAn6yRLwTnBqpyGsyuljPP303ArSAy5aw/jXkrutwkAseM+9dcoW3+w4/3qLDspQ Rqow== 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=34O6TatjNEY8nOPnyYesk9ARauywuyfIIAhiBcMthr8=; b=0TAV0rRQYXCZjdtiG467QwsTow8Cmi8gRmfaO5kfHmHG3mP2giOqij3oWnAuTvWIB4 oQ/Zq/dOyZYI57CdpOeiIogAqxrbm3J2PrC+yrS56QhtiMRhd241cCqn51hQ0yucWE3w xjgxqP653ViTOvxviVxKLd3T0U8BhyivjzhqO/TesB3yk0H29Tn6k3pNtZPjjEcqe917 g8nxqipW7Gp6c0m/TyUa+9ymctLIT/U6b9VrbKHytss6+4oA9hsDA5m4fGu9ccoAmyto tKWjZJHOVHdBhfC13fMD58vm5EONimRdap6/5NVg63UJDxzzTc8XDq9e2wKWYfFkoKid 6A/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1u4PGz9k; 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 cc13si8496991plb.412.2019.04.30.04.55.59; Tue, 30 Apr 2019 04:56:15 -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=1u4PGz9k; 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 S1731334AbfD3LvH (ORCPT + 99 others); Tue, 30 Apr 2019 07:51:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:38522 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731325AbfD3LvE (ORCPT ); Tue, 30 Apr 2019 07:51:04 -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 6AB9820449; Tue, 30 Apr 2019 11:51:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556625063; bh=Wb9v6+JfhmpyAoywsRFXiLGKnv7wZi6IPZiBNKCeCaA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1u4PGz9kkHgLlXzpZoih99AlXc/GZYZp1kfP1tf00HakK1RMzy7lk3KsN3ltp/cyp C2Ef1UfW9/Q8V8hzIgp7CgBzARHXVT7sFRVv1M6zIwWl+viMxoQESYGRd1fp0McQVX Yq6mhDqpsqy2d2mDvivw+7weDiMgxrG0yq2ao40s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+3ce8520484b0d4e260a5@syzkaller.appspotmail.com, Xin Long , "David S. Miller" Subject: [PATCH 5.0 50/89] tipc: handle the err returned from cmd header function Date: Tue, 30 Apr 2019 13:38:41 +0200 Message-Id: <20190430113612.040475975@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190430113609.741196396@linuxfoundation.org> References: <20190430113609.741196396@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 commit 2ac695d1d602ce00b12170242f58c3d3a8e36d04 upstream. Syzbot found a crash: BUG: KMSAN: uninit-value in tipc_nl_compat_name_table_dump+0x54f/0xcd0 net/tipc/netlink_compat.c:872 Call Trace: tipc_nl_compat_name_table_dump+0x54f/0xcd0 net/tipc/netlink_compat.c:872 __tipc_nl_compat_dumpit+0x59e/0xda0 net/tipc/netlink_compat.c:215 tipc_nl_compat_dumpit+0x63a/0x820 net/tipc/netlink_compat.c:280 tipc_nl_compat_handle net/tipc/netlink_compat.c:1226 [inline] tipc_nl_compat_recv+0x1b5f/0x2750 net/tipc/netlink_compat.c:1265 genl_family_rcv_msg net/netlink/genetlink.c:601 [inline] genl_rcv_msg+0x185f/0x1a60 net/netlink/genetlink.c:626 netlink_rcv_skb+0x431/0x620 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+0xf3e/0x1020 net/netlink/af_netlink.c:1336 netlink_sendmsg+0x127f/0x1300 net/netlink/af_netlink.c:1917 sock_sendmsg_nosec net/socket.c:622 [inline] sock_sendmsg net/socket.c:632 [inline] Uninit was created at: __alloc_skb+0x309/0xa20 net/core/skbuff.c:208 alloc_skb include/linux/skbuff.h:1012 [inline] netlink_alloc_large_skb net/netlink/af_netlink.c:1182 [inline] netlink_sendmsg+0xb82/0x1300 net/netlink/af_netlink.c:1892 sock_sendmsg_nosec net/socket.c:622 [inline] sock_sendmsg net/socket.c:632 [inline] It was supposed to be fixed on commit 974cb0e3e7c9 ("tipc: fix uninit-value in tipc_nl_compat_name_table_dump") by checking TLV_GET_DATA_LEN(msg->req) in cmd->header()/tipc_nl_compat_name_table_dump_header(), which is called ahead of tipc_nl_compat_name_table_dump(). However, tipc_nl_compat_dumpit() doesn't handle the error returned from cmd header function. It means even when the check added in that fix fails, it won't stop calling tipc_nl_compat_name_table_dump(), and the issue will be triggered again. So this patch is to add the process for the err returned from cmd header function in tipc_nl_compat_dumpit(). Reported-by: syzbot+3ce8520484b0d4e260a5@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 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) --- a/net/tipc/netlink_compat.c +++ b/net/tipc/netlink_compat.c @@ -267,8 +267,14 @@ static int tipc_nl_compat_dumpit(struct if (msg->rep_type) tipc_tlv_init(msg->rep, msg->rep_type); - if (cmd->header) - (*cmd->header)(msg); + if (cmd->header) { + err = (*cmd->header)(msg); + if (err) { + kfree_skb(msg->rep); + msg->rep = NULL; + return err; + } + } arg = nlmsg_new(0, GFP_KERNEL); if (!arg) {