Skip to content

Commit e44c42c

Browse files
avasummerij-intel
authored andcommitted
platform/x86: hp-bioscfg: Fix out-of-bounds array access in ACPI package parsing
The hp_populate_*_elements_from_package() functions in the hp-bioscfg driver contain out-of-bounds array access vulnerabilities. These functions parse ACPI packages into internal data structures using a for loop with index variable 'elem' that iterates through enum_obj/integer_obj/order_obj/password_obj/string_obj arrays. When processing multi-element fields like PREREQUISITES and ENUM_POSSIBLE_VALUES, these functions read multiple consecutive array elements using expressions like 'enum_obj[elem + reqs]' and 'enum_obj[elem + pos_values]' within nested loops. The bug is that the bounds check only validated elem, but did not consider the additional offset when accessing elem + reqs or elem + pos_values. The fix changes the bounds check to validate the actual accessed index. Reported-by: Yuhao Jiang <danisjiang@gmail.com> Reported-by: Junrui Luo <moonafterrain@outlook.com> Fixes: e6c7b3e ("platform/x86: hp-bioscfg: string-attributes") Signed-off-by: Junrui Luo <moonafterrain@outlook.com> Link: https://patch.msgid.link/SYBPR01MB788173D7DD4EA2CB6383683DAFB0A@SYBPR01MB7881.ausprd01.prod.outlook.com Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
1 parent 499d987 commit e44c42c

5 files changed

Lines changed: 14 additions & 4 deletions

File tree

drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ static int hp_populate_enumeration_elements_from_package(union acpi_object *enum
207207
case PREREQUISITES:
208208
size = min_t(u32, enum_data->common.prerequisites_size, MAX_PREREQUISITES_SIZE);
209209
for (reqs = 0; reqs < size; reqs++) {
210-
if (elem >= enum_obj_count) {
210+
if (elem + reqs >= enum_obj_count) {
211211
pr_err("Error enum-objects package is too small\n");
212212
return -EINVAL;
213213
}
@@ -255,7 +255,7 @@ static int hp_populate_enumeration_elements_from_package(union acpi_object *enum
255255

256256
for (pos_values = 0; pos_values < size && pos_values < MAX_VALUES_SIZE;
257257
pos_values++) {
258-
if (elem >= enum_obj_count) {
258+
if (elem + pos_values >= enum_obj_count) {
259259
pr_err("Error enum-objects package is too small\n");
260260
return -EINVAL;
261261
}

drivers/platform/x86/hp/hp-bioscfg/int-attributes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ static int hp_populate_integer_elements_from_package(union acpi_object *integer_
227227
size = min_t(u32, integer_data->common.prerequisites_size, MAX_PREREQUISITES_SIZE);
228228

229229
for (reqs = 0; reqs < size; reqs++) {
230-
if (elem >= integer_obj_count) {
230+
if (elem + reqs >= integer_obj_count) {
231231
pr_err("Error elem-objects package is too small\n");
232232
return -EINVAL;
233233
}

drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,11 @@ static int hp_populate_ordered_list_elements_from_package(union acpi_object *ord
216216
size = min_t(u32, ordered_list_data->common.prerequisites_size,
217217
MAX_PREREQUISITES_SIZE);
218218
for (reqs = 0; reqs < size; reqs++) {
219+
if (elem + reqs >= order_obj_count) {
220+
pr_err("Error elem-objects package is too small\n");
221+
return -EINVAL;
222+
}
223+
219224
ret = hp_convert_hexstr_to_str(order_obj[elem + reqs].string.pointer,
220225
order_obj[elem + reqs].string.length,
221226
&str_value, &value_len);

drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,11 @@ static int hp_populate_password_elements_from_package(union acpi_object *passwor
303303
MAX_PREREQUISITES_SIZE);
304304

305305
for (reqs = 0; reqs < size; reqs++) {
306+
if (elem + reqs >= password_obj_count) {
307+
pr_err("Error elem-objects package is too small\n");
308+
return -EINVAL;
309+
}
310+
306311
ret = hp_convert_hexstr_to_str(password_obj[elem + reqs].string.pointer,
307312
password_obj[elem + reqs].string.length,
308313
&str_value, &value_len);

drivers/platform/x86/hp/hp-bioscfg/string-attributes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ static int hp_populate_string_elements_from_package(union acpi_object *string_ob
217217
MAX_PREREQUISITES_SIZE);
218218

219219
for (reqs = 0; reqs < size; reqs++) {
220-
if (elem >= string_obj_count) {
220+
if (elem + reqs >= string_obj_count) {
221221
pr_err("Error elem-objects package is too small\n");
222222
return -EINVAL;
223223
}

0 commit comments

Comments
 (0)