This is backport of the upstream commit f6500801522c61782d4990fa1ad96154cb397cd4. It is suitable for upstream series 3.12 and 3.13. (previous stable kernels don't need this because they don't have the bug). commit f6500801522c61782d4990fa1ad96154cb397cd4 Author: Al Viro <viro@xxxxxxxxxxxxxxxxxx> Date: Sun Jan 26 12:37:55 2014 -0500 __dentry_path() fixes * we need to save the starting point for restarts * reject pathologically short buffers outright Spotted-by: Denys Vlasenko <dvlasenk@xxxxxxxxxx> Spotted-by: Oleg Nesterov <oleg@xxxxxxxxxx> Signed-off-by: Al Viro <viro@xxxxxxxxxxxxxxxxxx> diff --git a/fs/dcache.c b/fs/dcache.c index fdbe230..265e0ce 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -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 = '/'; -- To unsubscribe from this list: send the line "unsubscribe stable" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html