netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: hancock@sedsystems.ca
To: "Heiner Kallweit" <hkallweit1@gmail.com>
Cc: "Andrew Lunn" <andrew@lunn.ch>,
	"Robert Hancock" <hancock@sedsystems.ca>,
	netdev@vger.kernel.org, "Florian Fainelli" <f.fainelli@gmail.com>
Subject: Re: [PATCH net-next] net: phy: Ensure scheduled work is cancelled  during removal
Date: Fri, 31 May 2019 21:22:16 -0600 (CST)	[thread overview]
Message-ID: <8fc39ed123aede7ab23954ba06ff4cd5.squirrel@intranet.sedsystems.ca> (raw)
In-Reply-To: <49e18fde-5ac4-22ad-90ec-0cbad64d743a@gmail.com>

> On 31.05.2019 22:54, Andrew Lunn wrote:
>>> It is possible that scheduled work started by the PHY driver is still
>>> outstanding when phy_device_remove is called if the PHY was initially
>>> started but never connected, and therefore phy_disconnect is never
>>> called. phy_stop does not guarantee that the scheduled work is stopped
>>> because it is called under rtnl_lock. This can cause an oops due to
>>> use-after-free if the delayed work fires after freeing the PHY device.
>>>
> The patch itself at least shouldn't do any harm. However the justification
> isn't fully convincing yet.
> PHY drivers don't start any scheduled work. This queue is used by the
> phylib state machine. phy_stop usually isn't called under rtnl_lock,
> and it calls phy_stop_machine that cancels pending work.
> Did you experience such an oops? Can you provide a call chain where
> your described scenario could happen?

Upon further investigation, it appears that this change is no longer
needed in the mainline. Previously (such as in 4.19 kernels as we are
using), phy_stop did not call phy_stop_machine, only phy_disconnect did,
so if the phy was started but never connected and disconnected before
stopping it, the delayed work was not stopped. That sequence didn't occur
often, but could happen in some failure cases which I believe was what I
ran into during development when this change was originally made.

It looks like this was fixed in commit
cbfd12b3e8c3542e8142aa041714ed614d3f67b0 "net: phy: ensure phylib state
machine is stopped after calling phy_stop". So my patch can be dropped -
but maybe that patch should be added to stable?


  reply	other threads:[~2019-06-01  3:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-31 19:15 [PATCH net-next] net: phy: xilinx: add Xilinx PHY driver Robert Hancock
2019-05-31 19:15 ` [PATCH net-next] net: phy: Ensure scheduled work is cancelled during removal Robert Hancock
2019-05-31 20:54   ` Andrew Lunn
2019-05-31 21:26     ` Heiner Kallweit
2019-06-01  3:22       ` hancock [this message]
2019-06-01 15:46         ` Andrew Lunn
2019-05-31 20:52 ` [PATCH net-next] net: phy: xilinx: add Xilinx PHY driver Andrew Lunn
2019-05-31 21:11 ` Florian Fainelli

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=8fc39ed123aede7ab23954ba06ff4cd5.squirrel@intranet.sedsystems.ca \
    --to=hancock@sedsystems.ca \
    --cc=andrew@lunn.ch \
    --cc=f.fainelli@gmail.com \
    --cc=hkallweit1@gmail.com \
    --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).