History

Merge tag 'for-linus-5.16-2' of git://github.com/cminyard/linux-ipmi

Pull IPMI fixes from Corey Minyard: "Some changes that went in 5.16 had issues. When working on the design a piece was redesigned and things got missed. And the message type was not being initialized when it was allocated, resulting in crashes. In addition, the IPMI driver has had a shutdown issue where it could still have an item in a system workqueue after it had been shutdown. Move to a private workqueue to avoid that problem" * tag 'for-linus-5.16-2' of git://github.com/cminyard/linux-ipmi: ipmi:ipmb: Fix unknown command response ipmi: fix IPMI_SMI_MSG_TYPE_IPMB_DIRECT response length checking ipmi: fix oob access due to uninit smi_msg type ipmi: msghandler: Make symbol 'remove_work_wq' static ipmi: Move remove_work to dedicated workqueue

Linus Torvalds committed 4 years ago

Commit df365882 parents 4536579 c03a4871 file · +33 −8Browse files

Unified · Split

drivers/char/ipmi/ipmi_msghandler.c+33−8
@@ -191,6 +191,8 @@ struct ipmi_user { · 190 unmodified lines
191 struct work_struct remove_work;191 struct work_struct remove_work;
192};192};
193 193
194static struct workqueue_struct *remove_work_wq;
195
194static struct ipmi_user *acquire_ipmi_user(struct ipmi_user *user, int *index)196static struct ipmi_user *acquire_ipmi_user(struct ipmi_user *user, int *index)
195 __acquires(user->release_barrier)197 __acquires(user->release_barrier)
196{198{
@@ -1297,7 +1299,7 @@ static void free_user(struct kref *ref) · 1100 unmodified lines
1297 struct ipmi_user *user = container_of(ref, struct ipmi_user, refcount);1299 struct ipmi_user *user = container_of(ref, struct ipmi_user, refcount);
1298 1300
1299 /* SRCU cleanup must happen in task context. */1301 /* SRCU cleanup must happen in task context. */
1300 schedule_work(&user->remove_work);1302 queue_work(remove_work_wq, &user->remove_work);
1301}1303}
1302 1304
1303static void _ipmi_destroy_user(struct ipmi_user *user)1305static void _ipmi_destroy_user(struct ipmi_user *user)
@@ -3918,9 +3920,11 @@ static int handle_ipmb_direct_rcv_cmd(struct ipmi_smi *intf, · 2614 unmodified lines
3918 /* We didn't find a user, deliver an error response. */3920 /* We didn't find a user, deliver an error response. */
3919 ipmi_inc_stat(intf, unhandled_commands);3921 ipmi_inc_stat(intf, unhandled_commands);
3920 3922
3921 msg->data[0] = ((netfn + 1) << 2) | (msg->rsp[4] & 0x3);3923 msg->data[0] = (netfn + 1) << 2;
3922 msg->data[1] = msg->rsp[2];3924 msg->data[0] |= msg->rsp[2] & 0x3; /* rqLUN */
3923 msg->data[2] = msg->rsp[4] & ~0x3;3925 msg->data[1] = msg->rsp[1]; /* Addr */
3926 msg->data[2] = msg->rsp[2] & ~0x3; /* rqSeq */
3927 msg->data[2] |= msg->rsp[0] & 0x3; /* rsLUN */
3924 msg->data[3] = cmd;3928 msg->data[3] = cmd;
3925 msg->data[4] = IPMI_INVALID_CMD_COMPLETION_CODE;3929 msg->data[4] = IPMI_INVALID_CMD_COMPLETION_CODE;
3926 msg->data_size = 5;3930 msg->data_size = 5;
@@ -4455,13 +4459,24 @@ return_unspecified: · 528 unmodified lines
4455 msg->rsp[2] = IPMI_ERR_UNSPECIFIED;4459 msg->rsp[2] = IPMI_ERR_UNSPECIFIED;
4456 msg->rsp_size = 3;4460 msg->rsp_size = 3;
4457 } else if (msg->type == IPMI_SMI_MSG_TYPE_IPMB_DIRECT) {4461 } else if (msg->type == IPMI_SMI_MSG_TYPE_IPMB_DIRECT) {
4458 /* commands must have at least 3 bytes, responses 4. */4462 /* commands must have at least 4 bytes, responses 5. */
4459 if (is_cmd && (msg->rsp_size < 3)) {4463 if (is_cmd && (msg->rsp_size < 4)) {
4460 ipmi_inc_stat(intf, invalid_commands);4464 ipmi_inc_stat(intf, invalid_commands);
4461 goto out;4465 goto out;
4462 }4466 }
4463 if (!is_cmd && (msg->rsp_size < 4))4467 if (!is_cmd && (msg->rsp_size < 5)) {
4464 goto return_unspecified;4468 ipmi_inc_stat(intf, invalid_ipmb_responses);
4469 /* Construct a valid error response. */
4470 msg->rsp[0] = msg->data[0] & 0xfc; /* NetFN */
4471 msg->rsp[0] |= (1 << 2); /* Make it a response */
4472 msg->rsp[0] |= msg->data[2] & 3; /* rqLUN */
4473 msg->rsp[1] = msg->data[1]; /* Addr */
4474 msg->rsp[2] = msg->data[2] & 0xfc; /* rqSeq */
4475 msg->rsp[2] |= msg->data[0] & 0x3; /* rsLUN */
4476 msg->rsp[3] = msg->data[3]; /* Cmd */
4477 msg->rsp[4] = IPMI_ERR_UNSPECIFIED;
4478 msg->rsp_size = 5;
4479 }
4465 } else if ((msg->data_size >= 2)4480 } else if ((msg->data_size >= 2)
4466 && (msg->data[0] == (IPMI_NETFN_APP_REQUEST << 2))4481 && (msg->data[0] == (IPMI_NETFN_APP_REQUEST << 2))
4467 && (msg->data[1] == IPMI_SEND_MSG_CMD)4482 && (msg->data[1] == IPMI_SEND_MSG_CMD)
@@ -5031,6 +5046,7 @@ struct ipmi_smi_msg *ipmi_alloc_smi_msg(void) · 563 unmodified lines
5031 if (rv) {5046 if (rv) {
5032 rv->done = free_smi_msg;5047 rv->done = free_smi_msg;
5033 rv->user_data = NULL;5048 rv->user_data = NULL;
5049 rv->type = IPMI_SMI_MSG_TYPE_NORMAL;
5034 atomic_inc(&smi_msg_inuse_count);5050 atomic_inc(&smi_msg_inuse_count);
5035 }5051 }
5036 return rv;5052 return rv;
@@ -5383,6 +5399,13 @@ static int ipmi_init_msghandler(void) · 346 unmodified lines
5383 5399
5384 atomic_notifier_chain_register(&panic_notifier_list, &panic_block);5400 atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
5385 5401
5402 remove_work_wq = create_singlethread_workqueue("ipmi-msghandler-remove-wq");
5403 if (!remove_work_wq) {
5404 pr_err("unable to create ipmi-msghandler-remove-wq workqueue");
5405 rv = -ENOMEM;
5406 goto out;
5407 }
5408
5386 initialized = true;5409 initialized = true;
5387 5410
5388out:5411out:
@@ -5408,6 +5431,8 @@ static void __exit cleanup_ipmi(void) · 19 unmodified lines
5408 int count;5431 int count;
5409 5432
5410 if (initialized) {5433 if (initialized) {
5434 destroy_workqueue(remove_work_wq);
5435
5411 atomic_notifier_chain_unregister(&panic_notifier_list,5436 atomic_notifier_chain_unregister(&panic_notifier_list,
5412 &panic_block);5437 &panic_block);
5413 5438

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t