From: Nikolay Aleksandrov <nikolay@redhat.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: netdev@vger.kernel.org, Jiri Pirko <jiri@resnulli.us>,
Andy Gospodarek <andy@greyhouse.net>,
Jay Vosburgh <j.vosburgh@gmail.com>,
Veaceslav Falico <vfalico@gmail.com>
Subject: Re: [PATCH net] bonding: fix div by zero while enslaving and transmitting
Date: Fri, 12 Sep 2014 16:55:55 +0200 [thread overview]
Message-ID: <5413097B.9080802@redhat.com> (raw)
In-Reply-To: <1410533152.7106.95.camel@edumazet-glaptop2.roam.corp.google.com>
On 09/12/2014 04:45 PM, Eric Dumazet wrote:
> On Fri, 2014-09-12 at 15:33 +0200, Nikolay Aleksandrov wrote:
>
>> One more thing, netdev_master_upper_dev_link_private() which is called
>> after the increment uses list_add_rcu() (i.e. rcu_assign_pointer) to insert
>> the slave, so there's a barrier there to ensure this is visible before the
>> slave is linked.
>
> You missed my point.
>
> You fixed the writer side, without adding barriers on the read side.
>
> Without looking at the code, just reading your patch, I spot a problem.
>
> Following code is fundamentally broken :
>
> rcu_read_lock();
>
> if (bond->list) {
> x = y % bond->slave; // bug : cpu could fetch bond->slave before bond->list
>
> rcu_read_unlock();
>
>
Ah yes, you're absolutely correct.
Then get the value of slave_cnt in a local variable using ACCESS_ONCE() + a
check for != 0 would be a better solution than adding a read barrier, what
do you think ?
Since it's not a problem to see slave_cnt > 0 when there're no slaves, but
the other way around is problematic.
> Because it needs a read barrier, since the writer does after your patch:
>
> update bond->slave
> smp_wmb();
> update bond->list
>
> I repeat : adding few rcu_read_lock() / rcu_read_unlock() /
> rcu_assign_pointer() calls is not enough to guarantee code is not
> broken.
>
Yes, I see now.
Thanks,
Nik
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
next prev parent reply other threads:[~2014-09-12 14:56 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-12 12:22 [PATCH net] bonding: fix div by zero while enslaving and transmitting Nikolay Aleksandrov
2014-09-12 13:09 ` Eric Dumazet
2014-09-12 13:27 ` Nikolay Aleksandrov
2014-09-12 13:33 ` Nikolay Aleksandrov
2014-09-12 14:45 ` Eric Dumazet
2014-09-12 14:55 ` Nikolay Aleksandrov [this message]
2014-09-12 15:38 ` [PATCH net v2] " Nikolay Aleksandrov
2014-09-13 21:17 ` David Miller
2014-09-17 6:15 ` Ding Tianhong
2014-09-17 11:08 ` Nikolay Aleksandrov
2014-09-18 10:59 ` Ding Tianhong
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=5413097B.9080802@redhat.com \
--to=nikolay@redhat.com \
--cc=andy@greyhouse.net \
--cc=eric.dumazet@gmail.com \
--cc=j.vosburgh@gmail.com \
--cc=jiri@resnulli.us \
--cc=netdev@vger.kernel.org \
--cc=vfalico@gmail.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).