提交 ce5eb073 编写于 作者: D David E. Box 提交者: Rafael J. Wysocki

ACPICA: Utilities: Validate full RSDP header

Implement proper RSDP validation in acpi_ut_read_table(). Prevents a segmentation
fault that can occur if a user passes the wrong file to iasl.

This patch is only useful for iasl, which is not shipped in the Linux
kernel.

After the new table reading utility functions are well tested, acpidump can
also switch to use the generic acpi_ut_read_table_xxx() APIs. Currently
this patch is no-op as acpidump does not link to the new APIs.
Signed-off-by: NDavid E. Box <david.e.box@linux.intel.com>
Signed-off-by: NBob Moore <robert.moore@intel.com>
Signed-off-by: NLv Zheng <lv.zheng@intel.com>
Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
上级 e740304c
...@@ -150,6 +150,7 @@ acpi_ut_read_table(FILE * fp, ...@@ -150,6 +150,7 @@ acpi_ut_read_table(FILE * fp,
acpi_status status; acpi_status status;
u32 file_size; u32 file_size;
u8 standard_header = TRUE; u8 standard_header = TRUE;
s32 count;
/* Get the file size */ /* Get the file size */
...@@ -164,27 +165,21 @@ acpi_ut_read_table(FILE * fp, ...@@ -164,27 +165,21 @@ acpi_ut_read_table(FILE * fp,
/* Read the signature */ /* Read the signature */
if (fread(&table_header, 1, 4, fp) != 4) { fseek(fp, 0, SEEK_SET);
acpi_os_printf("Could not read the table signature\n");
count = fread(&table_header, 1, sizeof(struct acpi_table_header), fp);
if (count != sizeof(struct acpi_table_header)) {
acpi_os_printf("Could not read the table header\n");
return (AE_BAD_HEADER); return (AE_BAD_HEADER);
} }
fseek(fp, 0, SEEK_SET);
/* The RSDP table does not have standard ACPI header */ /* The RSDP table does not have standard ACPI header */
if (ACPI_COMPARE_NAME(table_header.signature, "RSD ")) { if (ACPI_VALIDATE_RSDP_SIG(table_header.signature)) {
*table_length = file_size; *table_length = file_size;
standard_header = FALSE; standard_header = FALSE;
} else { } else {
/* Read the table header */
if (fread
(&table_header, 1, sizeof(struct acpi_table_header),
fp) != sizeof(struct acpi_table_header)) {
acpi_os_printf("Could not read the table header\n");
return (AE_BAD_HEADER);
}
#if 0 #if 0
/* Validate the table header/length */ /* Validate the table header/length */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册