summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRonnie Sahlberg <lsahlber@redhat.com>2017-10-30 05:28:03 +0300
committerBen Hutchings <ben@decadent.org.uk>2017-11-11 16:34:38 +0300
commit90d8668e4ac34a84c52dc5b078af9d982323502c (patch)
tree2b01544ce7390a96261e4dc59a36631454a814f0
parent47dcfde4a9cc9f0e2dbe3fab9d8fc10ad42f1c00 (diff)
downloadlinux-90d8668e4ac34a84c52dc5b078af9d982323502c.tar.xz
cifs: check MaxPathNameComponentLength != 0 before using it
commit f74bc7c6679200a4a83156bb89cbf6c229fe8ec0 upstream. And fix tcon leak in error path. Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com> Signed-off-by: Steve French <smfrench@gmail.com> Reviewed-by: David Disseldorp <ddiss@samba.org> [bwh: Backported to 3.2: cifs_tcon pointer is tcon, and there's no leak to fix] Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r--fs/cifs/dir.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index a1c99c4e7763..22758b1c1426 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -521,7 +521,8 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,
oplock = pTcon->ses->server->oplocks ? REQ_OPLOCK : 0;
/* Don't allow path components longer than the server max. */
- if (unlikely(direntry->d_name.len >
+ if (unlikely(pTcon->fsAttrInfo.MaxPathNameComponentLength &&
+ direntry->d_name.len >
le32_to_cpu(pTcon->fsAttrInfo.MaxPathNameComponentLength))) {
rc = -ENAMETOOLONG;
goto lookup_out;