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] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240925113641.1297102-227-sashal@kernel.org>
Date: Wed, 25 Sep 2024 07:27:28 -0400
From: Sasha Levin <sashal@...nel.org>
To: linux-kernel@...r.kernel.org,
	stable@...r.kernel.org
Cc: Zhu Jun <zhujun2@...s.chinamobile.com>,
	Dexuan Cui <decui@...rosoft.com>,
	Saurabh Sengar <ssengar@...ux.microsoft.com>,
	Wei Liu <wei.liu@...nel.org>,
	Sasha Levin <sashal@...nel.org>,
	kys@...rosoft.com,
	haiyangz@...rosoft.com,
	linux-hyperv@...r.kernel.org
Subject: [PATCH AUTOSEL 6.11 227/244] tools/hv: Add memory allocation check in hv_fcopy_start

From: Zhu Jun <zhujun2@...s.chinamobile.com>

[ Upstream commit 94e86b174d103d941b4afc4f016af8af9e5352fa ]

Added error handling for memory allocation failures
of file_name and path_name.

Signed-off-by: Zhu Jun <zhujun2@...s.chinamobile.com>
Reviewed-by: Dexuan Cui <decui@...rosoft.com>
Tested-by: Saurabh Sengar <ssengar@...ux.microsoft.com>
Link: https://lore.kernel.org/r/20240906091333.11419-1-zhujun2@cmss.chinamobile.com
Signed-off-by: Wei Liu <wei.liu@...nel.org>
Message-ID: <20240906091333.11419-1-zhujun2@...s.chinamobile.com>
Signed-off-by: Sasha Levin <sashal@...nel.org>
---
 tools/hv/hv_fcopy_uio_daemon.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/tools/hv/hv_fcopy_uio_daemon.c b/tools/hv/hv_fcopy_uio_daemon.c
index 3ce316cc9f970..7a00f3066a980 100644
--- a/tools/hv/hv_fcopy_uio_daemon.c
+++ b/tools/hv/hv_fcopy_uio_daemon.c
@@ -296,6 +296,13 @@ static int hv_fcopy_start(struct hv_start_fcopy *smsg_in)
 	file_name = (char *)malloc(file_size * sizeof(char));
 	path_name = (char *)malloc(path_size * sizeof(char));
 
+	if (!file_name || !path_name) {
+		free(file_name);
+		free(path_name);
+		syslog(LOG_ERR, "Can't allocate memory for file name and/or path name");
+		return HV_E_FAIL;
+	}
+
 	wcstoutf8(file_name, (__u16 *)in_file_name, file_size);
 	wcstoutf8(path_name, (__u16 *)in_path_name, path_size);
 
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ