diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2012-07-19 23:17:26 +0200 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-07-29 19:24:14 +0200 |
commit | 8e4bfca1d1f0de62301dd223675717e7a5f63a27 (patch) | |
tree | 0489363abd435b844ffcfb7097b55b616fa908b7 /fs/namei.c | |
parent | new helper: done_path_create() (diff) | |
download | linux-8e4bfca1d1f0de62301dd223675717e7a5f63a27.tar.xz linux-8e4bfca1d1f0de62301dd223675717e7a5f63a27.zip |
mknod: take sanity checks on mode into the very beginning
Note that applying umask can't affect their results. While
that affects errno in cases like
mknod("/no_such_directory/a", 030000)
yielding -EINVAL (due to impossible mode_t) instead of
-ENOENT (due to inexistent directory), IMO that makes a lot
more sense, POSIX allows to return either and any software
that relies on getting -ENOENT instead of -EINVAL in that
case deserves everything it gets.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to '')
-rw-r--r-- | fs/namei.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/fs/namei.c b/fs/namei.c index 5bc6f3d1dc8a..cf362dc9d1fd 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -2964,8 +2964,9 @@ SYSCALL_DEFINE4(mknodat, int, dfd, const char __user *, filename, umode_t, mode, struct path path; int error; - if (S_ISDIR(mode)) - return -EPERM; + error = may_mknod(mode); + if (error) + return error; dentry = user_path_create(dfd, filename, &path, 0); if (IS_ERR(dentry)) @@ -2973,9 +2974,6 @@ SYSCALL_DEFINE4(mknodat, int, dfd, const char __user *, filename, umode_t, mode, if (!IS_POSIXACL(path.dentry->d_inode)) mode &= ~current_umask(); - error = may_mknod(mode); - if (error) - goto out_dput; error = mnt_want_write(path.mnt); if (error) goto out_dput; |