Skip to content

Commit 046ece7

Browse files
andy-shevrafaeljw
authored andcommitted
ACPI: property: Allow _DSD buffer data only for byte accessors
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: 369af6b ("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 <[email protected]> [ rjw: Add missing braces ] Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 8a749fd commit 046ece7

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

drivers/acpi/property.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,25 +1102,26 @@ static int acpi_data_prop_read(const struct acpi_device_data *data,
11021102
switch (proptype) {
11031103
case DEV_PROP_STRING:
11041104
break;
1105-
case DEV_PROP_U8 ... DEV_PROP_U64:
1105+
default:
11061106
if (obj->type == ACPI_TYPE_BUFFER) {
11071107
if (nval > obj->buffer.length)
11081108
return -EOVERFLOW;
1109-
break;
1109+
} else {
1110+
if (nval > obj->package.count)
1111+
return -EOVERFLOW;
11101112
}
1111-
fallthrough;
1112-
default:
1113-
if (nval > obj->package.count)
1114-
return -EOVERFLOW;
11151113
break;
11161114
}
11171115
if (nval == 0)
11181116
return -EINVAL;
11191117

1120-
if (obj->type != ACPI_TYPE_BUFFER)
1121-
items = obj->package.elements;
1122-
else
1118+
if (obj->type == ACPI_TYPE_BUFFER) {
1119+
if (proptype != DEV_PROP_U8)
1120+
return -EPROTO;
11231121
items = obj;
1122+
} else {
1123+
items = obj->package.elements;
1124+
}
11241125

11251126
switch (proptype) {
11261127
case DEV_PROP_U8:

0 commit comments

Comments
 (0)