summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKrzysztof Wilczyński <kw@linux.com>2021-06-03 00:01:12 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-07-20 16:17:53 +0200
commitbe6225e66f238a58c8563ac21c26c84a11b390a7 (patch)
tree88f2538cb9e3fbb86e3b04ae9cebb920b5770a4f
parentd2dad6cb060bae2b977c53f3ca39e2185bb77a49 (diff)
downloadlinux-be6225e66f238a58c8563ac21c26c84a11b390a7.tar.gz
linux-be6225e66f238a58c8563ac21c26c84a11b390a7.tar.bz2
linux-be6225e66f238a58c8563ac21c26c84a11b390a7.zip
PCI/sysfs: Fix dsm_label_utf16s_to_utf8s() buffer overrun
[ Upstream commit bdcdaa13ad96f1a530711c29e6d4b8311eff767c ] "utf16s_to_utf8s(..., buf, PAGE_SIZE)" puts up to PAGE_SIZE bytes into "buf" and returns the number of bytes it actually put there. If it wrote PAGE_SIZE bytes, the newline added by dsm_label_utf16s_to_utf8s() would overrun "buf". Reduce the size available for utf16s_to_utf8s() to use so there is always space for the newline. [bhelgaas: reorder patch in series, commit log] Fixes: 6058989bad05 ("PCI: Export ACPI _DSM provided firmware instance number and string name to sysfs") Link: https://lore.kernel.org/r/20210603000112.703037-7-kw@linux.com Reported-by: Joe Perches <joe@perches.com> Signed-off-by: Krzysztof Wilczyński <kw@linux.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/pci/pci-label.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/pci/pci-label.c b/drivers/pci/pci-label.c
index a961a71d950f..6beafc1bee96 100644
--- a/drivers/pci/pci-label.c
+++ b/drivers/pci/pci-label.c
@@ -161,7 +161,7 @@ static void dsm_label_utf16s_to_utf8s(union acpi_object *obj, char *buf)
len = utf16s_to_utf8s((const wchar_t *)obj->buffer.pointer,
obj->buffer.length,
UTF16_LITTLE_ENDIAN,
- buf, PAGE_SIZE);
+ buf, PAGE_SIZE - 1);
buf[len] = '\n';
}