Commit 456d8aa
PCI/ASPM: Disable ASPM on MFD function removal to avoid use-after-free
Struct pcie_link_state->downstream is a pointer to the pci_dev of function
0. Previously we retained that pointer when removing function 0, and
subsequent ASPM policy changes dereferenced it, resulting in a
use-after-free warning from KASAN, e.g.:
# echo 1 > /sys/bus/pci/devices/0000:03:00.0/remove
# echo powersave > /sys/module/pcie_aspm/parameters/policy
BUG: KASAN: slab-use-after-free in pcie_config_aspm_link+0x42d/0x500
Call Trace:
kasan_report+0xae/0xe0
pcie_config_aspm_link+0x42d/0x500
pcie_aspm_set_policy+0x8e/0x1a0
param_attr_store+0x162/0x2c0
module_attr_store+0x3e/0x80
PCIe spec r6.0, sec 7.5.3.7, recommends that software program the same ASPM
Control value in all functions of multi-function devices.
Disable ASPM and free the pcie_link_state when any child function is
removed so we can discard the dangling pcie_link_state->downstream pointer
and maintain the same ASPM Control configuration for all functions.
[bhelgaas: commit log and comment]
Debugged-by: Zongquan Qin <[email protected]>
Suggested-by: Bjorn Helgaas <[email protected]>
Fixes: b5a0a9b ("PCI/ASPM: Read and set up L1 substate capabilities")
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Ding Hui <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>1 parent ac9a786 commit 456d8aa
1 file changed
+12
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1010 | 1010 | | |
1011 | 1011 | | |
1012 | 1012 | | |
1013 | | - | |
1014 | | - | |
1015 | | - | |
1016 | | - | |
1017 | | - | |
1018 | | - | |
1019 | 1013 | | |
1020 | 1014 | | |
1021 | 1015 | | |
1022 | 1016 | | |
1023 | 1017 | | |
1024 | | - | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
1025 | 1029 | | |
1026 | 1030 | | |
1027 | | - | |
1028 | 1031 | | |
1029 | 1032 | | |
1030 | 1033 | | |
1031 | 1034 | | |
1032 | 1035 | | |
1033 | 1036 | | |
1034 | 1037 | | |
1035 | | - | |
| 1038 | + | |
1036 | 1039 | | |
1037 | 1040 | | |
1038 | 1041 | | |
| |||
0 commit comments