* FAILED: patch "[PATCH] PCI/ASPM: Always set link->downstream to avoid NULL" failed to apply to 4.10-stable tree
@ 2017-03-15 7:32 gregkh
2017-03-16 2:40 ` Yinghai Lu
0 siblings, 1 reply; 3+ messages in thread
From: gregkh @ 2017-03-15 7:32 UTC (permalink / raw)
To: yinghai; +Cc: stable
The patch below does not apply to the 4.10-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
>From 3bd7db63a841e8c5297bb18ad801df67d5e38ad2 Mon Sep 17 00:00:00 2001
From: Yinghai Lu <yinghai@kernel.org>
Date: Wed, 1 Mar 2017 00:25:40 -0800
Subject: [PATCH] PCI/ASPM: Always set link->downstream to avoid NULL
dereference on remove
We call pcie_aspm_exit_link_state() when we remove a device. If the device
is the last PCIe function to be removed below a bridge and the bridge has
an ASPM link_state struct, we disable ASPM on the link. Disabling ASPM
requires link->downstream (used in pcie_config_aspm_link()).
We previously set link->downstream in pcie_aspm_cap_init(), but only if the
device was not blacklisted. Removing the blacklisted device caused a NULL
pointer dereference in the pcie_aspm_exit_link_state() ->
pcie_config_aspm_link() path:
# echo 1 > /sys/bus/pci/devices/0000\:0b\:00.0/remove
...
BUG: unable to handle kernel NULL pointer dereference at 0000000000000080
IP: pcie_config_aspm_link+0x5d/0x2b0
Call Trace:
pcie_aspm_exit_link_state+0x75/0x130
pci_stop_bus_device+0xa4/0xb0
pci_stop_and_remove_bus_device_locked+0x1a/0x30
remove_store+0x50/0x70
dev_attr_store+0x18/0x30
sysfs_kf_write+0x44/0x60
kernfs_fop_write+0x10e/0x190
__vfs_write+0x28/0x110
? rcu_read_lock_sched_held+0x5d/0x80
? rcu_sync_lockdep_assert+0x2c/0x60
? __sb_start_write+0x173/0x1a0
? vfs_write+0xb3/0x180
vfs_write+0xc4/0x180
SyS_write+0x49/0xa0
do_syscall_64+0xa6/0x1c0
entry_SYSCALL64_slow_path+0x25/0x25
---[ end trace bd187ee0267df5d9 ]---
To avoid this, set link->downstream in alloc_pcie_link_state(), so every
pcie_link_state structure has a valid link->downstream pointer.
[bhelgaas: changelog]
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rajat Jain <rajatja@google.com>
CC: stable@vger.kernel.org
diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
index 973472c23d89..1dfa10cc566b 100644
--- a/drivers/pci/pcie/aspm.c
+++ b/drivers/pci/pcie/aspm.c
@@ -478,7 +478,7 @@ static void aspm_calc_l1ss_info(struct pcie_link_state *link,
static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist)
{
- struct pci_dev *child, *parent = link->pdev;
+ struct pci_dev *child = link->downstream, *parent = link->pdev;
struct pci_bus *linkbus = parent->subordinate;
struct aspm_register_info upreg, dwreg;
@@ -491,9 +491,7 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist)
/* Get upstream/downstream components' register state */
pcie_get_aspm_reg(parent, &upreg);
- child = pci_function_0(linkbus);
pcie_get_aspm_reg(child, &dwreg);
- link->downstream = child;
/*
* If ASPM not supported, don't mess with the clocks and link,
@@ -800,6 +798,7 @@ static struct pcie_link_state *alloc_pcie_link_state(struct pci_dev *pdev)
INIT_LIST_HEAD(&link->children);
INIT_LIST_HEAD(&link->link);
link->pdev = pdev;
+ link->downstream = pci_function_0(pdev->subordinate);
/*
* Root Ports and PCI/PCI-X to PCIe Bridges are roots of PCIe
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: FAILED: patch "[PATCH] PCI/ASPM: Always set link->downstream to avoid NULL" failed to apply to 4.10-stable tree
2017-03-15 7:32 FAILED: patch "[PATCH] PCI/ASPM: Always set link->downstream to avoid NULL" failed to apply to 4.10-stable tree gregkh
@ 2017-03-16 2:40 ` Yinghai Lu
2017-03-16 6:37 ` Greg Kroah-Hartman
0 siblings, 1 reply; 3+ messages in thread
From: Yinghai Lu @ 2017-03-16 2:40 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: stable@vger.kernel.org
On Wed, Mar 15, 2017 at 12:32 AM, <gregkh@linuxfoundation.org> wrote:
>
> The patch below does not apply to the 4.10-stable tree.
> If someone wants it applied there, or to any other stable or longterm
> tree, then please email the backport, including the original git commit
> id to <stable@vger.kernel.org>.
no, we don't need that for v4.10 and before.
as link->downstream is added in v4.11.
Thanks
Yinghai
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: FAILED: patch "[PATCH] PCI/ASPM: Always set link->downstream to avoid NULL" failed to apply to 4.10-stable tree
2017-03-16 2:40 ` Yinghai Lu
@ 2017-03-16 6:37 ` Greg Kroah-Hartman
0 siblings, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2017-03-16 6:37 UTC (permalink / raw)
To: Yinghai Lu; +Cc: stable@vger.kernel.org
On Wed, Mar 15, 2017 at 07:40:51PM -0700, Yinghai Lu wrote:
> On Wed, Mar 15, 2017 at 12:32 AM, <gregkh@linuxfoundation.org> wrote:
> >
> > The patch below does not apply to the 4.10-stable tree.
> > If someone wants it applied there, or to any other stable or longterm
> > tree, then please email the backport, including the original git commit
> > id to <stable@vger.kernel.org>.
>
> no, we don't need that for v4.10 and before.
>
> as link->downstream is added in v4.11.
Ok, I hate to wonder why someone taged it for stable inclusion then :(
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-03-16 6:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-15 7:32 FAILED: patch "[PATCH] PCI/ASPM: Always set link->downstream to avoid NULL" failed to apply to 4.10-stable tree gregkh
2017-03-16 2:40 ` Yinghai Lu
2017-03-16 6:37 ` Greg Kroah-Hartman
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).