mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-06 05:13:18 +00:00
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>
This commit is contained in:
parent
921a1650de
commit
8e4bfca1d1
@ -2964,8 +2964,9 @@ SYSCALL_DEFINE4(mknodat, int, dfd, const char __user *, filename, umode_t, mode,
|
|||||||
struct path path;
|
struct path path;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if (S_ISDIR(mode))
|
error = may_mknod(mode);
|
||||||
return -EPERM;
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
dentry = user_path_create(dfd, filename, &path, 0);
|
dentry = user_path_create(dfd, filename, &path, 0);
|
||||||
if (IS_ERR(dentry))
|
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))
|
if (!IS_POSIXACL(path.dentry->d_inode))
|
||||||
mode &= ~current_umask();
|
mode &= ~current_umask();
|
||||||
error = may_mknod(mode);
|
|
||||||
if (error)
|
|
||||||
goto out_dput;
|
|
||||||
error = mnt_want_write(path.mnt);
|
error = mnt_want_write(path.mnt);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_dput;
|
goto out_dput;
|
||||||
|
Loading…
Reference in New Issue
Block a user