Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Vladimir Oltean <vladimir.oltean@nxp.com>
To: Nikolay Aleksandrov <nikolay@nvidia.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
Jakub Kicinski <kuba@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Jiri Pirko <jiri@resnulli.us>, Ido Schimmel <idosch@idosch.org>,
Roopa Prabhu <roopa@nvidia.com>,
"bridge@lists.linux-foundation.org"
<bridge@lists.linux-foundation.org>,
syzkaller-bugs <syzkaller-bugs@googlegroups.com>,
"syzbot+9ba1174359adba5a5b7c@syzkaller.appspotmail.com"
<syzbot+9ba1174359adba5a5b7c@syzkaller.appspotmail.com>
Subject: Re: [PATCH net] net: bridge: validate the NUD_PERMANENT bit when adding an extern_learn FDB entry
Date: Mon, 2 Aug 2021 11:20:01 +0000 [thread overview]
Message-ID: <20210802112001.rxfajfttl35bnh5s@skbuf> (raw)
In-Reply-To: <4d85eacb-152e-8e4e-bb18-ad2814d249c1@nvidia.com>
On Mon, Aug 02, 2021 at 02:02:36PM +0300, Nikolay Aleksandrov wrote:
> >> Actually I believe there is still a bug in 52e4bec15546 even with this fix.
> >> The flag can change after the dst has been read in br_switchdev_fdb_notify()
> >> so in theory you could still do a null pointer dereference. fdb_notify()
> >> can be called from a few places without locking. The code shouldn't dereference
> >> the dst based on the flag.
> >
> > Are you thinking of a specific code path that triggers a race between
> > (a) a writer side doing WRITE_ONCE(fdb->dst, NULL) and then
> > set_bit(BR_FDB_LOCAL, &fdb->flags), exactly in this order, and
>
> Visible order is not guaranteed, there are no barriers neither at writer nor reader
> sides, especially when used without locking. So we cannot make any assumptions
> about the order visibility of these writes.
>
> > (b) a reader side catching that fdb exactly in between the above 2
> > statements, through fdb_notify or otherwise (br_fdb_replay)?
> >
> > Because I don't see any.
> >
> > Plus, I am a bit nervous about protecting against theoretical/unproven
> > races in a way that masks real bugs, as we would be doing if I add an
> > extra check in br_fdb_replay_one and br_switchdev_fdb_notify against the
> > case where an entry has fdb->dst == NULL but not BR_FDB_LOCAL.
> >
>
> The bits are _not_ visible atomically with the setting of ->dst. It is obvious
> you must not dereference anything based on them, they are only indications when used
> outside of locked regions and code must be able to deal with inconsistencies as that
> is implied by the way they're used. It is a clear and obvious bug dereferencing based
> on a bit that can change in parallel without any memory ordering guarantees.
Ok, I will send a separate patch for that.
> You are not "masking" anything, but fixing what is currently buggy use of fdb bits.
I am "masking" in the sense that the bug I am fixing here was not
obvious to me until it triggered a NPD. That would stop happening with
the patch I'm about to send, but maybe there are still bridge UAPI
functions that do not validate the 'permanent' flag from FDB entries.
> As I already said - this doesn't fix the null deref bug completely, in fact it fixes a different
> inconsistency, before at worst you'd get blackholed traffic for such entries now
> you get a null pointer dereference.
next prev parent reply other threads:[~2021-08-02 11:20 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-01 23:17 Vladimir Oltean
2021-08-02 7:42 ` Nikolay Aleksandrov
2021-08-02 9:20 ` Vladimir Oltean
2021-08-02 9:42 ` Nikolay Aleksandrov
2021-08-02 10:52 ` Vladimir Oltean
2021-08-02 11:02 ` Nikolay Aleksandrov
2021-08-02 11:20 ` Vladimir Oltean [this message]
2021-08-02 11:25 ` Nikolay Aleksandrov
2021-08-02 22:10 ` patchwork-bot+netdevbpf
2021-08-09 12:16 ` Ido Schimmel
2021-08-09 12:32 ` Vladimir Oltean
2021-08-09 15:33 ` Nikolay Aleksandrov
2021-08-10 6:40 ` Ido Schimmel
2021-08-10 7:21 ` [PATCH net] net: bridge: fix flags interpretation for extern learn fdb entries Nikolay Aleksandrov
2021-08-10 11:00 ` [PATCH net v2] " Nikolay Aleksandrov
2021-08-10 13:50 ` Vladimir Oltean
2021-08-10 20:20 ` patchwork-bot+netdevbpf
2021-08-09 16:05 ` [PATCH net] net: bridge: validate the NUD_PERMANENT bit when adding an extern_learn FDB entry Vladimir Oltean
2021-08-10 6:46 ` Ido Schimmel
2021-08-10 10:09 ` Vladimir Oltean
2021-08-10 10:15 ` Nikolay Aleksandrov
2021-08-10 10:38 ` Vladimir Oltean
2021-08-10 10:43 ` Nikolay Aleksandrov
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=20210802112001.rxfajfttl35bnh5s@skbuf \
--to=vladimir.oltean@nxp.com \
--cc=bridge@lists.linux-foundation.org \
--cc=davem@davemloft.net \
--cc=idosch@idosch.org \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nikolay@nvidia.com \
--cc=roopa@nvidia.com \
--cc=syzbot+9ba1174359adba5a5b7c@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--subject='Re: [PATCH net] net: bridge: validate the NUD_PERMANENT bit when adding an extern_learn FDB entry' \
/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
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).