lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1648872080-9605-1-git-send-email-baihaowen@meizu.com>
Date:   Sat, 2 Apr 2022 12:01:20 +0800
From:   Haowen Bai <baihaowen@...zu.com>
To:     Corey Minyard <minyard@....org>
CC:     Haowen Bai <baihaowen@...zu.com>,
        <openipmi-developer@...ts.sourceforge.net>,
        <linux-kernel@...r.kernel.org>
Subject: [PATCH V2] ipmi: ssif: potential NULL dereference in msg_done_handler()

msg could be null without checking null and return, but still dereference
msg->rsp[2] and will lead to a null pointer trigger.

Signed-off-by: Haowen Bai <baihaowen@...zu.com>
---
V1->V2: check msg both cases that also uses msg; add logs;

 drivers/char/ipmi/ipmi_ssif.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c
index f199cc194844..eb6bdd44b69e 100644
--- a/drivers/char/ipmi/ipmi_ssif.c
+++ b/drivers/char/ipmi/ipmi_ssif.c
@@ -758,8 +758,11 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result,
 	switch (ssif_info->ssif_state) {
 	case SSIF_NORMAL:
 		ipmi_ssif_unlock_cond(ssif_info, flags);
-		if (!msg)
+		if (!msg) {
+			dev_dbg(&ssif_info->client->dev,
+				"msg was null, case SSIF_NORMAL\n");
 			break;
+		}
 
 		if (result < 0)
 			return_hosed_msg(ssif_info, msg);
@@ -814,6 +817,13 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result,
 		break;
 
 	case SSIF_GETTING_EVENTS:
+		if (!msg) {
+			ipmi_ssif_unlock_cond(ssif_info, flags);
+			dev_dbg(&ssif_info->client->dev,
+				"msg was null, case SSIF_GETTING_EVENTS\n");
+			break;
+		}
+
 		if ((result < 0) || (len < 3) || (msg->rsp[2] != 0)) {
 			/* Error getting event, probably done. */
 			msg->done(msg);
@@ -838,6 +848,13 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result,
 		break;
 
 	case SSIF_GETTING_MESSAGES:
+		if (!msg) {
+			ipmi_ssif_unlock_cond(ssif_info, flags);
+			dev_dbg(&ssif_info->client->dev,
+				"msg was null, case SSIF_GETTING_MESSAGES\n");
+			break;
+		}
+
 		if ((result < 0) || (len < 3) || (msg->rsp[2] != 0)) {
 			/* Error getting event, probably done. */
 			msg->done(msg);
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ