[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1390572299-3074-1-git-send-email-dvlasenk@redhat.com>
Date: Fri, 24 Jan 2014 15:04:59 +0100
From: Denys Vlasenko <dvlasenk@...hat.com>
To: Al Viro <viro@...iv.linux.org.uk>
Cc: Denys Vlasenko <dvlasenk@...hat.com>,
Jan Kratochvil <jan.kratochvil@...hat.com>,
Oleg Nesterov <oleg@...hat.com>, linux-kernel@...r.kernel.org
Subject: [PATCH] dcache: error out if the name buffer is too short
This change makes __dentry_path() and d_path()
immediately return ENAMETOOLONG if buflen < 2.
Cc: Jan Kratochvil <jan.kratochvil@...hat.com>
Cc: Oleg Nesterov <oleg@...hat.com>
Cc: linux-kernel@...r.kernel.org
Signed-off-by: Denys Vlasenko <dvlasenk@...hat.com>
---
fs/dcache.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/fs/dcache.c b/fs/dcache.c
index cb4a106..2fba276 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -3055,6 +3055,9 @@ char *d_path(const struct path *path, char *buf, int buflen)
struct path root;
int error;
+ if (buflen < 2)
+ return ERR_PTR(-ENAMETOOLONG);
+
/*
* We have various synthetic filesystems that never get mounted. On
* these filesystems dentries are never used for lookup purposes, and
@@ -3122,13 +3125,14 @@ static char *__dentry_path(struct dentry *dentry, char *buf, int buflen)
int len, seq = 0;
int error = 0;
+ if (buflen < 2)
+ goto Elong;
+
rcu_read_lock();
restart:
end = buf + buflen;
len = buflen;
prepend(&end, &len, "\0", 1);
- if (buflen < 1)
- goto Elong;
/* Get '/' right */
retval = end-1;
*retval = '/';
--
1.8.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists