Skip to content

Commit 0740040

Browse files
committed
Merge tag 'for-linus-5.16-3' of git://github.com/cminyard/linux-ipmi
Pull IPMI fixes from Corey Minyard: "Fix some IPMI crashes Some crash fixes have come in dealing with various error handling issues. They have sat in next for 5 days or more without issue, and they are fairly critical" * tag 'for-linus-5.16-3' of git://github.com/cminyard/linux-ipmi: ipmi: Fix UAF when uninstall ipmi_si and ipmi_msghandler module ipmi: fix initialization when workqueue allocation fails ipmi: bail out if init_srcu_struct fails ipmi: ssif: initialize ssif_info->client early
2 parents c9ea870 + ffb76a8 commit 0740040

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

drivers/char/ipmi/ipmi_msghandler.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3031,7 +3031,7 @@ cleanup_bmc_device(struct kref *ref)
30313031
* with removing the device attributes while reading a device
30323032
* attribute.
30333033
*/
3034-
schedule_work(&bmc->remove_work);
3034+
queue_work(remove_work_wq, &bmc->remove_work);
30353035
}
30363036

30373037
/*
@@ -5392,22 +5392,27 @@ static int ipmi_init_msghandler(void)
53925392
if (initialized)
53935393
goto out;
53945394

5395-
init_srcu_struct(&ipmi_interfaces_srcu);
5396-
5397-
timer_setup(&ipmi_timer, ipmi_timeout, 0);
5398-
mod_timer(&ipmi_timer, jiffies + IPMI_TIMEOUT_JIFFIES);
5399-
5400-
atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
5395+
rv = init_srcu_struct(&ipmi_interfaces_srcu);
5396+
if (rv)
5397+
goto out;
54015398

54025399
remove_work_wq = create_singlethread_workqueue("ipmi-msghandler-remove-wq");
54035400
if (!remove_work_wq) {
54045401
pr_err("unable to create ipmi-msghandler-remove-wq workqueue");
54055402
rv = -ENOMEM;
5406-
goto out;
5403+
goto out_wq;
54075404
}
54085405

5406+
timer_setup(&ipmi_timer, ipmi_timeout, 0);
5407+
mod_timer(&ipmi_timer, jiffies + IPMI_TIMEOUT_JIFFIES);
5408+
5409+
atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
5410+
54095411
initialized = true;
54105412

5413+
out_wq:
5414+
if (rv)
5415+
cleanup_srcu_struct(&ipmi_interfaces_srcu);
54115416
out:
54125417
mutex_unlock(&ipmi_interfaces_mutex);
54135418
return rv;

drivers/char/ipmi/ipmi_ssif.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,6 +1659,9 @@ static int ssif_probe(struct i2c_client *client, const struct i2c_device_id *id)
16591659
}
16601660
}
16611661

1662+
ssif_info->client = client;
1663+
i2c_set_clientdata(client, ssif_info);
1664+
16621665
rv = ssif_check_and_remove(client, ssif_info);
16631666
/* If rv is 0 and addr source is not SI_ACPI, continue probing */
16641667
if (!rv && ssif_info->addr_source == SI_ACPI) {
@@ -1679,9 +1682,6 @@ static int ssif_probe(struct i2c_client *client, const struct i2c_device_id *id)
16791682
ipmi_addr_src_to_str(ssif_info->addr_source),
16801683
client->addr, client->adapter->name, slave_addr);
16811684

1682-
ssif_info->client = client;
1683-
i2c_set_clientdata(client, ssif_info);
1684-
16851685
/* Now check for system interface capabilities */
16861686
msg[0] = IPMI_NETFN_APP_REQUEST << 2;
16871687
msg[1] = IPMI_GET_SYSTEM_INTERFACE_CAPABILITIES_CMD;
@@ -1881,6 +1881,7 @@ static int ssif_probe(struct i2c_client *client, const struct i2c_device_id *id)
18811881

18821882
dev_err(&ssif_info->client->dev,
18831883
"Unable to start IPMI SSIF: %d\n", rv);
1884+
i2c_set_clientdata(client, NULL);
18841885
kfree(ssif_info);
18851886
}
18861887
kfree(resp);

0 commit comments

Comments
 (0)