aboutsummaryrefslogtreecommitdiffstats
path: root/fs/stat.c
diff options
context:
space:
mode:
authorAndy Whitcroft <apw@canonical.com>2011-11-02 04:44:39 -0400
committerHerton Ronaldo Krzesinski <herton.krzesinski@canonical.com>2011-11-21 12:55:03 -0500
commit6cb9bd4e2830c3a7b3fe1bd981a50c8e6a407ef5 (patch)
treeddbab59e4db392cf8d899c7daf9eb8f86859c40f /fs/stat.c
parent6575069057ea8601a36ffbac504d926d9aed83e9 (diff)
readlinkat: ensure we return ENOENT for the empty pathname for normal lookups
BugLink: http://bugs.launchpad.net/bugs/890952 commit 1fa1e7f615f4d3ae436fa319af6e4eebdd4026a8 upstream. Since the commit below which added O_PATH support to the *at() calls, the error return for readlink/readlinkat for the empty pathname has switched from ENOENT to EINVAL: commit 65cfc6722361570bfe255698d9cd4dccaf47570d Author: Al Viro <viro@zeniv.linux.org.uk> Date: Sun Mar 13 15:56:26 2011 -0400 readlinkat(), fchownat() and fstatat() with empty relative pathnames This is both unexpected for userspace and makes readlink/readlinkat inconsistant with all other interfaces; and inconsistant with our stated return for these pathnames. As the readlinkat call does not have a flags parameter we cannot use the AT_EMPTY_PATH approach used in the other calls. Therefore expose whether the original path is infact entry via a new user_path_at_empty() path lookup function. Use this to determine whether to default to EINVAL or ENOENT for failures. Addresses http://bugs.launchpad.net/bugs/817187 [akpm@linux-foundation.org: remove unused getname_flags()] Signed-off-by: Andy Whitcroft <apw@canonical.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
Diffstat (limited to 'fs/stat.c')
-rw-r--r--fs/stat.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/fs/stat.c b/fs/stat.c
index 961039121cb..02a606141b8 100644
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -296,15 +296,16 @@ SYSCALL_DEFINE4(readlinkat, int, dfd, const char __user *, pathname,
296{ 296{
297 struct path path; 297 struct path path;
298 int error; 298 int error;
299 int empty = 0;
299 300
300 if (bufsiz <= 0) 301 if (bufsiz <= 0)
301 return -EINVAL; 302 return -EINVAL;
302 303
303 error = user_path_at(dfd, pathname, LOOKUP_EMPTY, &path); 304 error = user_path_at_empty(dfd, pathname, LOOKUP_EMPTY, &path, &empty);
304 if (!error) { 305 if (!error) {
305 struct inode *inode = path.dentry->d_inode; 306 struct inode *inode = path.dentry->d_inode;
306 307
307 error = -EINVAL; 308 error = empty ? -ENOENT : -EINVAL;
308 if (inode->i_op->readlink) { 309 if (inode->i_op->readlink) {
309 error = security_inode_readlink(path.dentry); 310 error = security_inode_readlink(path.dentry);
310 if (!error) { 311 if (!error) {