[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20201012100501.33a41d8a@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>
Date: Mon, 12 Oct 2020 10:05:01 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Christian Eggers <ceggers@...i.de>
Cc: Vladimir Oltean <olteanv@...il.com>,
Woojung Huh <woojung.huh@...rochip.com>,
Microchip Linux Driver Support <UNGLinuxDriver@...rochip.com>,
Andrew Lunn <andrew@...n.ch>,
Vivien Didelot <vivien.didelot@...il.com>,
Florian Fainelli <f.fainelli@...il.com>,
"David S . Miller" <davem@...emloft.net>,
George McCollister <george.mccollister@...il.com>,
<netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [net v4] net: dsa: microchip: fix race condition
On Mon, 12 Oct 2020 10:39:42 +0200 Christian Eggers wrote:
> Between queuing the delayed work and finishing the setup of the dsa
> ports, the process may sleep in request_module() (via
> phy_device_create()) and the queued work may be executed prior to the
> switch net devices being registered. In ksz_mib_read_work(), a NULL
> dereference will happen within netof_carrier_ok(dp->slave).
>
> Not queuing the delayed work in ksz_init_mib_timer() makes things even
> worse because the work will now be queued for immediate execution
> (instead of 2000 ms) in ksz_mac_link_down() via
> dsa_port_link_register_of().
>
> Solution:
> 1. Do not queue (only initialize) delayed work in ksz_init_mib_timer().
> 2. Only queue delayed work in ksz_mac_link_down() if init is completed.
> 3. Queue work once in ksz_switch_register(), after dsa_register_switch()
> has completed.
>
> Fixes: 7c6ff470aa86 ("net: dsa: microchip: add MIB counter reading support")
> Signed-off-by: Christian Eggers <ceggers@...i.de>
> Reviewed-by: Florian Fainelli <f.fainelli@...il.com>
> Reviewed-by: Vladimir Oltean <olteanv@...il.com>
> Reviewed-by: Jakub Kicinski <kuba@...nel.org>
Now you went too far in the opposite direction, I never gave you my
explicit tag :) So I'll drop it.
Applied and queued for stable, thanks!
Powered by blists - more mailing lists