Commit da2d0ced authored by Dmitry Kadashev's avatar Dmitry Kadashev Committed by Jens Axboe

namei: make do_symlinkat() take struct filename

Pass in the struct filename pointers instead of the user string, for
uniformity with the recently converted do_mkdnodat(), do_unlinkat(),
do_renameat(), do_mkdirat().

Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christian Brauner <christian.brauner@ubuntu.com>
Acked-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Link: https://lore.kernel.org/io-uring/20210330071700.kpjoyp5zlni7uejm@wittgenstein/Signed-off-by: default avatarDmitry Kadashev <dkadashev@gmail.com>
Acked-by: default avatarChristian Brauner <christian.brauner@ubuntu.com>
Link: https://lore.kernel.org/r/20210708063447.3556403-6-dkadashev@gmail.comSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 7797251b
......@@ -4207,23 +4207,23 @@ int vfs_symlink(struct user_namespace *mnt_userns, struct inode *dir,
}
EXPORT_SYMBOL(vfs_symlink);
static long do_symlinkat(const char __user *oldname, int newdfd,
const char __user *newname)
static long do_symlinkat(struct filename *from, int newdfd,
struct filename *to)
{
int error;
struct filename *from;
struct dentry *dentry;
struct path path;
unsigned int lookup_flags = 0;
from = getname(oldname);
if (IS_ERR(from))
return PTR_ERR(from);
if (IS_ERR(from)) {
error = PTR_ERR(from);
goto out_putnames;
}
retry:
dentry = user_path_create(newdfd, newname, &path, lookup_flags);
dentry = __filename_create(newdfd, to, &path, lookup_flags);
error = PTR_ERR(dentry);
if (IS_ERR(dentry))
goto out_putname;
goto out_putnames;
error = security_path_symlink(&path, dentry, from->name);
if (!error) {
......@@ -4238,7 +4238,8 @@ static long do_symlinkat(const char __user *oldname, int newdfd,
lookup_flags |= LOOKUP_REVAL;
goto retry;
}
out_putname:
out_putnames:
putname(to);
putname(from);
return error;
}
......@@ -4246,12 +4247,12 @@ static long do_symlinkat(const char __user *oldname, int newdfd,
SYSCALL_DEFINE3(symlinkat, const char __user *, oldname,
int, newdfd, const char __user *, newname)
{
return do_symlinkat(oldname, newdfd, newname);
return do_symlinkat(getname(oldname), newdfd, getname(newname));
}
SYSCALL_DEFINE2(symlink, const char __user *, oldname, const char __user *, newname)
{
return do_symlinkat(oldname, AT_FDCWD, newname);
return do_symlinkat(getname(oldname), AT_FDCWD, getname(newname));
}
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment