netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4] net: ravb: Fix possible UAF bug in ravb_remove
@ 2023-07-25  3:00 Zheng Wang
  2023-07-26  3:19 ` Jakub Kicinski
  2023-08-15 10:08 ` Lee Jones
  0 siblings, 2 replies; 19+ messages in thread
From: Zheng Wang @ 2023-07-25  3:00 UTC (permalink / raw)
  To: s.shtylyov
  Cc: lee, linyunsheng, davem, edumazet, kuba, pabeni, richardcochran,
	p.zabel, geert+renesas, magnus.damm, yoshihiro.shimoda.uh,
	biju.das.jz, wsa+renesas, netdev, linux-renesas-soc, linux-kernel,
	hackerzheng666, 1395428693sheep, alex000young, Zheng Wang

In ravb_probe, priv->work was bound with ravb_tx_timeout_work.
If timeout occurs, it will start the work. And if we call
ravb_remove without finishing the work, there may be a
use-after-free bug on ndev.

Fix it by finishing the job before cleanup in ravb_remove.

Note that this bug is found by static analysis, it might be
false positive.

Fixes: c156633f1353 ("Renesas Ethernet AVB driver proper")
Signed-off-by: Zheng Wang <zyytlz.wz@163.com>
Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
v4:
- add information about the bug was found suggested by Yunsheng Lin
v3:
- fix typo in commit message
v2:
- stop dev_watchdog so that handle no more timeout work suggested by Yunsheng Lin,
add an empty line to make code clear suggested by Sergey Shtylyov
---
 drivers/net/ethernet/renesas/ravb_main.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 4d6b3b7d6abb..ce2da5101e51 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -2885,6 +2885,9 @@ static int ravb_remove(struct platform_device *pdev)
 	struct ravb_private *priv = netdev_priv(ndev);
 	const struct ravb_hw_info *info = priv->info;
 
+	netif_carrier_off(ndev);
+	netif_tx_disable(ndev);
+	cancel_work_sync(&priv->work);
 	/* Stop PTP Clock driver */
 	if (info->ccc_gac)
 		ravb_ptp_stop(ndev);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2023-10-13  8:32 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-25  3:00 [PATCH v4] net: ravb: Fix possible UAF bug in ravb_remove Zheng Wang
2023-07-26  3:19 ` Jakub Kicinski
2023-07-27  8:21   ` Paolo Abeni
2023-07-27 18:48     ` Sergey Shtylyov
2023-07-27 23:48       ` Jakub Kicinski
2023-07-28 10:32       ` Simon Horman
2023-09-20  2:37       ` Yoshihiro Shimoda
2023-09-29 20:23         ` Sergey Shtylyov
2023-10-02  0:11           ` Yoshihiro Shimoda
2023-10-03 19:39         ` Sergey Shtylyov
2023-10-04  5:05           ` Yoshihiro Shimoda
2023-10-10 12:59   ` Behme Dirk (CM/ESO2)
2023-10-12  8:39     ` Yoshihiro Shimoda
2023-10-13  6:04       ` Behme Dirk (CM/ESO2)
2023-10-13  8:32         ` Yoshihiro Shimoda
2023-08-15 10:08 ` Lee Jones
2023-08-29 13:46   ` Lee Jones
2023-08-30  4:30     ` Zheng Hacker
2023-08-31  6:46       ` Zheng Hacker

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).