mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 09:20:13 -04:00
platform/x86/amd/hsmp: Validate ACPI UID before parsing socket index
hsmp_get_uid() passed the device UID directly to kstrtou16(uid + 2) without checking it. A NULL UID or one shorter than three characters would dereference a NULL pointer or read past the end of the string. Reject such UIDs with -EINVAL before stripping the "ID" prefix. Signed-off-by: Muralidhara M K <muralidhara.mk@amd.com> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Link: https://patch.msgid.link/20260625123337.886435-3-muralidhara.mk@amd.com Link: https://patch.msgid.link/20260629155634.1807598-2-muralidhara.mk@amd.com Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
This commit is contained in:
committed by
Ilpo Järvinen
parent
71eb3db934
commit
4c7d1b4cd7
@@ -21,6 +21,7 @@
|
||||
#include <linux/kstrtox.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/sysfs.h>
|
||||
#include <linux/topology.h>
|
||||
#include <linux/uuid.h>
|
||||
@@ -77,6 +78,8 @@ static inline int hsmp_get_uid(struct device *dev, u16 *sock_ind)
|
||||
* bytes to integer.
|
||||
*/
|
||||
uid = acpi_device_uid(ACPI_COMPANION(dev));
|
||||
if (!uid || strlen(uid) < 3)
|
||||
return -EINVAL;
|
||||
|
||||
return kstrtou16(uid + 2, 10, sock_ind);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user