mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 18:51:56 -04:00
readlinkat: ensure we return ENOENT for the empty pathname for normal lookups
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 65cfc67223
Author: Al Viro <[email protected]>
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
[[email protected]: remove unused getname_flags()]
Signed-off-by: Andy Whitcroft <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: Al Viro <[email protected]>
Cc: <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Christoph Hellwig <[email protected]>
This commit is contained in:
parent
32096ea1aa
commit
1fa1e7f615
3 changed files with 17 additions and 7 deletions
|
|
@ -294,15 +294,16 @@ SYSCALL_DEFINE4(readlinkat, int, dfd, const char __user *, pathname,
|
|||
{
|
||||
struct path path;
|
||||
int error;
|
||||
int empty = 0;
|
||||
|
||||
if (bufsiz <= 0)
|
||||
return -EINVAL;
|
||||
|
||||
error = user_path_at(dfd, pathname, LOOKUP_EMPTY, &path);
|
||||
error = user_path_at_empty(dfd, pathname, LOOKUP_EMPTY, &path, &empty);
|
||||
if (!error) {
|
||||
struct inode *inode = path.dentry->d_inode;
|
||||
|
||||
error = -EINVAL;
|
||||
error = empty ? -ENOENT : -EINVAL;
|
||||
if (inode->i_op->readlink) {
|
||||
error = security_inode_readlink(path.dentry);
|
||||
if (!error) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue