netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nikolay Aleksandrov <razor@blackwall.org>
To: netdev@vger.kernel.org
Cc: stephen@networkplumber.org, davem@davemloft.net,
	nikolay@cumulusnetworks.com, idosch@mellanox.com,
	roopa@cumulusnetworks.com
Subject: [PATCH net-next 1/2] bridge: vlan: Prevent possible use-after-free
Date: Fri, 30 Oct 2015 17:46:19 +0100	[thread overview]
Message-ID: <1446223580-1464-2-git-send-email-razor@blackwall.org> (raw)
In-Reply-To: <1446223580-1464-1-git-send-email-razor@blackwall.org>

From: Ido Schimmel <idosch@mellanox.com>

When adding a port to a bridge we initialize VLAN filtering on it. We do
not bail out in case an error occurred in nbp_vlan_init, as it can be
used as a non VLAN filtering bridge.

However, if VLAN filtering is required and an error occurred in
nbp_vlan_init, we should set vlgrp to NULL, so that VLAN filtering
functions (e.g. br_vlan_find, br_get_pvid) will know the struct is
invalid and will not try to access it.

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
---
 net/bridge/br_vlan.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c
index 5f0d0cc4744f..1054696323d7 100644
--- a/net/bridge/br_vlan.c
+++ b/net/bridge/br_vlan.c
@@ -914,6 +914,8 @@ out:
 	return ret;
 
 err_vlan_add:
+	RCU_INIT_POINTER(p->vlgrp, NULL);
+	synchronize_rcu();
 	rhashtable_destroy(&vg->vlan_hash);
 err_rhtbl:
 	kfree(vg);
-- 
2.4.3

  reply	other threads:[~2015-10-30 16:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-30 16:46 [PATCH net-next 0/2] bridge: vlan: failure path and comment fixes Nikolay Aleksandrov
2015-10-30 16:46 ` Nikolay Aleksandrov [this message]
2015-10-30 16:46 ` [PATCH net-next 2/2] bridge: vlan: Use correct flag name in comment Nikolay Aleksandrov
2015-11-02 20:40 ` [PATCH net-next 0/2] bridge: vlan: failure path and comment fixes 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=1446223580-1464-2-git-send-email-razor@blackwall.org \
    --to=razor@blackwall.org \
    --cc=davem@davemloft.net \
    --cc=idosch@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=nikolay@cumulusnetworks.com \
    --cc=roopa@cumulusnetworks.com \
    --cc=stephen@networkplumber.org \
    /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).