aboutsummaryrefslogtreecommitdiffstats
path: root/fs/namei.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2012-07-19 17:17:26 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-07-29 13:24:14 -0400
commit8e4bfca1d1f0de62301dd223675717e7a5f63a27 (patch)
tree0489363abd435b844ffcfb7097b55b616fa908b7 /fs/namei.c
parent921a1650de9eed40dd64d681aba4a4d98856f289 (diff)
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 'fs/namei.c')
-rw-r--r--fs/namei.c8
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,
2964 struct path path; 2964 struct path path;
2965 int error; 2965 int error;
2966 2966
2967 if (S_ISDIR(mode)) 2967 error = may_mknod(mode);
2968 return -EPERM; 2968 if (error)
2969 return error;
2969 2970
2970 dentry = user_path_create(dfd, filename, &path, 0); 2971 dentry = user_path_create(dfd, filename, &path, 0);
2971 if (IS_ERR(dentry)) 2972 if (IS_ERR(dentry))
@@ -2973,9 +2974,6 @@ SYSCALL_DEFINE4(mknodat, int, dfd, const char __user *, filename, umode_t, mode,
2973 2974
2974 if (!IS_POSIXACL(path.dentry->d_inode)) 2975 if (!IS_POSIXACL(path.dentry->d_inode))
2975 mode &= ~current_umask(); 2976 mode &= ~current_umask();
2976 error = may_mknod(mode);
2977 if (error)
2978 goto out_dput;
2979 error = mnt_want_write(path.mnt); 2977 error = mnt_want_write(path.mnt);
2980 if (error) 2978 if (error)
2981 goto out_dput; 2979 goto out_dput;