/* We may have had an error reading before, so let's retry */ if (!elog->buffer) {
elog->buffer = kzalloc(elog->size, GFP_KERNEL); if (!elog->buffer) return -EIO;
/* * As soon as the sysfs file for this elog is created/activated there is * a chance the opal_errd daemon (or any userspace) might read and * acknowledge the elog before kobject_uevent() is called. If that * happens then there is a potential race between * elog_ack_store->kobject_put() and kobject_uevent() which leads to a * use-after-free of a kernfs object resulting in a kernel crash. * * To avoid that, we need to take a reference on behalf of the bin file, * so that our reference remains valid while we call kobject_uevent(). * We then drop our reference before exiting the function, leaving the * bin file to drop the last reference (if it hasn't already).
*/
/* Take a reference for the bin file */
kobject_get(&elog->kobj);
rc = sysfs_create_bin_file(&elog->kobj, &elog->raw_attr); if (rc == 0) {
kobject_uevent(&elog->kobj, KOBJ_ADD);
} else { /* Drop the reference taken for the bin file */
kobject_put(&elog->kobj);
}
/* Drop our reference */
kobject_put(&elog->kobj);
if (elog_size >= OPAL_MAX_ERRLOG_SIZE)
elog_size = OPAL_MAX_ERRLOG_SIZE;
sprintf(name, "0x%llx", log_id);
/* we may get notified twice, let's handle * that gracefully and not create two conflicting * entries.
*/
kobj = kset_find_obj(elog_kset, name); if (kobj) { /* Drop reference added by kset_find_obj() */
kobject_put(kobj); return IRQ_HANDLED;
}
create_elog_obj(log_id, elog_size, elog_type);
return IRQ_HANDLED;
}
int __init opal_elog_init(void)
{ int rc = 0, irq;
/* ELOG not supported by firmware */ if (!opal_check_token(OPAL_ELOG_READ)) return -1;
elog_kset = kset_create_and_add("elog", NULL, opal_kobj); if (!elog_kset) {
pr_warn("%s: failed to create elog kset\n", __func__); return -1;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.