Skip to content

Commit b724e84

Browse files
author
Dominik Brodowski
committed
fs: add do_symlinkat() helper and ksys_symlink() wrapper; remove in-kernel calls to syscall
Using the fs-internal do_symlinkat() helper allows us to get rid of fs-internal calls to the sys_symlinkat() syscall. Introducing the ksys_symlink() wrapper allows us to avoid the in-kernel calls to the sys_symlink() syscall. The ksys_ prefix denotes that this function is meant as a drop-in replacement for the syscall. In particular, it uses the same calling convention as sys_symlink(). This patch is part of a series which removes in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined. For details, see http://lkml.kernel.org/r/20180325162527.GA17492@light.dominikbrodowski.net Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
1 parent 0101db7 commit b724e84

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

fs/internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
5858
long do_mkdirat(int dfd, const char __user *pathname, umode_t mode);
5959
long do_rmdir(int dfd, const char __user *pathname);
6060
long do_unlinkat(int dfd, struct filename *name);
61+
long do_symlinkat(const char __user *oldname, int newdfd,
62+
const char __user *newname);
6163

6264
/*
6365
* namespace.c

fs/namei.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4113,8 +4113,8 @@ int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname)
41134113
}
41144114
EXPORT_SYMBOL(vfs_symlink);
41154115

4116-
SYSCALL_DEFINE3(symlinkat, const char __user *, oldname,
4117-
int, newdfd, const char __user *, newname)
4116+
long do_symlinkat(const char __user *oldname, int newdfd,
4117+
const char __user *newname)
41184118
{
41194119
int error;
41204120
struct filename *from;
@@ -4144,9 +4144,15 @@ SYSCALL_DEFINE3(symlinkat, const char __user *, oldname,
41444144
return error;
41454145
}
41464146

4147+
SYSCALL_DEFINE3(symlinkat, const char __user *, oldname,
4148+
int, newdfd, const char __user *, newname)
4149+
{
4150+
return do_symlinkat(oldname, newdfd, newname);
4151+
}
4152+
41474153
SYSCALL_DEFINE2(symlink, const char __user *, oldname, const char __user *, newname)
41484154
{
4149-
return sys_symlinkat(oldname, AT_FDCWD, newname);
4155+
return do_symlinkat(oldname, AT_FDCWD, newname);
41504156
}
41514157

41524158
/**

include/linux/syscalls.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,4 +979,13 @@ static inline long ksys_mkdir(const char __user *pathname, umode_t mode)
979979
return do_mkdirat(AT_FDCWD, pathname, mode);
980980
}
981981

982+
extern long do_symlinkat(const char __user *oldname, int newdfd,
983+
const char __user *newname);
984+
985+
static inline long ksys_symlink(const char __user *oldname,
986+
const char __user *newname)
987+
{
988+
return do_symlinkat(oldname, AT_FDCWD, newname);
989+
}
990+
982991
#endif

init/initramfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ static int __init do_symlink(void)
392392
{
393393
collected[N_ALIGN(name_len) + body_len] = '\0';
394394
clean_path(collected, 0);
395-
sys_symlink(collected + N_ALIGN(name_len), collected);
395+
ksys_symlink(collected + N_ALIGN(name_len), collected);
396396
sys_lchown(collected, uid, gid);
397397
do_utime(collected, mtime);
398398
state = SkipIt;

0 commit comments

Comments
 (0)