netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Girish Moodalbail <girish.moodalbail@oracle.com>
To: netdev@vger.kernel.org, davem@davemloft.net
Subject: [PATCH net 1/2] ipvlan: NULL pointer dereference panic in ipvlan_port_destroy
Date: Tue, 31 Oct 2017 09:39:46 -0700	[thread overview]
Message-ID: <1509467987-20050-2-git-send-email-girish.moodalbail@oracle.com> (raw)
In-Reply-To: <1509467987-20050-1-git-send-email-girish.moodalbail@oracle.com>

When call to register_netdevice() (called from ipvlan_link_new()) fails,
we call ipvlan_uninit() (through ndo_uninit()) to destroy the ipvlan
port. Upon returning unsuccessfully from register_netdevice() we go
ahead and call ipvlan_port_destroy() again which causes NULL pointer
dereference panic. Fix it.

Signed-off-by: Girish Moodalbail <girish.moodalbail@oracle.com>
---
 drivers/net/ipvlan/ipvlan_main.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c
index c74893c..00a62a1 100644
--- a/drivers/net/ipvlan/ipvlan_main.c
+++ b/drivers/net/ipvlan/ipvlan_main.c
@@ -602,6 +602,12 @@ int ipvlan_link_new(struct net *src_net, struct net_device *dev,
 unregister_netdev:
 	unregister_netdevice(dev);
 remove_ida:
+	/* Through the call to ipvlan_uninit (ndo_uninit callback) IPvlan port
+	 * might be already destroyed in failure path in register_netdevice()
+	 * or the above call in unregister_netdevice().
+	 */
+	if (!ipvlan_port_get_rtnl(phy_dev))
+		return err;
 	ida_simple_remove(&port->ida, dev->dev_id);
 destroy_ipvlan_port:
 	if (create)
-- 
1.8.3.1

  reply	other threads:[~2017-10-31 17:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-31 16:39 [PATCH net 0/2] NULL pointer dereference in {ipvlan|macvlan}_port_destroy Girish Moodalbail
2017-10-31 16:39 ` Girish Moodalbail [this message]
2017-10-31 16:39 ` [PATCH net 2/2] macvlan: NULL pointer dereference panic in macvlan_port_destroy Girish Moodalbail
2017-11-03  5:05 ` [PATCH net 0/2] NULL pointer dereference in {ipvlan|macvlan}_port_destroy David Miller
2017-11-03 16:39   ` Girish Moodalbail

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=1509467987-20050-2-git-send-email-girish.moodalbail@oracle.com \
    --to=girish.moodalbail@oracle.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.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).