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-next>] [day] [month] [year] [list]
Message-Id: <20231204020745.2445944-1-chentao@kylinos.cn>
Date:   Mon,  4 Dec 2023 10:07:45 +0800
From:   Kunwu Chan <chentao@...inos.cn>
To:     fbarrat@...ux.ibm.com, ajd@...ux.ibm.com, arnd@...db.de,
        gregkh@...uxfoundation.org, mpe@...erman.id.au,
        mrochs@...ux.vnet.ibm.com
Cc:     kunwu.chan@...mail.com, linuxppc-dev@...ts.ozlabs.org,
        linux-kernel@...r.kernel.org, Kunwu Chan <chentao@...inos.cn>
Subject: [PATCH] cxl: Fix null pointer dereference in cxl_get_fd

kasprintf() returns a pointer to dynamically allocated memory
which can be NULL upon failure.

Fixes: bdecf76e319a ("cxl: Fix coredump generation when cxl_get_fd() is used")
Signed-off-by: Kunwu Chan <chentao@...inos.cn>
---
 drivers/misc/cxl/api.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/misc/cxl/api.c b/drivers/misc/cxl/api.c
index d85c56530863..bfd7ccd4d7e1 100644
--- a/drivers/misc/cxl/api.c
+++ b/drivers/misc/cxl/api.c
@@ -419,6 +419,10 @@ struct file *cxl_get_fd(struct cxl_context *ctx, struct file_operations *fops,
 		fops = (struct file_operations *)&afu_fops;
 
 	name = kasprintf(GFP_KERNEL, "cxl:%d", ctx->pe);
+	if (!name) {
+		put_unused_fd(fdtmp);
+		return ERR_PTR(-ENOMEM);
+	}
 	file = cxl_getfile(name, fops, ctx, flags);
 	kfree(name);
 	if (IS_ERR(file))
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ