Skip to contentSkip to conversation

ipmi: fix oob access due to uninit smi_msg type

PATCH In review Jakub Kicinski 2 participants 4 messages Nov 24, 2021 – Nov 26, 2021 IPMI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ipmi: fix oob access due to uninit smi_msg type

We're hitting OOB accesses in handle_ipmb_direct_rcv_rsp() (memcpy of size -1) after user space generates a message. Looks like the message is incorrectly assumed to be of the new IPMB type, because type is never set and message is allocated with kmalloc() not kzalloc().

Fixes 059747c245f0 ("ipmi: Add support for IPMB direct messages")

---
Would it be possible to get something like this to Linus ASAP? It's flipping over all my test boxes.

---
 drivers/char/ipmi/ipmi_msghandler.c | 1 +
 1 file changed, 1 insertion(+)
drivers/char/ipmi/ipmi_msghandler.c +1 -0
index deed355422f4..f0b18c25cbb1 100644
@@ -5031,6 +5031,7 @@ struct ipmi_smi_msg *ipmi_alloc_smi_msg(void)
 	if (rv) {
 		rv->done = free_smi_msg;
 		rv->user_data = NULL;
+		rv->type = IPMI_SMI_MSG_TYPE_NORMAL;
 		atomic_inc(&smi_msg_inuse_count);
 	}
 	return rv;
Signature · 1 line
2.31.1
#1 lore raw
Quoted 7 lines · Jakub Kicinski

We're hitting OOB accesses in handle_ipmb_direct_rcv_rsp() (memcpy of size -1) after user space generates a message. Looks like the message is incorrectly assumed to be of the new IPMB type, because type is never set and message is allocated with kmalloc() not kzalloc().

Fixes 059747c245f0 ("ipmi: Add support for IPMB direct messages")

This is correct, and in my queue. Thanks for the fix.

-corey

Quoted 22 lines

---
Would it be possible to get something like this to Linus ASAP? It's flipping over all my test boxes.

---
 drivers/char/ipmi/ipmi_msghandler.c | 1 +
 1 file changed, 1 insertion(+)
drivers/char/ipmi/ipmi_msghandler.c +1 -0
index deed355422f4..f0b18c25cbb1 100644
@@ -5031,6 +5031,7 @@ struct ipmi_smi_msg *ipmi_alloc_smi_msg(void)
 	if (rv) {
 		rv->done = free_smi_msg;
 		rv->user_data = NULL;
+		rv->type = IPMI_SMI_MSG_TYPE_NORMAL;
 		atomic_inc(&smi_msg_inuse_count);
 	}
 	return rv;
Signature · 1 line
2.31.1
#2 lore raw
Quoted 10 lines · On Thu, 25 Nov 2021 08:21:40 -0600 Corey Minyard wrote:
Quoted 7 lines · Jakub Kicinski

We're hitting OOB accesses in handle_ipmb_direct_rcv_rsp() (memcpy of size -1) after user space generates a message. Looks like the message is incorrectly assumed to be of the new IPMB type, because type is never set and message is allocated with kmalloc() not kzalloc().

Fixes 059747c245f0 ("ipmi: Add support for IPMB direct messages")

This is correct, and in my queue. Thanks for the fix.

Where is your queue, BTW? I see not T entry in MAINTAINERS and nothing of note in the github tree from which you send PRs.

#3 lore raw
Quoted 7 lines · Jakub Kicinski
Quoted 6 lines · On Thu, 25 Nov 2021 08:21:40 -0600 Corey Minyard wrote:
Quoted 5 lines · Jakub Kicinski

We're hitting OOB accesses in handle_ipmb_direct_rcv_rsp() (memcpy of size -1) after user space generates a message. Looks like the message is incorrectly assumed to be of the new IPMB type, because type is never set and message is allocated with kmalloc() not kzalloc().

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Fixes 059747c245f0 ("ipmi: Add support for IPMB direct messages")

This is correct, and in my queue. Thanks for the fix.

Where is your queue, BTW? I see not T entry in MAINTAINERS and nothing of note in the github tree from which you send PRs.

It's at github.com:cminyard/linux-ipmi.git for-next

I hadn't pushed it up yet, I wanted to do some testing. I just pushed it.

-corey