Skip to contentSkip to conversation

ACPI: pfr_telemetry: Fix info leak in pfrt_log_ioctl()

PATCH In review Dan Carpenter 3 participants 6 messages Jan 7, 2022 – Jan 11, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ACPI: pfr_telemetry: Fix info leak in pfrt_log_ioctl()

The "data_info" struct is copied to the user. It has a 4 byte struct hole after the last struct member so we need to memset that to avoid copying uninitialized stack data to the user.

Fixes b0013e037a8b ("ACPI: Introduce Platform Firmware Runtime Telemetry driver")

---
When you're adding a new driver to the kernel then please use the new driver's prefix instead of just the subsystem prefix.

Bad: ACPI: Introduce Platform Firmware Runtime Telemetry driver
Good: ACPI / pfr_telemetry: Introduce Platform Firmware Runtime Telemetry driver

Otherwise it's just up to me to guess what prefix you wanted.

 drivers/acpi/pfr_telemetry.c | 1 +
 1 file changed, 1 insertion(+)
drivers/acpi/pfr_telemetry.c +1 -0
index da50dd80192c..9abf350bd7a5 100644
@@ -83,6 +83,7 @@ static int get_pfrt_log_data_info(struct pfrt_log_data_info *data_info,
 	union acpi_object *out_obj, in_obj, in_buf;
 	int ret = -EBUSY;
 
+	memset(data_info, 0, sizeof(*data_info));
 	memset(&in_obj, 0, sizeof(in_obj));
 	memset(&in_buf, 0, sizeof(in_buf));
 	in_obj.type = ACPI_TYPE_PACKAGE;
Signature · 1 line
2.20.1
#1 lore raw
Quoted 4 lines · Dan Carpenter

The "data_info" struct is copied to the user. It has a 4 byte struct hole after the last struct member so we need to memset that to avoid copying uninitialized stack data to the user.

Quoted 9 lines
Fixes b0013e037a8b ("ACPI: Introduce Platform Firmware Runtime Telemetry driver")

---
When you're adding a new driver to the kernel then please use the new driver's prefix instead of just the subsystem prefix.

Bad: ACPI: Introduce Platform Firmware Runtime Telemetry driver
Good: ACPI / pfr_telemetry: Introduce Platform Firmware Runtime Telemetry driver

Thanks for pointing this out.

Quoted 10 lines

Otherwise it's just up to me to guess what prefix you wanted.

 drivers/acpi/pfr_telemetry.c | 1 +
 1 file changed, 1 insertion(+)
drivers/acpi/pfr_telemetry.c +0 -0
index da50dd80192c..9abf350bd7a5 100644

drivers/acpi/pfr_telemetry.c static int get_pfrt_log_data_info(struct pfrt_log_data_info *data_info, · line 86

Quoted 4 lines
drivers/acpi/pfr_telemetry.c +1 -0
@@ -83,6 +83,7 @@ static int get_pfrt_log_data_info(struct pfrt_log_data_info *data_info,
 	union acpi_object *out_obj, in_obj, in_buf;
 	int ret = -EBUSY;
 
+	memset(data_info, 0, sizeof(*data_info));

Just one minor question, how about moving above before:
data_info->status = out_obj->package.elements[LOG_STATUS_IDX].integer.value; after the sanity check of the _DSM result?

thanks,
Chenyu

Quoted 3 lines
drivers/acpi/pfr_telemetry.c +0 -0
 	memset(&in_obj, 0, sizeof(in_obj));
 	memset(&in_buf, 0, sizeof(in_buf));
 	in_obj.type = ACPI_TYPE_PACKAGE;
#2 lore raw
Quoted 28 lines · Chen Yu
Quoted 4 lines · Dan Carpenter

The "data_info" struct is copied to the user. It has a 4 byte struct hole after the last struct member so we need to memset that to avoid copying uninitialized stack data to the user.

Quoted 9 lines
Fixes b0013e037a8b ("ACPI: Introduce Platform Firmware Runtime Telemetry driver")

---
When you're adding a new driver to the kernel then please use the new driver's prefix instead of just the subsystem prefix.

Bad: ACPI: Introduce Platform Firmware Runtime Telemetry driver
Good: ACPI / pfr_telemetry: Introduce Platform Firmware Runtime Telemetry driver

Thanks for pointing this out.

Quoted 13 lines

Otherwise it's just up to me to guess what prefix you wanted.

 drivers/acpi/pfr_telemetry.c | 1 +
 1 file changed, 1 insertion(+)
drivers/acpi/pfr_telemetry.c +0 -0
index da50dd80192c..9abf350bd7a5 100644
@@ -83,6 +83,7 @@ static int get_pfrt_log_data_info(struct pfrt_log_data_info *data_info,
 	union acpi_object *out_obj, in_obj, in_buf;
 	int ret = -EBUSY;
 
Quoted 4 lines

drivers/acpi/pfr_telemetry.c static int get_pfrt_log_data_info(struct pfrt_log_data_info *data_info, · line 86

Quoted 1 line
drivers/acpi/pfr_telemetry.c +1 -0
+	memset(data_info, 0, sizeof(*data_info));

Just one minor question, how about moving above before:
data_info->status = out_obj->package.elements[LOG_STATUS_IDX].integer.value; after the sanity check of the _DSM result?

I guess I wanted to keep all the memsets together. I feel like if the data is invalid, then it's going to be a slow path and it's not worth optimizing that case. If the data is invalid then a little slow down is the least of our concerns.

regards,
dan carpenter

#3 lore raw
Quoted 35 lines · Dan Carpenter
Quoted 28 lines · Chen Yu
Quoted 4 lines · Dan Carpenter

The "data_info" struct is copied to the user. It has a 4 byte struct hole after the last struct member so we need to memset that to avoid copying uninitialized stack data to the user.

Quoted 9 lines
Fixes b0013e037a8b ("ACPI: Introduce Platform Firmware Runtime Telemetry driver")

---
When you're adding a new driver to the kernel then please use the new driver's prefix instead of just the subsystem prefix.

Bad: ACPI: Introduce Platform Firmware Runtime Telemetry driver
Good: ACPI / pfr_telemetry: Introduce Platform Firmware Runtime Telemetry driver

Thanks for pointing this out.

Quoted 13 lines

Otherwise it's just up to me to guess what prefix you wanted.

 drivers/acpi/pfr_telemetry.c | 1 +
 1 file changed, 1 insertion(+)
drivers/acpi/pfr_telemetry.c +0 -0
index da50dd80192c..9abf350bd7a5 100644
@@ -83,6 +83,7 @@ static int get_pfrt_log_data_info(struct pfrt_log_data_info *data_info,
    union acpi_object *out_obj, in_obj, in_buf;
    int ret = -EBUSY;
 
Quoted 4 lines

drivers/acpi/pfr_telemetry.c static int get_pfrt_log_data_info(struct pfrt_log_data_info *data_info, · line 86

Quoted 1 line
drivers/acpi/pfr_telemetry.c +1 -0
+   memset(data_info, 0, sizeof(*data_info));

Just one minor question, how about moving above before:
data_info->status = out_obj->package.elements[LOG_STATUS_IDX].integer.value; after the sanity check of the _DSM result?

Quoted 4 lines

I guess I wanted to keep all the memsets together. I feel like if the data is invalid, then it's going to be a slow path and it's not worth optimizing that case. If the data is invalid then a little slow down is the least of our concerns.

Patch applied, thanks!

Yu, this series needs to spend a few days more in linux-next, because of the fixes against it sent lately.

#4 lore raw
Quoted 41 lines · Rafael J. Wysocki
Quoted 35 lines · Dan Carpenter
Quoted 28 lines · Chen Yu
Quoted 4 lines · Dan Carpenter

The "data_info" struct is copied to the user. It has a 4 byte struct hole after the last struct member so we need to memset that to avoid copying uninitialized stack data to the user.

Quoted 9 lines
Fixes b0013e037a8b ("ACPI: Introduce Platform Firmware Runtime Telemetry driver")

---
When you're adding a new driver to the kernel then please use the new driver's prefix instead of just the subsystem prefix.

Bad: ACPI: Introduce Platform Firmware Runtime Telemetry driver
Good: ACPI / pfr_telemetry: Introduce Platform Firmware Runtime Telemetry driver

Thanks for pointing this out.

Quoted 13 lines

Otherwise it's just up to me to guess what prefix you wanted.

 drivers/acpi/pfr_telemetry.c | 1 +
 1 file changed, 1 insertion(+)
drivers/acpi/pfr_telemetry.c +0 -0
index da50dd80192c..9abf350bd7a5 100644
@@ -83,6 +83,7 @@ static int get_pfrt_log_data_info(struct pfrt_log_data_info *data_info,
    union acpi_object *out_obj, in_obj, in_buf;
    int ret = -EBUSY;
 
Quoted 4 lines

drivers/acpi/pfr_telemetry.c static int get_pfrt_log_data_info(struct pfrt_log_data_info *data_info, · line 86

Quoted 1 line
drivers/acpi/pfr_telemetry.c +1 -0
+   memset(data_info, 0, sizeof(*data_info));

Just one minor question, how about moving above before:
data_info->status = out_obj->package.elements[LOG_STATUS_IDX].integer.value; after the sanity check of the _DSM result?

Quoted 4 lines

I guess I wanted to keep all the memsets together. I feel like if the data is invalid, then it's going to be a slow path and it's not worth optimizing that case. If the data is invalid then a little slow down is the least of our concerns.

Quoted 4 lines

Patch applied, thanks!

Yu, this series needs to spend a few days more in linux-next, because of the fixes against it sent lately.

Ok, I see.

thanks,
Chenyu

#5 lore raw
In reply to Dan Carpenter
Quoted 34 lines · Dan Carpenter
Quoted 28 lines · Chen Yu
Quoted 4 lines · Dan Carpenter

The "data_info" struct is copied to the user. It has a 4 byte struct hole after the last struct member so we need to memset that to avoid copying uninitialized stack data to the user.

Quoted 9 lines
Fixes b0013e037a8b ("ACPI: Introduce Platform Firmware Runtime Telemetry driver")

---
When you're adding a new driver to the kernel then please use the new driver's prefix instead of just the subsystem prefix.

Bad: ACPI: Introduce Platform Firmware Runtime Telemetry driver
Good: ACPI / pfr_telemetry: Introduce Platform Firmware Runtime Telemetry driver

Thanks for pointing this out.

Quoted 13 lines

Otherwise it's just up to me to guess what prefix you wanted.

 drivers/acpi/pfr_telemetry.c | 1 +
 1 file changed, 1 insertion(+)
drivers/acpi/pfr_telemetry.c +0 -0
index da50dd80192c..9abf350bd7a5 100644
@@ -83,6 +83,7 @@ static int get_pfrt_log_data_info(struct pfrt_log_data_info *data_info,
 	union acpi_object *out_obj, in_obj, in_buf;
 	int ret = -EBUSY;
 
Quoted 4 lines

drivers/acpi/pfr_telemetry.c static int get_pfrt_log_data_info(struct pfrt_log_data_info *data_info, · line 86

Quoted 1 line
drivers/acpi/pfr_telemetry.c +1 -0
+	memset(data_info, 0, sizeof(*data_info));

Just one minor question, how about moving above before:
data_info->status = out_obj->package.elements[LOG_STATUS_IDX].integer.value; after the sanity check of the _DSM result?

Quoted 5 lines

I guess I wanted to keep all the memsets together. I feel like if the data is invalid, then it's going to be a slow path and it's not worth optimizing that case. If the data is invalid then a little slow down is the least of our concerns.

Ok, got it.

thanks,
Chenyu

Quoted 1 line