History

ipmi: fix IPMI_SMI_MSG_TYPE_IPMB_DIRECT response length checking

A couple of issues: The tested data sizes are wrong; during the design that changed and this got missed. The formatting of the reponse couldn't use the normal one, it has to be an IPMB formatted response.

Corey Minyard committed 4 years ago

Commit d2c12f51 parent c33fdfb1 file · +15 −4Browse files

Unified · Split

drivers/char/ipmi/ipmi_msghandler.c+15−4
@@ -4457,13 +4457,24 @@ return_unspecified: · 4456 unmodified lines
44574457 msg->rsp[2] = IPMI_ERR_UNSPECIFIED;
44584458 msg->rsp_size = 3;
44594459 } else if (msg->type == IPMI_SMI_MSG_TYPE_IPMB_DIRECT) {
4460− /* commands must have at least 3 bytes, responses 4. */
4461− if (is_cmd && (msg->rsp_size < 3)) {
4460+ /* commands must have at least 4 bytes, responses 5. */
4461+ if (is_cmd && (msg->rsp_size < 4)) {
44624462 ipmi_inc_stat(intf, invalid_commands);
44634463 goto out;
44644464 }
4465− if (!is_cmd && (msg->rsp_size < 4))
4466− goto return_unspecified;
4465+ if (!is_cmd && (msg->rsp_size < 5)) {
4466+ ipmi_inc_stat(intf, invalid_ipmb_responses);
4467+ /* Construct a valid error response. */
4468+ msg->rsp[0] = msg->data[0] & 0xfc; /* NetFN */
4469+ msg->rsp[0] |= (1 << 2); /* Make it a response */
4470+ msg->rsp[0] |= msg->data[2] & 3; /* rqLUN */
4471+ msg->rsp[1] = msg->data[1]; /* Addr */
4472+ msg->rsp[2] = msg->data[2] & 0xfc; /* rqSeq */
4473+ msg->rsp[2] |= msg->data[0] & 0x3; /* rsLUN */
4474+ msg->rsp[3] = msg->data[3]; /* Cmd */
4475+ msg->rsp[4] = IPMI_ERR_UNSPECIFIED;
4476+ msg->rsp_size = 5;
4477+ }
44674478 } else if ((msg->data_size >= 2)
44684479 && (msg->data[0] == (IPMI_NETFN_APP_REQUEST << 2))
44694480 && (msg->data[1] == IPMI_SEND_MSG_CMD)

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