mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-28 13:22:57 +00:00
ACPI: property: Allow _DSD buffer data only for byte accessors
[ Upstream commit046ece773c
] In accordance with ACPI specificication and _DSD data buffer representation the data there is an array of bytes. Hence, accessing it with something longer will create a sparse data which is against of how device property APIs work in general and also not defined in the ACPI specification (see [1]). Fix the code to emit an error if non-byte accessor is used to retrieve _DSD buffer data. Fixes:369af6bf2c
("ACPI: property: Read buffer properties as integers") Link: https://uefi.org/specs/ACPI/6.5/19_ASL_Reference.html#buffer-declare-buffer-object # [1] Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> [ rjw: Add missing braces ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
75de6a6641
commit
396ec51b13
1 changed files with 10 additions and 9 deletions
|
@ -1114,25 +1114,26 @@ static int acpi_data_prop_read(const struct acpi_device_data *data,
|
||||||
switch (proptype) {
|
switch (proptype) {
|
||||||
case DEV_PROP_STRING:
|
case DEV_PROP_STRING:
|
||||||
break;
|
break;
|
||||||
case DEV_PROP_U8 ... DEV_PROP_U64:
|
default:
|
||||||
if (obj->type == ACPI_TYPE_BUFFER) {
|
if (obj->type == ACPI_TYPE_BUFFER) {
|
||||||
if (nval > obj->buffer.length)
|
if (nval > obj->buffer.length)
|
||||||
return -EOVERFLOW;
|
return -EOVERFLOW;
|
||||||
break;
|
} else {
|
||||||
|
if (nval > obj->package.count)
|
||||||
|
return -EOVERFLOW;
|
||||||
}
|
}
|
||||||
fallthrough;
|
|
||||||
default:
|
|
||||||
if (nval > obj->package.count)
|
|
||||||
return -EOVERFLOW;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (nval == 0)
|
if (nval == 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (obj->type != ACPI_TYPE_BUFFER)
|
if (obj->type == ACPI_TYPE_BUFFER) {
|
||||||
items = obj->package.elements;
|
if (proptype != DEV_PROP_U8)
|
||||||
else
|
return -EPROTO;
|
||||||
items = obj;
|
items = obj;
|
||||||
|
} else {
|
||||||
|
items = obj->package.elements;
|
||||||
|
}
|
||||||
|
|
||||||
switch (proptype) {
|
switch (proptype) {
|
||||||
case DEV_PROP_U8:
|
case DEV_PROP_U8:
|
||||||
|
|
Loading…
Reference in a new issue