]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Add explicit MAXNAMELEN check
authorBrian Behlendorf <behlendorf1@llnl.gov>
Mon, 11 Feb 2013 20:55:24 +0000 (12:55 -0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Tue, 12 Feb 2013 18:27:39 +0000 (10:27 -0800)
It turns out that the Linux VFS doesn't strictly handle all cases
where a component path name exceeds MAXNAMELEN.  It does however
appear to correctly handle MAXPATHLEN for us.

The right way to handle this appears to be to add an explicit
check to the zpl_lookup() function.  Several in-tree filesystems
handle this case the same way.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1279

module/zfs/zpl_inode.c

index e4062887878244b87fbeb41706b8ae8530dc55a7..8c8ec24147816d7fb72d4188096932a1668641a9 100644 (file)
@@ -41,6 +41,9 @@ zpl_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
        struct inode *ip;
        int error;
 
+       if (dlen(dentry) > ZFS_MAXNAMELEN)
+               return ERR_PTR(-ENAMETOOLONG);
+
        crhold(cr);
        error = -zfs_lookup(dir, dname(dentry), &ip, 0, cr, NULL, NULL);
        ASSERT3S(error, <=, 0);