[linux-cifs-client] [PATCH] cifs: Fix insufficient memory allocation for nativeFileSystem field

Suresh Jayaraman sjayaraman at suse.de
Mon Apr 6 07:05:58 GMT 2009

The upstream commit b363b3304bcf68c4541683b2eff70b29f0446a5b attempted
to fix memory overwrite during tree connect response processing while
mounting. However, the memory allocated may still be insufficient as
UTF-8 string can be upto 4X times as UCS. So, would it be safe to
allocate memory that is 4X instead of 2X?

Noticed by Marcus Meissner <meissner at suse.de>.

Signed-off-by: Suresh Jayaraman <sjayaraman at suse.de>
 fs/cifs/connect.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 0de3b56..b361be0 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -3674,7 +3674,7 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,
 			    BCC(smb_buffer_response)) {
 				tcon->nativeFileSystem =
-				    kzalloc(2*(length + 1), GFP_KERNEL);
+				    kzalloc((4 * length) + 2, GFP_KERNEL);
 				if (tcon->nativeFileSystem)

More information about the linux-cifs-client mailing list