From: Tommi Rantala <tommi.t.rantala@nokia.com>
To: Ying Xue <ying.xue@windriver.com>,
Jon Maloy <jon.maloy@ericsson.com>,
"David S. Miller" <davem@davemloft.net>,
netdev@vger.kernel.org, tipc-discussion@lists.sourceforge.net,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v2] tipc: call tipc_rcv() only if bearer is up in tipc_udp_recv()
Date: Fri, 1 Dec 2017 16:02:47 +0200 [thread overview]
Message-ID: <c110a0a9-4092-19aa-7d09-99e38d161663@nokia.com> (raw)
In-Reply-To: <840ce8d1-7271-5189-4cfa-e40f4a0a4172@windriver.com>
On 01.12.2017 15:18, Ying Xue wrote:
> On 11/30/2017 08:32 PM, Tommi Rantala wrote:
>>> In my opinion, the real root cause of the issue is because we too early
>>> set a not-yet-initialized bearer instance to ub->bearer through
>>> rcu_assign_pointer(ub->bearer, b) in tipc_udp_enable(). Instead if we
>>> assign the bearer pointer at the end of tipc_udp_enable() where the
>>> bearer has been completed the initialization, the issue would be avoided.
>> Hi, sorry, I fail to see how that helps.
>>
>> bearer->tolerance is only initialized in tipc_enable_bearer() after
>> calling m->enable_media() ie. tipc_udp_enable().
>>
>> So even if we do "rcu_assign_pointer(ub->bearer, b)" later in
>> tipc_udp_enable(), bearer->tolerance will still be uninitialized, and
>> the crash can happen.
>
> Sorry, I missed the point that b->tolerance is not uninitialized when we
> assign bearer pointer to ub->bearer later.
>
> But in my view the issue happened is because we enable media too early.
> So it's better to change the code as belows:
Thanks, looks good to me!
Tested in 4.4 (which does not have b->up), and this fixes the oops also
there.
-Tommi
> diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
> index 47ec121..ec6f02a 100644
> --- a/net/tipc/bearer.c
> +++ b/net/tipc/bearer.c
> @@ -320,19 +320,18 @@ static int tipc_enable_bearer(struct net *net,
> const char *name,
>
> strcpy(b->name, name);
> b->media = m;
> - res = m->enable_media(net, b, attr);
> - if (res) {
> - pr_warn("Bearer <%s> rejected, enable failure (%d)\n",
> - name, -res);
> - return -EINVAL;
> - }
> -
> b->identity = bearer_id;
> b->tolerance = m->tolerance;
> b->window = m->window;
> b->domain = disc_domain;
> b->net_plane = bearer_id + 'A';
> b->priority = priority;
> + res = m->enable_media(net, b, attr);
> + if (res) {
> + pr_warn("Bearer <%s> rejected, enable failure (%d)\n",
> + name, -res);
> + return -EINVAL;
> + }
> test_and_set_bit_lock(0, &b->up);
>
next prev parent reply other threads:[~2017-12-01 14:02 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-29 10:48 [PATCH net v2] tipc: call tipc_rcv() only if bearer is up in tipc_udp_recv() Tommi Rantala
2017-11-30 10:57 ` Ying Xue
2017-11-30 12:32 ` Tommi Rantala
2017-12-01 13:18 ` Ying Xue
2017-12-01 14:02 ` Tommi Rantala [this message]
2017-12-01 14:20 ` Jon Maloy
2017-12-01 20:14 ` 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=c110a0a9-4092-19aa-7d09-99e38d161663@nokia.com \
--to=tommi.t.rantala@nokia.com \
--cc=davem@davemloft.net \
--cc=jon.maloy@ericsson.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--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