forked from Minki/linux
namei: make do_mknodat() take struct filename
Pass in the struct filename pointers instead of the user string, for uniformity with the recently converted do_unlinkat(), do_renameat(), do_mkdirat(). Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Christian Brauner <christian.brauner@ubuntu.com> Acked-by: Linus Torvalds <torvalds@linux-foundation.org> Link: https://lore.kernel.org/io-uring/20210330071700.kpjoyp5zlni7uejm@wittgenstein/ Signed-off-by: Dmitry Kadashev <dkadashev@gmail.com> Acked-by: Christian Brauner <christian.brauner@ubuntu.com> Link: https://lore.kernel.org/r/20210708063447.3556403-5-dkadashev@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
584d3226d6
commit
7797251bb5
19
fs/namei.c
19
fs/namei.c
@ -3739,7 +3739,7 @@ static int may_mknod(umode_t mode)
|
||||
}
|
||||
}
|
||||
|
||||
static long do_mknodat(int dfd, const char __user *filename, umode_t mode,
|
||||
static long do_mknodat(int dfd, struct filename *name, umode_t mode,
|
||||
unsigned int dev)
|
||||
{
|
||||
struct user_namespace *mnt_userns;
|
||||
@ -3750,17 +3750,18 @@ static long do_mknodat(int dfd, const char __user *filename, umode_t mode,
|
||||
|
||||
error = may_mknod(mode);
|
||||
if (error)
|
||||
return error;
|
||||
goto out1;
|
||||
retry:
|
||||
dentry = user_path_create(dfd, filename, &path, lookup_flags);
|
||||
dentry = __filename_create(dfd, name, &path, lookup_flags);
|
||||
error = PTR_ERR(dentry);
|
||||
if (IS_ERR(dentry))
|
||||
return PTR_ERR(dentry);
|
||||
goto out1;
|
||||
|
||||
if (!IS_POSIXACL(path.dentry->d_inode))
|
||||
mode &= ~current_umask();
|
||||
error = security_path_mknod(&path, dentry, mode, dev);
|
||||
if (error)
|
||||
goto out;
|
||||
goto out2;
|
||||
|
||||
mnt_userns = mnt_user_ns(path.mnt);
|
||||
switch (mode & S_IFMT) {
|
||||
@ -3779,24 +3780,26 @@ retry:
|
||||
dentry, mode, 0);
|
||||
break;
|
||||
}
|
||||
out:
|
||||
out2:
|
||||
done_path_create(&path, dentry);
|
||||
if (retry_estale(error, lookup_flags)) {
|
||||
lookup_flags |= LOOKUP_REVAL;
|
||||
goto retry;
|
||||
}
|
||||
out1:
|
||||
putname(name);
|
||||
return error;
|
||||
}
|
||||
|
||||
SYSCALL_DEFINE4(mknodat, int, dfd, const char __user *, filename, umode_t, mode,
|
||||
unsigned int, dev)
|
||||
{
|
||||
return do_mknodat(dfd, filename, mode, dev);
|
||||
return do_mknodat(dfd, getname(filename), mode, dev);
|
||||
}
|
||||
|
||||
SYSCALL_DEFINE3(mknod, const char __user *, filename, umode_t, mode, unsigned, dev)
|
||||
{
|
||||
return do_mknodat(AT_FDCWD, filename, mode, dev);
|
||||
return do_mknodat(AT_FDCWD, getname(filename), mode, dev);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user