From: David Miller <davem@davemloft.net>
To: ying.xue@windriver.com
Cc: netdev@vger.kernel.org, jon.maloy@ericsson.com,
syzkaller-bugs@googlegroups.com,
tipc-discussion@lists.sourceforge.net
Subject: Re: [PATCH net] tipc: fix missing rtnl lock protection during setting link properties
Date: Wed, 03 Jan 2018 10:48:50 -0500 (EST) [thread overview]
Message-ID: <20180103.104850.406238717375090795.davem@davemloft.net> (raw)
In-Reply-To: <1514802241-7896-1-git-send-email-ying.xue@windriver.com>
From: Ying Xue <ying.xue@windriver.com>
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.
next prev parent reply other threads:[~2018-01-03 15:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-01 10:24 [PATCH net] tipc: fix missing rtnl lock protection during setting link properties Ying Xue
2018-01-03 15:48 ` David Miller [this message]
2018-01-04 7:30 ` Ying Xue
2018-01-04 15:22 ` David Miller
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=20180103.104850.406238717375090795.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=jon.maloy@ericsson.com \
--cc=netdev@vger.kernel.org \
--cc=syzkaller-bugs@googlegroups.com \
--cc=tipc-discussion@lists.sourceforge.net \
--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