All of lore.kernel.org
 help / color / mirror / Atom feed
From: Xingyuan Mo <hdthky0@gmail.com>
To: Oded Gabbay <ogabbay@kernel.org>, Ofir Bitton <obitton@habana.ai>,
	Tomer Tayar <ttayar@habana.ai>,
	Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>,
	Moti Haimovski <mhaimovski@habana.ai>,
	Dafna Hirschfeld <dhirschfeld@habana.ai>,
	dri-devel@lists.freedesktop.org (open list:HABANALABS PCI DRIVER)
Cc: Xingyuan Mo <hdthky0@gmail.com>
Subject: [PATCH v2] habanalabs: fix information leak in sec_attest_info()
Date: Fri,  8 Dec 2023 21:00:59 +0800	[thread overview]
Message-ID: <20231208130059.424735-1-hdthky0@gmail.com> (raw)

This function may copy the pad0 field of struct hl_info_sec_attest to user
mode which has not been initialized, resulting in leakage of kernel heap
data to user mode. To prevent this, use kzalloc() to allocate and zero out
the buffer, which can also eliminate other uninitilized holes, if any.

Fixes: 0c88760f8f5e ("habanalabs/gaudi2: add secured attestation info uapi")
Signed-off-by: Xingyuan Mo <hdthky0@gmail.com>
---
 drivers/accel/habanalabs/common/habanalabs_ioctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/accel/habanalabs/common/habanalabs_ioctl.c b/drivers/accel/habanalabs/common/habanalabs_ioctl.c
index 8ef36effb95b..a7cd625d82c0 100644
--- a/drivers/accel/habanalabs/common/habanalabs_ioctl.c
+++ b/drivers/accel/habanalabs/common/habanalabs_ioctl.c
@@ -685,7 +685,7 @@ static int sec_attest_info(struct hl_fpriv *hpriv, struct hl_info_args *args)
 	if (!sec_attest_info)
 		return -ENOMEM;
 
-	info = kmalloc(sizeof(*info), GFP_KERNEL);
+	info = kzalloc(sizeof(*info), GFP_KERNEL);
 	if (!info) {
 		rc = -ENOMEM;
 		goto free_sec_attest_info;
-- 
2.34.1


             reply	other threads:[~2023-12-08 13:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-08 13:00 Xingyuan Mo [this message]
2023-12-19  9:30 ` [PATCH v2] habanalabs: fix information leak in sec_attest_info() Oded Gabbay

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231208130059.424735-1-hdthky0@gmail.com \
    --to=hdthky0@gmail.com \
    --cc=dhirschfeld@habana.ai \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=mhaimovski@habana.ai \
    --cc=obitton@habana.ai \
    --cc=ogabbay@kernel.org \
    --cc=stanislaw.gruszka@linux.intel.com \
    --cc=ttayar@habana.ai \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.