Skip to content

Commit e2aaa9f

Browse files
author
Dominik Brodowski
committed
kernel: add ksys_setsid() helper; remove in-kernel call to sys_setsid()
Using this helper allows us to avoid the in-kernel call to the sys_setsid() 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_setsid(). 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> Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
1 parent 9b32105 commit e2aaa9f

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

‎include/linux/syscalls.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,7 @@ off_t ksys_lseek(unsigned int fd, off_t offset, unsigned int whence);
962962
ssize_t ksys_read(unsigned int fd, char __user *buf, size_t count);
963963
void ksys_sync(void);
964964
int ksys_unshare(unsigned long unshare_flags);
965+
int ksys_setsid(void);
965966

966967
/*
967968
* The following kernel syscall equivalents are just wrappers to fs-internal

‎init/do_mounts_initrd.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ static int init_linuxrc(struct subprocess_info *info, struct cred *new)
4545
ksys_chdir("/root");
4646
ksys_mount(".", "/", NULL, MS_MOVE, NULL);
4747
ksys_chroot(".");
48-
sys_setsid();
48+
ksys_setsid();
4949
return 0;
5050
}
5151

‎kernel/sys.c‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1150,7 +1150,7 @@ static void set_special_pids(struct pid *pid)
11501150
change_pid(curr, PIDTYPE_PGID, pid);
11511151
}
11521152

1153-
SYSCALL_DEFINE0(setsid)
1153+
int ksys_setsid(void)
11541154
{
11551155
struct task_struct *group_leader = current->group_leader;
11561156
struct pid *sid = task_pid(group_leader);
@@ -1183,6 +1183,11 @@ SYSCALL_DEFINE0(setsid)
11831183
return err;
11841184
}
11851185

1186+
SYSCALL_DEFINE0(setsid)
1187+
{
1188+
return ksys_setsid();
1189+
}
1190+
11861191
DECLARE_RWSEM(uts_sem);
11871192

11881193
#ifdef COMPAT_UTS_MACHINE

0 commit comments

Comments
 (0)