]> git.itanic.dy.fi Git - linux-stable/commit
PCI/sysfs: Fix dsm_label_utf16s_to_utf8s() buffer overrun
authorKrzysztof Wilczyński <kw@linux.com>
Thu, 3 Jun 2021 00:01:12 +0000 (00:01 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 20 Jul 2021 14:22:43 +0000 (16:22 +0200)
commitcf9c734840132c44b5e687532346208027ddbc3c
treed65a095861eaa841ad9548283fe902c794c8787b
parent187f14fb88a9e62d55924748a274816fe6f34de6
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>
drivers/pci/pci-label.c