linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Skripkin <paskripkin@gmail.com>
To: davem@davemloft.net, kuba@kernel.org, andrew@lunn.ch,
	michael@walle.cc, abrodkin@synopsys.com, talz@ezchip.com,
	noamc@ezchip.com
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-kernel-mentees@lists.linuxfoundation.org,
	Pavel Skripkin <paskripkin@gmail.com>
Subject: [PATCH 1/3] net: ethernet: ezchip: fix UAF in nps_enet_remove
Date: Fri, 18 Jun 2021 19:14:31 +0300	[thread overview]
Message-ID: <b04b3823c002aac127c16472b150466afe9b38a9.1624032669.git.paskripkin@gmail.com> (raw)
In-Reply-To: <cover.1624032669.git.paskripkin@gmail.com>

priv is netdev private data, but it is used
after free_netdev(). It can cause use-after-free when accessing priv
pointer. So, fix it by moving free_netdev() after netif_napi_del()
call.

Fixes: 0dd077093636 ("NET: Add ezchip ethernet driver")
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
---
 drivers/net/ethernet/ezchip/nps_enet.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/ezchip/nps_enet.c b/drivers/net/ethernet/ezchip/nps_enet.c
index e3954d8835e7..20d2c2bb26e4 100644
--- a/drivers/net/ethernet/ezchip/nps_enet.c
+++ b/drivers/net/ethernet/ezchip/nps_enet.c
@@ -642,8 +642,8 @@ static s32 nps_enet_remove(struct platform_device *pdev)
 	struct nps_enet_priv *priv = netdev_priv(ndev);
 
 	unregister_netdev(ndev);
-	free_netdev(ndev);
 	netif_napi_del(&priv->napi);
+	free_netdev(ndev);
 
 	return 0;
 }
-- 
2.32.0


  reply	other threads:[~2021-06-18 16:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-18 16:14 [PATCH 0/3] net: ethernat: ezchip: bug fixing and code improvments Pavel Skripkin
2021-06-18 16:14 ` Pavel Skripkin [this message]
2021-06-18 16:14 ` [PATCH 2/3] net: ethernet: ezchip: remove redundant check Pavel Skripkin
2021-06-18 16:14 ` [PATCH 3/3] net: ethernet: ezchip: fix error handling Pavel Skripkin
2021-06-19 19:30 ` [PATCH 0/3] net: ethernat: ezchip: bug fixing and code improvments patchwork-bot+netdevbpf

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=b04b3823c002aac127c16472b150466afe9b38a9.1624032669.git.paskripkin@gmail.com \
    --to=paskripkin@gmail.com \
    --cc=abrodkin@synopsys.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=linux-kernel-mentees@lists.linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael@walle.cc \
    --cc=netdev@vger.kernel.org \
    --cc=noamc@ezchip.com \
    --cc=talz@ezchip.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).