diff options
author | Philip Guenthe <guenther@cvs.openbsd.org> | 2012-05-25 04:39:42 +0000 |
---|---|---|
committer | Philip Guenthe <guenther@cvs.openbsd.org> | 2012-05-25 04:39:42 +0000 |
commit | 0de601c280f7774e627bbabcfdf5bcdd1787959c (patch) | |
tree | abad380356fa48ee14f8bad1d2922201530fd134 | |
parent | 8093f5e607f42cbabe8359e77f8982ec908b2bac (diff) |
Change the KERN_FILE_BYPID and KERN_FILE_BYUID modes of the KERN_FILE2
sysctl() to be per-process instead of per-thread. This means the
filedesc table has to really be per-process instead of per-thread,
so make it an error for the linux clone() emulation to try to do
otherwise. This removes pointless duplication in fstat's output.
requested by jsing@ and deraadt@, ok matthew@ deraadt@
-rw-r--r-- | sys/compat/linux/linux_sched.c | 10 | ||||
-rw-r--r-- | sys/kern/kern_sysctl.c | 16 |
2 files changed, 19 insertions, 7 deletions
diff --git a/sys/compat/linux/linux_sched.c b/sys/compat/linux/linux_sched.c index cb35647a43b..599dc9ffc7a 100644 --- a/sys/compat/linux/linux_sched.c +++ b/sys/compat/linux/linux_sched.c @@ -1,4 +1,4 @@ -/* $OpenBSD: linux_sched.c,v 1.13 2012/05/24 01:19:16 guenther Exp $ */ +/* $OpenBSD: linux_sched.c,v 1.14 2012/05/25 04:39:40 guenther Exp $ */ /* $NetBSD: linux_sched.c,v 1.6 2000/05/28 05:49:05 thorpej Exp $ */ /*- @@ -97,9 +97,15 @@ linux_sys_clone(struct proc *p, void *v, register_t *retval) * CLONE_FS and CLONE_SYSVSEM. Also, we decree it * to be incompatible with CLONE_VFORK, as I don't * want to work out whether that's 100% safe. + * Requires CLONE_FILES so that the rest of the kernel + * can assume that threads share an fd table. */ #define REQUIRED \ - (LINUX_CLONE_SIGHAND | LINUX_CLONE_FS | LINUX_CLONE_SYSVSEM) + ( LINUX_CLONE_SIGHAND \ + | LINUX_CLONE_FS \ + | LINUX_CLONE_SYSVSEM \ + | LINUX_CLONE_FILES \ + ) #define BANNED \ LINUX_CLONE_VFORK if ((cflags & (REQUIRED | BANNED)) != REQUIRED) diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index ba6e06515ce..e15d254edbc 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sysctl.c,v 1.223 2012/05/02 20:42:25 guenther Exp $ */ +/* $OpenBSD: kern_sysctl.c,v 1.224 2012/05/25 04:39:41 guenther Exp $ */ /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */ /*- @@ -1288,8 +1288,11 @@ sysctl_file2(int *name, u_int namelen, char *where, size_t *sizep, break; } LIST_FOREACH(pp, &allproc, p_list) { - /* skip system, exiting, embryonic and undead processes */ - if ((pp->p_flag & P_SYSTEM) || (pp->p_flag & P_WEXIT) + /* + * skip system, exiting, embryonic and undead + * processes, as well as threads + */ + if ((pp->p_flag & (P_SYSTEM | P_WEXIT | P_THREAD)) || (pp->p_p->ps_flags & PS_EXITING) || pp->p_stat == SIDL || pp->p_stat == SZOMB) continue; @@ -1317,8 +1320,11 @@ sysctl_file2(int *name, u_int namelen, char *where, size_t *sizep, break; case KERN_FILE_BYUID: LIST_FOREACH(pp, &allproc, p_list) { - /* skip system, exiting, embryonic and undead processes */ - if ((pp->p_flag & P_SYSTEM) || (pp->p_flag & P_WEXIT) + /* + * skip system, exiting, embryonic and undead + * processes, as well as threads + */ + if ((pp->p_flag & (P_SYSTEM | P_WEXIT | P_THREAD)) || (pp->p_p->ps_flags & PS_EXITING) || pp->p_stat == SIDL || pp->p_stat == SZOMB) continue; |