Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp164013pxa; Wed, 26 Aug 2020 07:30:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxn9I62I/BwzwcUc4PGO5IsW2CGhRDvIuu0thRxpsaYByRYsEiJOSg7FueSg8iKx2faqWlb X-Received: by 2002:a05:6402:1299:: with SMTP id w25mr15499665edv.349.1598452200995; Wed, 26 Aug 2020 07:30:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598452200; cv=none; d=google.com; s=arc-20160816; b=DqmX7Ag8hzqvAnA2vKxPam1eW+AWoAps0DvVimnbrGSZtcglHAIyF5NpRdv+9nD/Yb lwdFbeaxxmCZdf4WnYuuTne/ruecM0MFHVC6IlMYRfAPQpi0wd70rCNyghf3jbmENG3l /1mwKywu4x1u1i9ShK2EOZ1GcJ23Adt+cJUkg5lApU1bgUJn0w8E2l3g89vKQj/jrq9i a/R+Kgy8vBwj2SsM1a1piWS/4iKn6os8hMRmm7j5fPOpv0k6OU7dqRmjI2uui45+06n7 d4iBTRJv5BlDndcrtzft0AW6ypfq2JrhOwc2snQ6On+em19wWVBamYMB5bYgTLQgjpx8 Kc5Q== 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=gjArwBDH0MetrIK/cKmffXfjZygupRuqekisyyqcr3g=; b=jz+FHBPH9nqYoBGojeF0qGORdX0jjHjvXzsBv7zW6fkwaShzP5GwqUqXoSmCjCKJAw 2nZ+05qvmmLmLRvp1U1kLjcrQR/xqu2P2hraF8sUpTq+aZ2Tj+2j/RrB/jzzirOPd+Pr 2p7x2IXirjNcycTm4C/RxsyA3hhXm/2XFm7VCVpJjnmucxhHA14xzxrCt+69qYm1hXL9 F56AfgYw0hD/aopiitpopl1EmgMUDZwkncdwAP/HhlT5B0JgI5u0XrMmR69/KGixAVKo fhxMEngxOE/3WGNdTo2NwqSA/AIxXUNfVHLqBjQ46P0/DKwrWlenxb1RrbWPbtI2B+ce cYUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2mb+jiFt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s5si1523083edu.65.2020.08.26.07.29.36; Wed, 26 Aug 2020 07:30:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2mb+jiFt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729594AbgHZMEO (ORCPT + 99 others); Wed, 26 Aug 2020 08:04:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:37486 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729484AbgHZMC5 (ORCPT ); Wed, 26 Aug 2020 08:02: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 4D73420786; Wed, 26 Aug 2020 12:02:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598443377; bh=RmXL/1u0VAWNbKLafrCpKWutDzDTHZH6Cc5wbc73xbs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2mb+jiFtFoM8nZsakS4jNxo2a/D2iin9vayTfEOXlIWYi4Xk1g5f4+BG9H/ODY/3v x56+98IGMAvsUix4H3CapMt04DRwsKrPgYCirVqZ66k9AEpr+NF3KVvrrQfb4NKgaR vBrl9wRtd1M4Ky3rbGfRyejtpCwMwJ1yyQN1VQGI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jon Maloy , Ying Xue , Richard Alpe , Cong Wang , "David S. Miller" , syzbot+0e7181deafa7e0b79923@syzkaller.appspotmail.com Subject: [PATCH 5.7 09/15] tipc: fix uninit skb->data in tipc_nl_compat_dumpit() Date: Wed, 26 Aug 2020 14:02:37 +0200 Message-Id: <20200826114849.751629016@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200826114849.295321031@linuxfoundation.org> References: <20200826114849.295321031@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: Cong Wang [ Upstream commit 47733f9daf4fe4f7e0eb9e273f21ad3a19130487 ] __tipc_nl_compat_dumpit() has two callers, and it expects them to pass a valid nlmsghdr via arg->data. This header is artificial and crafted just for __tipc_nl_compat_dumpit(). tipc_nl_compat_publ_dump() does so by putting a genlmsghdr as well as some nested attribute, TIPC_NLA_SOCK. But the other caller tipc_nl_compat_dumpit() does not, this leaves arg->data uninitialized on this call path. Fix this by just adding a similar nlmsghdr without any payload in tipc_nl_compat_dumpit(). This bug exists since day 1, but the recent commit 6ea67769ff33 ("net: tipc: prepare attrs in __tipc_nl_compat_dumpit()") makes it easier to appear. Reported-and-tested-by: syzbot+0e7181deafa7e0b79923@syzkaller.appspotmail.com Fixes: d0796d1ef63d ("tipc: convert legacy nl bearer dump to nl compat") Cc: Jon Maloy Cc: Ying Xue Cc: Richard Alpe Signed-off-by: Cong Wang Acked-by: Ying Xue Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/tipc/netlink_compat.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) --- a/net/tipc/netlink_compat.c +++ b/net/tipc/netlink_compat.c @@ -275,8 +275,9 @@ err_out: static int tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd, struct tipc_nl_compat_msg *msg) { - int err; + struct nlmsghdr *nlh; struct sk_buff *arg; + int err; if (msg->req_type && (!msg->req_size || !TLV_CHECK_TYPE(msg->req, msg->req_type))) @@ -305,6 +306,15 @@ static int tipc_nl_compat_dumpit(struct return -ENOMEM; } + nlh = nlmsg_put(arg, 0, 0, tipc_genl_family.id, 0, NLM_F_MULTI); + if (!nlh) { + kfree_skb(arg); + kfree_skb(msg->rep); + msg->rep = NULL; + return -EMSGSIZE; + } + nlmsg_end(arg, nlh); + err = __tipc_nl_compat_dumpit(cmd, msg, arg); if (err) { kfree_skb(msg->rep);