]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
iommu/amd: Fix potential buffer overflow in parse_ivrs_acpihid
authorPavel Paklov <Pavel.Paklov@cyberprotect.ru>
Tue, 25 Mar 2025 09:22:44 +0000 (09:22 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 9 May 2025 07:43:52 +0000 (09:43 +0200)
commit13d67528e1ae4486e9ab24b70122fab104c73c29
tree1357522b12ee2839a67a30e5a7e0197cfaa407ec
parent64e95bb37916ab03dcb7a920276c5a52df8e568b
iommu/amd: Fix potential buffer overflow in parse_ivrs_acpihid

commit 8dee308e4c01dea48fc104d37f92d5b58c50b96c upstream.

There is a string parsing logic error which can lead to an overflow of hid
or uid buffers. Comparing ACPIID_LEN against a total string length doesn't
take into account the lengths of individual hid and uid buffers so the
check is insufficient in some cases. For example if the length of hid
string is 4 and the length of the uid string is 260, the length of str
will be equal to ACPIID_LEN + 1 but uid string will overflow uid buffer
which size is 256.

The same applies to the hid string with length 13 and uid string with
length 250.

Check the length of hid and uid strings separately to prevent
buffer overflow.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: ca3bf5d47cec ("iommu/amd: Introduces ivrs_acpihid kernel parameter")
Cc: stable@vger.kernel.org
Signed-off-by: Pavel Paklov <Pavel.Paklov@cyberprotect.ru>
Link: https://lore.kernel.org/r/20250325092259.392844-1-Pavel.Paklov@cyberprotect.ru
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/iommu/amd/init.c