From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Miller Subject: Re: [PATCH net] tipc: fix missing rtnl lock protection during setting link properties Date: Wed, 03 Jan 2018 10:48:50 -0500 (EST) Message-ID: <20180103.104850.406238717375090795.davem@davemloft.net> References: <1514802241-7896-1-git-send-email-ying.xue@windriver.com> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org, jon.maloy@ericsson.com, syzkaller-bugs@googlegroups.com, tipc-discussion@lists.sourceforge.net To: ying.xue@windriver.com Return-path: Received: from shards.monkeyblade.net ([184.105.139.130]:33124 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752008AbeACPsw (ORCPT ); Wed, 3 Jan 2018 10:48:52 -0500 In-Reply-To: <1514802241-7896-1-git-send-email-ying.xue@windriver.com> Sender: netdev-owner@vger.kernel.org List-ID: From: Ying Xue Date: Mon, 1 Jan 2018 18:24:01 +0800 > diff --git a/net/tipc/netlink_compat.c b/net/tipc/netlink_compat.c > index e48f0b2..0fb12a4 100644 > --- a/net/tipc/netlink_compat.c > +++ b/net/tipc/netlink_compat.c > @@ -720,17 +720,21 @@ static int tipc_nl_compat_link_set(struct tipc_nl_compat_cmd_doit *cmd, > > lc = (struct tipc_link_config *)TLV_DATA(msg->req); > > + rtnl_lock(); > media = tipc_media_find(lc->name); > if (media) { > cmd->doit = &tipc_nl_media_set; > + rtnl_unlock(); > return tipc_nl_compat_media_set(skb, msg); > } > > bearer = tipc_bearer_find(msg->net, lc->name); > if (bearer) { > cmd->doit = &tipc_nl_bearer_set; > + rtnl_unlock(); > return tipc_nl_compat_bearer_set(skb, msg); > } > + rtnl_unlock(); > > return __tipc_nl_compat_link_set(skb, msg); > } As soon as you drop the RTNL lock, the media or bearer entry can be removed from the tables. This invalidates what you do next, whether it's tipc_nl_compat_media_set(), tipc_nl_compat_bearer_set(), etc. Therefore, you have to lock down the tipc configuration state around this entire operation, from media/bearer probe to the building of the netlink message(s). Either this entire code path must execute with the bearer/media entry present, or without. If you drop the RTNL mutex in the middle, this invariant is not held.