Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Vladimir Oltean <firstname.lastname@example.org>
To: Nikolay Aleksandrov <email@example.com>
Cc: "firstname.lastname@example.org" <email@example.com>,
Jakub Kicinski <firstname.lastname@example.org>,
"David S. Miller" <email@example.com>,
Jiri Pirko <firstname.lastname@example.org>, Ido Schimmel <email@example.com>,
Roopa Prabhu <firstname.lastname@example.org>,
Subject: Re: [PATCH net] net: bridge: validate the NUD_PERMANENT bit when adding an extern_learn FDB entry
Date: Mon, 2 Aug 2021 10:52:33 +0000 [thread overview]
Message-ID: <20210802105233.64r23kucu4mjnjsu@skbuf> (raw)
On Mon, Aug 02, 2021 at 12:42:17PM +0300, Nikolay Aleksandrov wrote:
> >>> Before, the two commands listed above both crashed the kernel in this
> >>> check from br_switchdev_fdb_notify:
> >> Not before 52e4bec15546 though, the check used to be:
> >> struct net_device *dev = dst ? dst->dev : br->dev;
> > "Before", as in "before this patch, on net-next/linux-next".
> We still need that check, more below.
> >> which wouldn't crash. So the fixes tag below is incorrect, you could
> >> add a weird extern learn entry, but it wouldn't crash the kernel.
> > :)
> > Is our only criterion whether a patch is buggy or not that it causes a
> > NULL pointer dereference inside the kernel?
> > I thought I'd mention the interaction with the net-next work for the
> > sake of being thorough, and because this is how the syzcaller caught it
> > by coincidence, but "kernel does not treat an FDB entry with the
> > 'permanent' flag as permanent" is enough of a reason to submit this as a
> Not exactly right, you may add it as permanent but it doesn't get "permanent" flag set.
And that is the bug I am addressing here, no?
> The actual bug is that it points to the bridge device, e.g. null dst without the flag.
> > bug fix for the commit that I pointed to. Granted, I don't have any use
> > case with extern_learn, so probably your user space programs simply
> > don't add permanent FDB entries, but as this is the kernel UAPI, it
> > should nevertheless do whatever the user space is allowed to say. For a
> > permanent FDB entry, that behavior is to stop forwarding for that MAC
> > DA, and that behavior obviously was not taking place even before any
> > change in br_switchdev_fdb_notify(), or even with CONFIG_NET_SWITCHDEV=n.
> 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
(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.
> I'm okay with this change due to the null dst without permanent flag fix, but
> it doesn't fully fix the null pointer dereference.
So is there any change that I should make to this patch?
next prev parent reply other threads:[~2021-08-02 10:52 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 [this message]
2021-08-02 11:02 ` Nikolay Aleksandrov
2021-08-02 11:20 ` Vladimir Oltean
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
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:
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--subject='Re: [PATCH net] net: bridge: validate the NUD_PERMANENT bit when adding an extern_learn FDB entry' \
* 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).