* [patch net] rocker: fix possible null pointer dereference in rocker_router_fib_event_work
@ 2018-02-01 11:21 Jiri Pirko
2018-02-01 14:52 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Jiri Pirko @ 2018-02-01 11:21 UTC (permalink / raw)
To: netdev; +Cc: davem, mlxsw
From: Jiri Pirko <jiri@mellanox.com>
Currently, rocker user may experience following null pointer
derefence bug:
[ 3.062141] BUG: unable to handle kernel NULL pointer dereference at 00000000000000d0
[ 3.065163] IP: rocker_router_fib_event_work+0x36/0x110 [rocker]
The problem is uninitialized rocker->wops pointer that is initialized
only with the first initialized port. So move the port initialization
before registering the fib events.
Fixes: 936bd486564a ("rocker: use FIB notifications instead of switchdev calls")
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
drivers/net/ethernet/rocker/rocker_main.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/rocker/rocker_main.c b/drivers/net/ethernet/rocker/rocker_main.c
index fc8f8bdf6579..056cb6093630 100644
--- a/drivers/net/ethernet/rocker/rocker_main.c
+++ b/drivers/net/ethernet/rocker/rocker_main.c
@@ -2902,6 +2902,12 @@ static int rocker_probe(struct pci_dev *pdev, const struct pci_device_id *id)
goto err_alloc_ordered_workqueue;
}
+ err = rocker_probe_ports(rocker);
+ if (err) {
+ dev_err(&pdev->dev, "failed to probe ports\n");
+ goto err_probe_ports;
+ }
+
/* Only FIBs pointing to our own netdevs are programmed into
* the device, so no need to pass a callback.
*/
@@ -2918,22 +2924,16 @@ static int rocker_probe(struct pci_dev *pdev, const struct pci_device_id *id)
rocker->hw.id = rocker_read64(rocker, SWITCH_ID);
- err = rocker_probe_ports(rocker);
- if (err) {
- dev_err(&pdev->dev, "failed to probe ports\n");
- goto err_probe_ports;
- }
-
dev_info(&pdev->dev, "Rocker switch with id %*phN\n",
(int)sizeof(rocker->hw.id), &rocker->hw.id);
return 0;
-err_probe_ports:
- unregister_switchdev_notifier(&rocker_switchdev_notifier);
err_register_switchdev_notifier:
unregister_fib_notifier(&rocker->fib_nb);
err_register_fib_notifier:
+ rocker_remove_ports(rocker);
+err_probe_ports:
destroy_workqueue(rocker->rocker_owq);
err_alloc_ordered_workqueue:
free_irq(rocker_msix_vector(rocker, ROCKER_MSIX_VEC_EVENT), rocker);
@@ -2961,9 +2961,9 @@ static void rocker_remove(struct pci_dev *pdev)
{
struct rocker *rocker = pci_get_drvdata(pdev);
- rocker_remove_ports(rocker);
unregister_switchdev_notifier(&rocker_switchdev_notifier);
unregister_fib_notifier(&rocker->fib_nb);
+ rocker_remove_ports(rocker);
rocker_write32(rocker, CONTROL, ROCKER_CONTROL_RESET);
destroy_workqueue(rocker->rocker_owq);
free_irq(rocker_msix_vector(rocker, ROCKER_MSIX_VEC_EVENT), rocker);
--
2.14.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [patch net] rocker: fix possible null pointer dereference in rocker_router_fib_event_work
2018-02-01 11:21 [patch net] rocker: fix possible null pointer dereference in rocker_router_fib_event_work Jiri Pirko
@ 2018-02-01 14:52 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2018-02-01 14:52 UTC (permalink / raw)
To: jiri; +Cc: netdev, mlxsw
From: Jiri Pirko <jiri@resnulli.us>
Date: Thu, 1 Feb 2018 12:21:15 +0100
> From: Jiri Pirko <jiri@mellanox.com>
>
> Currently, rocker user may experience following null pointer
> derefence bug:
>
> [ 3.062141] BUG: unable to handle kernel NULL pointer dereference at 00000000000000d0
> [ 3.065163] IP: rocker_router_fib_event_work+0x36/0x110 [rocker]
>
> The problem is uninitialized rocker->wops pointer that is initialized
> only with the first initialized port. So move the port initialization
> before registering the fib events.
>
> Fixes: 936bd486564a ("rocker: use FIB notifications instead of switchdev calls")
> Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Applied and queued up for -stable, thanks Jiri.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-02-01 14:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-01 11:21 [patch net] rocker: fix possible null pointer dereference in rocker_router_fib_event_work Jiri Pirko
2018-02-01 14:52 ` David Miller
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).