]> Pileus Git - ~andy/linux/commitdiff
__dentry_path() fixes
authorAl Viro <viro@zeniv.linux.org.uk>
Sun, 26 Jan 2014 17:37:55 +0000 (12:37 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Sun, 26 Jan 2014 17:37:55 +0000 (12:37 -0500)
* we need to save the starting point for restarts
* reject pathologically short buffers outright

Spotted-by: Denys Vlasenko <dvlasenk@redhat.com>
Spotted-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/dcache.c

index fdbe230278101eab9657d55f7137cb66e02f49fd..265e0ce9769c70db65d5f9df11c4365f44c6dd29 100644 (file)
@@ -3116,19 +3116,22 @@ char *simple_dname(struct dentry *dentry, char *buffer, int buflen)
 /*
  * Write full pathname from the root of the filesystem into the buffer.
  */
-static char *__dentry_path(struct dentry *dentry, char *buf, int buflen)
+static char *__dentry_path(struct dentry *d, char *buf, int buflen)
 {
+       struct dentry *dentry;
        char *end, *retval;
        int len, seq = 0;
        int error = 0;
 
+       if (buflen < 2)
+               goto Elong;
+
        rcu_read_lock();
 restart:
+       dentry = d;
        end = buf + buflen;
        len = buflen;
        prepend(&end, &len, "\0", 1);
-       if (buflen < 1)
-               goto Elong;
        /* Get '/' right */
        retval = end-1;
        *retval = '/';