orangefs: Avoid symlink upcall if target is too long.
authorMartin Brandenburg <martin@omnibond.com>
Mon, 29 Feb 2016 21:07:35 +0000 (16:07 -0500)
committerMike Marshall <hubcap@omnibond.com>
Wed, 9 Mar 2016 18:26:39 +0000 (13:26 -0500)
Previously the client-core detected this condition by sheer luck!

Since we used strncpy, no NUL byte would be included on the name. The
client-core would call strlen, which would read past the end of its
buffer, but return a number large enough that the client-core would
return ENAMETOOLONG.

Signed-off-by: Martin Brandenburg <martin@omnibond.com>
Signed-off-by: Mike Marshall <hubcap@omnibond.com>
fs/orangefs/namei.c

index 650ff299738bc22bd7e8be8e7c3527ff4dcef47d..5a60c508af4ed7e8492a69e8c18276c9981fb62d 100644 (file)
@@ -269,6 +269,9 @@ static int orangefs_symlink(struct inode *dir,
        if (!symname)
                return -EINVAL;
 
+       if (strlen(symname)+1 > ORANGEFS_NAME_MAX)
+               return -ENAMETOOLONG;
+
        new_op = op_alloc(ORANGEFS_VFS_OP_SYMLINK);
        if (!new_op)
                return -ENOMEM;