Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 27922b4260f65d317aabda37e42bbbff > files > 895

kernel-2.6.18-238.el5.src.rpm

From: Jeff Layton <jlayton@redhat.com>
Date: Mon, 15 Feb 2010 16:08:13 -0500
Subject: [fs] cifs: fix len for converted unicode readdir names
Message-id: <1266250096-21498-2-git-send-email-jlayton@redhat.com>
Patchwork-id: 23274
O-Subject: [RHEL5.5 PATCH 1/4] BZ#562947: cifs: fix length calculation for
	converted unicode readdir names
Bugzilla: 562947
RH-Acked-by: Steve Dickson <SteveD@redhat.com>

(backported from f12f98dba6ea1517cd7fbb912208893b9c014c15)

cifs_from_ucs2 returns the length of the converted name, including the
length of the NULL terminator. We don't want to include the NULL
terminator in the dentry name length however since that'll throw off the
hash calculation for the dentry cache.

I believe that this is the root cause of several problems that have
cropped up recently that seem to be papered over with the "noserverino"
mount option. More confirmation of that would be good, but this is
clearly a bug and it fixes at least one reproducible problem that
was reported.

This patch fixes at least this reproducer in this kernel.org bug:

    http://bugzilla.kernel.org/show_bug.cgi?id=15088#c12

Reported-by: Bjorn Tore Sund <bjorn.sund@it.uib.no>
Acked-by: Dave Kleikamp <shaggy@linux.vnet.ibm.com>
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Cc: stable@kernel.org
Signed-off-by: Steve French <sfrench@us.ibm.com>

diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index c53b33c..c8a7a97 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -925,6 +925,7 @@ static int cifs_get_name_from_search_buf(struct qstr *pqst,
 					   min(len, max_len), nlt,
 					   cifs_sb->mnt_cifs_flags &
 						CIFS_MOUNT_MAP_SPECIAL_CHR);
+		pqst->len -= nls_nullsize(nlt);
 	} else {
 		pqst->name = filename;
 		pqst->len = len;