summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2014-01-26 12:37:55 -0500
committerJiri Slaby <jslaby@suse.cz>2014-05-05 11:20:53 +0200
commitaeaf64c5a760c88e7af7b316536980d41bf312cf (patch)
tree501b0d518653191205b4893d66a20525bcff9019
parent12716b1214464dc9b5d418f8e7a9f465ae03e241 (diff)
__dentry_path() fixes
commit f6500801522c61782d4990fa1ad96154cb397cd4 upstream. * 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> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
-rw-r--r--fs/dcache.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/fs/dcache.c b/fs/dcache.c
index 008f524e195a..8ef74f3d8fe5 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -3122,19 +3122,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 = '/';