static void acpi_db_test_all_objects(void) { acpi_status status; /* Install the debugger read-object control method if necessary */ if (!read_handle) { status = acpi_install_method(read_method_code); if (ACPI_FAILURE(status)) { acpi_os_printf ("%s, Could not install debugger read method\n", acpi_format_exception(status)); return; } status = acpi_get_handle(NULL, ACPI_DB_READ_METHOD, &read_handle); if (ACPI_FAILURE(status)) { acpi_os_printf ("Could not obtain handle for debug method %s\n", ACPI_DB_READ_METHOD); return; } } /* Install the debugger write-object control method if necessary */ if (!write_handle) { status = acpi_install_method(write_method_code); if (ACPI_FAILURE(status)) { acpi_os_printf ("%s, Could not install debugger write method\n", acpi_format_exception(status)); return; } status = acpi_get_handle(NULL, ACPI_DB_WRITE_METHOD, &write_handle); if (ACPI_FAILURE(status)) { acpi_os_printf ("Could not obtain handle for debug method %s\n", ACPI_DB_WRITE_METHOD); return; } } /* Walk the entire namespace, testing each supported named data object */ (void)acpi_walk_namespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, acpi_db_test_one_object, NULL, NULL, NULL); }
static ssize_t cm_write(struct file *file, const char __user * user_buf, size_t count, loff_t *ppos) { static char *buf; static u32 max_size; static u32 uncopied_bytes; struct acpi_table_header table; acpi_status status; #ifdef CONFIG_GRKERNSEC_KMEM return -EPERM; #endif if (!(*ppos)) { /* parse the table header to get the table length */ if (count <= sizeof(struct acpi_table_header)) return -EINVAL; if (copy_from_user(&table, user_buf, sizeof(struct acpi_table_header))) return -EFAULT; uncopied_bytes = max_size = table.length; buf = kzalloc(max_size, GFP_KERNEL); if (!buf) return -ENOMEM; } if (buf == NULL) return -EINVAL; if ((*ppos > max_size) || (*ppos + count > max_size) || (*ppos + count < count) || (count > uncopied_bytes)) return -EINVAL; if (copy_from_user(buf + (*ppos), user_buf, count)) { kfree(buf); buf = NULL; return -EFAULT; } uncopied_bytes -= count; *ppos += count; if (!uncopied_bytes) { status = acpi_install_method(buf); kfree(buf); buf = NULL; if (ACPI_FAILURE(status)) return -EINVAL; add_taint(TAINT_OVERRIDDEN_ACPI_TABLE, LOCKDEP_NOW_UNRELIABLE); } return count; }
static ssize_t cm_write(struct file *file, const char __user * user_buf, size_t count, loff_t *ppos) { static char *buf; static int uncopied_bytes; struct acpi_table_header table; acpi_status status; if (!(*ppos)) { /* parse the table header to get the table length */ if (count <= sizeof(struct acpi_table_header)) return -EINVAL; if (copy_from_user(&table, user_buf, sizeof(struct acpi_table_header))) return -EFAULT; uncopied_bytes = table.length; buf = kzalloc(uncopied_bytes, GFP_KERNEL); if (!buf) return -ENOMEM; } if (uncopied_bytes < count) { kfree(buf); return -EINVAL; } if (copy_from_user(buf + (*ppos), user_buf, count)) { kfree(buf); return -EFAULT; } uncopied_bytes -= count; *ppos += count; if (!uncopied_bytes) { status = acpi_install_method(buf); kfree(buf); if (ACPI_FAILURE(status)) return -EINVAL; add_taint(TAINT_OVERRIDDEN_ACPI_TABLE); } return count; }