Commit d2fd6e81 authored by Logan Gunthorpe's avatar Logan Gunthorpe Committed by Bjorn Helgaas
Browse files

PCI: Fix __initdata issue with "pci=disable_acs_redir" parameter

The disable_acs_redir parameter stores a pointer to the string passed to
pci_setup().  However, the string passed to PCI setup is actually a
temporary copy allocated in static __initdata memory.  After init, once the
memory is freed, it is no longer valid to reference this pointer.

This bug was noticed in v5.0-rc1 after a change in commit c5eb1190
("PCI / PM: Allow runtime PM without callback functions") caused
pci_disable_acs_redir() to be called during shutdown which manifested
as an unable to handle kernel paging request at:

  RIP: 0010:pci_enable_acs+0x3f/0x1e0
  Call Trace:
     ? pci_restore_standard_config+0x40/0x40
     ? pci_restore_standard_config+0x40/0x40
     ? pci_conf1_read+0xb6/0xf0
     ? pci_conf1_write+0xb2/0xe0
     ? __fput+0x144/0x1d0
     ? do_writev+0x5e/0xf0

It was also likely possible to trigger this bug when hotplugging PCI

To fix this, instead of storing a pointer, we use kstrdup() to copy the
disable_acs_redir_param to its own buffer which will never be freed.

Fixes: aaca43fd

 ("PCI: Add "pci=disable_acs_redir=" parameter for peer-to-peer support")
Tested-by: default avatarJarkko Nikula <>
Signed-off-by: default avatarLogan Gunthorpe <>
Signed-off-by: default avatarBjorn Helgaas <>
Reviewed-by: default avatarJarkko Nikula <>
parent 77f88abd
...@@ -6195,7 +6195,8 @@ static int __init pci_setup(char *str) ...@@ -6195,7 +6195,8 @@ static int __init pci_setup(char *str)
} else if (!strncmp(str, "pcie_scan_all", 13)) { } else if (!strncmp(str, "pcie_scan_all", 13)) {
pci_add_flags(PCI_SCAN_ALL_PCIE_DEVS); pci_add_flags(PCI_SCAN_ALL_PCIE_DEVS);
} else if (!strncmp(str, "disable_acs_redir=", 18)) { } else if (!strncmp(str, "disable_acs_redir=", 18)) {
disable_acs_redir_param = str + 18; disable_acs_redir_param =
kstrdup(str + 18, GFP_KERNEL);
} else { } else {
printk(KERN_ERR "PCI: Unknown option `%s'\n", printk(KERN_ERR "PCI: Unknown option `%s'\n",
str); str);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment