From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
patches@lists.linux.dev, Bjorn Helgaas <bhelgaas@google.com>,
Mario Limonciello <mario.limonciello@amd.com>
Subject: [PATCH 6.3 03/13] PCI/ACPI: Validate acpi_pci_set_power_state() parameter
Date: Mon, 3 Jul 2023 20:54:13 +0200 [thread overview]
Message-ID: <20230703184519.300044205@linuxfoundation.org> (raw)
In-Reply-To: <20230703184519.206275653@linuxfoundation.org>
From: Bjorn Helgaas <bhelgaas@google.com>
commit 5557b62634abbd55bab7b154ce4bca348ad7f96f upstream.
Previously acpi_pci_set_power_state() assumed the requested power state was
valid (PCI_D0 ... PCI_D3cold). If a caller supplied something else, we
could index outside the state_conv[] array and pass junk to
acpi_device_set_power().
Validate the pci_power_t parameter and return -EINVAL if it's invalid.
Link: https://lore.kernel.org/r/20230621222857.GA122930@bhelgaas
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/pci/pci-acpi.c | 31 ++++++++++++++++++-------------
1 file changed, 18 insertions(+), 13 deletions(-)
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -1053,32 +1053,37 @@ int acpi_pci_set_power_state(struct pci_
[PCI_D3hot] = ACPI_STATE_D3_HOT,
[PCI_D3cold] = ACPI_STATE_D3_COLD,
};
- int error = -EINVAL;
+ int error;
/* If the ACPI device has _EJ0, ignore the device */
if (!adev || acpi_has_method(adev->handle, "_EJ0"))
return -ENODEV;
switch (state) {
- case PCI_D3cold:
- if (dev_pm_qos_flags(&dev->dev, PM_QOS_FLAG_NO_POWER_OFF) ==
- PM_QOS_FLAGS_ALL) {
- error = -EBUSY;
- break;
- }
- fallthrough;
case PCI_D0:
case PCI_D1:
case PCI_D2:
case PCI_D3hot:
- error = acpi_device_set_power(adev, state_conv[state]);
+ case PCI_D3cold:
+ break;
+ default:
+ return -EINVAL;
}
- if (!error)
- pci_dbg(dev, "power state changed by ACPI to %s\n",
- acpi_power_state_string(adev->power.state));
+ if (state == PCI_D3cold) {
+ if (dev_pm_qos_flags(&dev->dev, PM_QOS_FLAG_NO_POWER_OFF) ==
+ PM_QOS_FLAGS_ALL)
+ return -EBUSY;
+ }
+
+ error = acpi_device_set_power(adev, state_conv[state]);
+ if (error)
+ return error;
+
+ pci_dbg(dev, "power state changed by ACPI to %s\n",
+ acpi_power_state_string(adev->power.state));
- return error;
+ return 0;
}
pci_power_t acpi_pci_get_power_state(struct pci_dev *dev)
next prev parent reply other threads:[~2023-07-03 18:56 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-03 18:54 [PATCH 6.3 00/13] 6.3.12-rc1 review Greg Kroah-Hartman
2023-07-03 18:54 ` [PATCH 6.3 01/13] xtensa: fix lock_mm_and_find_vma in case VMA not found Greg Kroah-Hartman
2023-07-03 18:54 ` [PATCH 6.3 02/13] drm/amd/display: Do not update DRR while BW optimizations pending Greg Kroah-Hartman
2023-07-03 18:54 ` Greg Kroah-Hartman [this message]
2023-07-03 18:54 ` [PATCH 6.3 04/13] PCI/ACPI: Call _REG when transitioning D-states Greg Kroah-Hartman
2023-07-03 18:54 ` [PATCH 6.3 05/13] execve: always mark stack as growing down during early stack setup Greg Kroah-Hartman
2023-07-03 18:54 ` [PATCH 6.3 06/13] nfs: dont report STATX_BTIME in ->getattr Greg Kroah-Hartman
2023-07-03 18:54 ` [PATCH 6.3 07/13] Revert "cxl/port: Enable the HDM decoder capability for switch ports" Greg Kroah-Hartman
2023-07-03 18:54 ` [PATCH 6.3 08/13] nubus: Partially revert proc_create_single_data() conversion Greg Kroah-Hartman
2023-07-03 18:54 ` [PATCH 6.3 09/13] hugetlb: revert use of page_cache_next_miss() Greg Kroah-Hartman
2023-07-03 18:54 ` [PATCH 6.3 10/13] scripts/tags.sh: Resolve gtags empty index generation Greg Kroah-Hartman
2023-07-03 18:54 ` [PATCH 6.3 11/13] docs: Set minimal gtags / GNU GLOBAL version to 6.6.5 Greg Kroah-Hartman
2023-07-03 18:54 ` [PATCH 6.3 12/13] dm ioctl: Avoid double-fetch of version Greg Kroah-Hartman
2023-07-03 18:54 ` [PATCH 6.3 13/13] drm/amdgpu: Validate VM ioctl flags Greg Kroah-Hartman
2023-07-04 7:34 ` [PATCH 6.3 00/13] 6.3.12-rc1 review Naresh Kamboju
2023-07-04 7:43 ` Greg Kroah-Hartman
2023-07-04 8:24 ` Greg Kroah-Hartman
2023-07-04 8:39 ` Greg Kroah-Hartman
2023-07-04 8:43 ` Harshit Mogalapalli
2023-07-04 8:47 ` Greg Kroah-Hartman
2023-07-04 9:56 ` Thorsten Leemhuis
2023-07-04 12:28 ` Greg Kroah-Hartman
2023-07-05 17:36 ` Mike Kravetz
2023-07-04 10:53 ` Arnd Bergmann
2023-07-04 12:29 ` Greg Kroah-Hartman
2023-07-05 7:09 ` Conor Dooley
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=20230703184519.300044205@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=bhelgaas@google.com \
--cc=mario.limonciello@amd.com \
--cc=patches@lists.linux.dev \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox