All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	David Daney <ddaney.cavm@gmail.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	"David S. Miller" <davem@davemloft.net>
Subject: [PATCH 4.4 05/66] Revert "net: phy: Correctly process PHY_HALTED in phy_stop_machine()"
Date: Sun, 24 Sep 2017 22:31:00 +0200	[thread overview]
Message-ID: <20170924202920.810638288@linuxfoundation.org> (raw)
In-Reply-To: <20170924202920.581603259@linuxfoundation.org>

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Florian Fainelli <f.fainelli@gmail.com>


[ Upstream commit ebc8254aeae34226d0bc8fda309fd9790d4dccfe ]

This reverts commit 7ad813f208533cebfcc32d3d7474dc1677d1b09a ("net: phy:
Correctly process PHY_HALTED in phy_stop_machine()") because it is
creating the possibility for a NULL pointer dereference.

David Daney provide the following call trace and diagram of events:

When ndo_stop() is called we call:

 phy_disconnect()
    +---> phy_stop_interrupts() implies: phydev->irq = PHY_POLL;
    +---> phy_stop_machine()
    |      +---> phy_state_machine()
    |              +----> queue_delayed_work(): Work queued.
    +--->phy_detach() implies: phydev->attached_dev = NULL;

Now at a later time the queued work does:

 phy_state_machine()
    +---->netif_carrier_off(phydev->attached_dev): Oh no! It is NULL:

 CPU 12 Unable to handle kernel paging request at virtual address
0000000000000048, epc == ffffffff80de37ec, ra == ffffffff80c7c
Oops[#1]:
CPU: 12 PID: 1502 Comm: kworker/12:1 Not tainted 4.9.43-Cavium-Octeon+ #1
Workqueue: events_power_efficient phy_state_machine
task: 80000004021ed100 task.stack: 8000000409d70000
$ 0   : 0000000000000000 ffffffff84720060 0000000000000048 0000000000000004
$ 4   : 0000000000000000 0000000000000001 0000000000000004 0000000000000000
$ 8   : 0000000000000000 0000000000000000 00000000ffff98f3 0000000000000000
$12   : 8000000409d73fe0 0000000000009c00 ffffffff846547c8 000000000000af3b
$16   : 80000004096bab68 80000004096babd0 0000000000000000 80000004096ba800
$20   : 0000000000000000 0000000000000000 ffffffff81090000 0000000000000008
$24   : 0000000000000061 ffffffff808637b0
$28   : 8000000409d70000 8000000409d73cf0 80000000271bd300 ffffffff80c7804c
Hi    : 000000000000002a
Lo    : 000000000000003f
epc   : ffffffff80de37ec netif_carrier_off+0xc/0x58
ra    : ffffffff80c7804c phy_state_machine+0x48c/0x4f8
Status: 14009ce3        KX SX UX KERNEL EXL IE
Cause : 00800008 (ExcCode 02)
BadVA : 0000000000000048
PrId  : 000d9501 (Cavium Octeon III)
Modules linked in:
Process kworker/12:1 (pid: 1502, threadinfo=8000000409d70000,
task=80000004021ed100, tls=0000000000000000)
Stack : 8000000409a54000 80000004096bab68 80000000271bd300 80000000271c1e00
        0000000000000000 ffffffff808a1708 8000000409a54000 80000000271bd300
        80000000271bd320 8000000409a54030 ffffffff80ff0f00 0000000000000001
        ffffffff81090000 ffffffff808a1ac0 8000000402182080 ffffffff84650000
        8000000402182080 ffffffff84650000 ffffffff80ff0000 8000000409a54000
        ffffffff808a1970 0000000000000000 80000004099e8000 8000000402099240
        0000000000000000 ffffffff808a8598 0000000000000000 8000000408eeeb00
        8000000409a54000 00000000810a1d00 0000000000000000 8000000409d73de8
        8000000409d73de8 0000000000000088 000000000c009c00 8000000409d73e08
        8000000409d73e08 8000000402182080 ffffffff808a84d0 8000000402182080
        ...
Call Trace:
[<ffffffff80de37ec>] netif_carrier_off+0xc/0x58
[<ffffffff80c7804c>] phy_state_machine+0x48c/0x4f8
[<ffffffff808a1708>] process_one_work+0x158/0x368
[<ffffffff808a1ac0>] worker_thread+0x150/0x4c0
[<ffffffff808a8598>] kthread+0xc8/0xe0
[<ffffffff808617f0>] ret_from_kernel_thread+0x14/0x1c

The original motivation for this change originated from Marc Gonzales
indicating that his network driver did not have its adjust_link callback
executing with phydev->link = 0 while he was expecting it.

PHYLIB has never made any such guarantees ever because phy_stop() merely just
tells the workqueue to move into PHY_HALTED state which will happen
asynchronously.

Reported-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reported-by: David Daney <ddaney.cavm@gmail.com>
Fixes: 7ad813f20853 ("net: phy: Correctly process PHY_HALTED in phy_stop_machine()")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/net/phy/phy.c |    3 ---
 1 file changed, 3 deletions(-)

--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -541,9 +541,6 @@ void phy_stop_machine(struct phy_device
 	if (phydev->state > PHY_UP && phydev->state != PHY_HALTED)
 		phydev->state = PHY_UP;
 	mutex_unlock(&phydev->lock);
-
-	/* Now we can run the state machine synchronously */
-	phy_state_machine(&phydev->state_queue.work);
 }
 
 /**

  parent reply	other threads:[~2017-09-24 20:35 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-24 20:30 [PATCH 4.4 00/66] 4.4.89-stable review Greg Kroah-Hartman
2017-09-24 20:30 ` [PATCH 4.4 01/66] ipv6: accept 64k - 1 packet length in ip6_find_1stfragopt() Greg Kroah-Hartman
2017-09-24 20:30 ` [PATCH 4.4 02/66] ipv6: add rcu grace period before freeing fib6_node Greg Kroah-Hartman
2017-09-24 20:30 ` [PATCH 4.4 03/66] ipv6: fix sparse warning on rt6i_node Greg Kroah-Hartman
2017-09-24 20:30 ` [PATCH 4.4 04/66] qlge: avoid memcpy buffer overflow Greg Kroah-Hartman
2017-09-24 20:31 ` Greg Kroah-Hartman [this message]
2017-09-24 20:31 ` [PATCH 4.4 06/66] tcp: initialize rcv_mss to TCP_MIN_MSS instead of 0 Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 07/66] Revert "net: use lib/percpu_counter API for fragmentation mem accounting" Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 08/66] Revert "net: fix percpu memory leaks" Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 09/66] gianfar: Fix Tx flow control deactivation Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 10/66] ipv6: fix memory leak with multiple tables during netns destruction Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 11/66] ipv6: fix typo in fib6_net_exit() Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 12/66] f2fs: check hot_data for roll-forward recovery Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 13/66] x86/fsgsbase/64: Report FSBASE and GSBASE correctly in core dumps Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 14/66] md/raid5: release/flush io in raid5_do_work() Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 15/66] nfsd: Fix general protection fault in release_lock_stateid() Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 16/66] mm: prevent double decrease of nr_reserved_highatomic Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 17/66] tty: improve tty_insert_flip_char() fast path Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 18/66] tty: improve tty_insert_flip_char() slow path Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 19/66] tty: fix __tty_insert_flip_char regression Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 20/66] Input: i8042 - add Gigabyte P57 to the keyboard reset table Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 21/66] MIPS: math-emu: <MAX|MAXA|MIN|MINA>.<D|S>: Fix quiet NaN propagation Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 22/66] MIPS: math-emu: <MAX|MAXA|MIN|MINA>.<D|S>: Fix cases of both inputs zero Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 23/66] MIPS: math-emu: <MAX|MIN>.<D|S>: Fix cases of both inputs negative Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 24/66] MIPS: math-emu: <MAXA|MINA>.<D|S>: Fix cases of input values with opposite signs Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 25/66] MIPS: math-emu: <MAXA|MINA>.<D|S>: Fix cases of both infinite inputs Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 26/66] MIPS: math-emu: MINA.<D|S>: Fix some cases of infinity and zero inputs Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 27/66] [PATCH - RESEND] crypto: AF_ALG - remove SGL terminator indicator when chaining Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 28/66] ext4: fix incorrect quotaoff if the quota feature is enabled Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 29/66] ext4: fix quota inconsistency during orphan cleanup for read-only mounts Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 30/66] powerpc: Fix DAR reporting when alignment handler faults Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 31/66] block: Relax a check in blk_start_queue() Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 32/66] md/bitmap: disable bitmap_resize for file-backed bitmaps Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 33/66] skd: Avoid that module unloading triggers a use-after-free Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 34/66] skd: Submit requests to firmware before triggering the doorbell Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 35/66] scsi: zfcp: fix queuecommand for scsi_eh commands when DIX enabled Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 36/66] scsi: zfcp: add handling for FCP_RESID_OVER to the fcp ingress path Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 37/66] scsi: zfcp: fix capping of unsuccessful GPN_FT SAN response trace records Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 38/66] scsi: zfcp: fix passing fsf_req to SCSI trace on TMF to correlate with HBA Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 39/66] scsi: zfcp: fix missing trace records for early returns in TMF eh handlers Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 40/66] scsi: zfcp: fix payload with full FCP_RSP IU in SCSI trace records Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 41/66] scsi: zfcp: trace HBA FSF response by default on dismiss or timedout late response Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 42/66] scsi: zfcp: trace high part of "new" 64 bit SCSI LUN Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 43/66] scsi: megaraid_sas: Check valid aen class range to avoid kernel panic Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 44/66] scsi: megaraid_sas: Return pended IOCTLs with cmd_status MFI_STAT_WRONG_STATE in case adapter is dead Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 45/66] scsi: storvsc: fix memory leak on ring buffer busy Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 46/66] scsi: sg: remove save_scat_len Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 47/66] scsi: sg: use standard lists for sg_requests Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 48/66] scsi: sg: off by one in sg_ioctl() Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 49/66] scsi: sg: factor out sg_fill_request_table() Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 50/66] scsi: sg: fixup infoleak when using SG_GET_REQUEST_TABLE Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 51/66] scsi: qla2xxx: Fix an integer overflow in sysfs code Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 52/66] ftrace: Fix selftest goto location on error Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 53/66] tracing: Apply trace_clock changes to instance max buffer Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 54/66] ARC: Re-enable MMU upon Machine Check exception Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 55/66] PCI: shpchp: Enable bridge bus mastering if MSI is enabled Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 56/66] media: v4l2-compat-ioctl32: Fix timespec conversion Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 57/66] media: uvcvideo: Prevent heap overflow when accessing mapped controls Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 58/66] bcache: initialize dirty stripes in flash_dev_run() Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 59/66] bcache: Fix leak of bdev reference Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 60/66] bcache: do not subtract sectors_to_gc for bypassed IO Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 61/66] bcache: correct cache_dirty_target in __update_writeback_rate() Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 62/66] bcache: Correct return value for sysfs attach errors Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 63/66] bcache: fix for gc and write-back race Greg Kroah-Hartman
2017-09-24 20:31 ` [PATCH 4.4 64/66] bcache: fix bch_hprint crash and improve output Greg Kroah-Hartman
2017-09-24 20:32 ` [PATCH 4.4 65/66] ftrace: Fix memleak when unregistering dynamic ops when tracing disabled Greg Kroah-Hartman
2017-09-24 20:32 ` [PATCH 4.4 66/66] mac80211: flush hw_roc_start work before cancelling the ROC Greg Kroah-Hartman
2017-09-25  1:04 ` [PATCH 4.4 00/66] 4.4.89-stable review Guenter Roeck
2017-09-25 23:12 ` Shuah Khan

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=20170924202920.810638288@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=davem@davemloft.net \
    --cc=ddaney.cavm@gmail.com \
    --cc=f.fainelli@gmail.com \
    --cc=geert+renesas@glider.be \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.