Skip to content

Commit

Permalink
__dentry_path() fixes
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
Al Viro committed Jan 26, 2014
1 parent a8323da commit f650080
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions fs/dcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '/';
Expand Down

0 comments on commit f650080

Please sign in to comment.