stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Jon Maloy <jmaloy@redhat.com>,
	Ying Xue <ying.xue@windriver.com>,
	Richard Alpe <richard.alpe@ericsson.com>,
	Cong Wang <xiyou.wangcong@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	syzbot+0e7181deafa7e0b79923@syzkaller.appspotmail.com
Subject: [PATCH 5.8 09/16] tipc: fix uninit skb->data in tipc_nl_compat_dumpit()
Date: Wed, 26 Aug 2020 14:02:46 +0200	[thread overview]
Message-ID: <20200826114911.681967861@linuxfoundation.org> (raw)
In-Reply-To: <20200826114911.216745274@linuxfoundation.org>

From: Cong Wang <xiyou.wangcong@gmail.com>

[ 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 <jmaloy@redhat.com>
Cc: Ying Xue <ying.xue@windriver.com>
Cc: Richard Alpe <richard.alpe@ericsson.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Acked-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 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);



  parent reply	other threads:[~2020-08-26 12:04 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-26 12:02 [PATCH 5.8 00/16] 5.8.5-rc1 review Greg Kroah-Hartman
2020-08-26 12:02 ` [PATCH 5.8 01/16] gre6: Fix reception with IP6_TNL_F_RCV_DSCP_COPY Greg Kroah-Hartman
2020-08-26 12:02 ` [PATCH 5.8 02/16] net: Fix potential wrong skb->protocol in skb_vlan_untag() Greg Kroah-Hartman
2020-08-26 12:02 ` [PATCH 5.8 03/16] net: nexthop: dont allow empty NHA_GROUP Greg Kroah-Hartman
2020-08-26 12:02 ` [PATCH 5.8 04/16] net: qrtr: fix usage of idr in port assignment to socket Greg Kroah-Hartman
2020-08-26 12:02 ` [PATCH 5.8 05/16] net/sched: act_ct: Fix skb double-free in tcf_ct_handle_fragments() error flow Greg Kroah-Hartman
2020-08-26 12:02 ` [PATCH 5.8 06/16] net: sctp: Fix negotiation of the number of data streams Greg Kroah-Hartman
2020-08-26 12:02 ` [PATCH 5.8 07/16] net/smc: Prevent kernel-infoleak in __smc_diag_dump() Greg Kroah-Hartman
2020-08-26 12:02 ` [PATCH 5.8 08/16] tipc: call rcu_read_lock() in tipc_aead_encrypt_done() Greg Kroah-Hartman
2020-08-26 12:02 ` Greg Kroah-Hartman [this message]
2020-08-26 12:02 ` [PATCH 5.8 10/16] net: ena: Make missed_tx stat incremental Greg Kroah-Hartman
2020-08-26 12:02 ` [PATCH 5.8 11/16] ethtool: Fix preserving of wanted feature bits in netlink interface Greg Kroah-Hartman
2020-08-26 12:02 ` [PATCH 5.8 12/16] ethtool: Account for hw_features " Greg Kroah-Hartman
2020-08-26 12:02 ` [PATCH 5.8 13/16] ethtool: Dont omit the netlink reply if no features were changed Greg Kroah-Hartman
2020-08-26 12:02 ` [PATCH 5.8 14/16] netlink: fix state reallocation in policy export Greg Kroah-Hartman
2020-08-26 12:02 ` [PATCH 5.8 15/16] io_uring: fix missing ->mm on exit Greg Kroah-Hartman
2020-08-26 12:02 ` [PATCH 5.8 16/16] binfmt_flat: revert "binfmt_flat: dont offset the data start" Greg Kroah-Hartman
2020-08-26 16:04 ` [PATCH 5.8 00/16] 5.8.5-rc1 review Jon Hunter
2020-08-27  7:32   ` Greg Kroah-Hartman
2020-08-26 20:58 ` Guenter Roeck
2020-08-27  7:32   ` Greg Kroah-Hartman
2020-08-27  7:59 ` Naresh Kamboju

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200826114911.681967861@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=davem@davemloft.net \
    --cc=jmaloy@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=richard.alpe@ericsson.com \
    --cc=stable@vger.kernel.org \
    --cc=syzbot+0e7181deafa7e0b79923@syzkaller.appspotmail.com \
    --cc=xiyou.wangcong@gmail.com \
    --cc=ying.xue@windriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).