diff options
author | anton <anton@cvs.openbsd.org> | 2020-02-15 09:35:49 +0000 |
---|---|---|
committer | anton <anton@cvs.openbsd.org> | 2020-02-15 09:35:49 +0000 |
commit | 126e083ddada267194d23cd03cbc00ef578693e5 (patch) | |
tree | 6fa992a20ab4bafe23be0ad1fd187074c7eed5aa /sys | |
parent | 9f7e48ab7e52c3a434602a331a92467313a8b7ab (diff) |
Consistently perform atomic writes to the ps_flags field of struct
process.
ok bluhm@ claudio@ visa@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_exec.c | 6 | ||||
-rw-r--r-- | sys/kern/kern_pledge.c | 6 | ||||
-rw-r--r-- | sys/kern/kern_sig.c | 6 | ||||
-rw-r--r-- | sys/sys/proc.h | 5 | ||||
-rw-r--r-- | sys/sys/sysctl.h | 4 |
5 files changed, 14 insertions, 13 deletions
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 39af7a3de4b..20480c2fc28 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_exec.c,v 1.212 2019/12/11 07:30:09 guenther Exp $ */ +/* $OpenBSD: kern_exec.c,v 1.213 2020/02/15 09:35:48 anton Exp $ */ /* $NetBSD: kern_exec.c,v 1.75 1996/02/09 18:59:28 christos Exp $ */ /*- @@ -701,9 +701,9 @@ sys_execve(struct proc *p, void *v, register_t *retval) p->p_descfd = pack.ep_fd; if (pack.ep_flags & EXEC_WXNEEDED) - p->p_p->ps_flags |= PS_WXNEEDED; + atomic_setbits_int(&p->p_p->ps_flags, PS_WXNEEDED); else - p->p_p->ps_flags &= ~PS_WXNEEDED; + atomic_clearbits_int(&p->p_p->ps_flags, PS_WXNEEDED); /* update ps_emul, the old value is no longer needed */ pr->ps_emul = pack.ep_emul; diff --git a/sys/kern/kern_pledge.c b/sys/kern/kern_pledge.c index 3769b58d74c..7bcc7636d99 100644 --- a/sys/kern/kern_pledge.c +++ b/sys/kern/kern_pledge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_pledge.c,v 1.260 2020/02/11 16:02:39 deraadt Exp $ */ +/* $OpenBSD: kern_pledge.c,v 1.261 2020/02/15 09:35:48 anton Exp $ */ /* * Copyright (c) 2015 Nicholas Marriott <nicm@openbsd.org> @@ -488,7 +488,7 @@ sys_pledge(struct proc *p, void *v, register_t *retval) if (SCARG(uap, promises)) { pr->ps_pledge = promises; - pr->ps_flags |= PS_PLEDGE; + atomic_setbits_int(&pr->ps_flags, PS_PLEDGE); /* * Kill off unveil and drop unveil vnode refs if we no * longer are holding any path-accessing pledge @@ -500,7 +500,7 @@ sys_pledge(struct proc *p, void *v, register_t *retval) } if (SCARG(uap, execpromises)) { pr->ps_execpledge = execpromises; - pr->ps_flags |= PS_EXECPLEDGE; + atomic_setbits_int(&pr->ps_flags, PS_EXECPLEDGE); } return (0); } diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index bc4d54495b4..6079b0eb15f 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sig.c,v 1.246 2020/02/14 14:32:44 mpi Exp $ */ +/* $OpenBSD: kern_sig.c,v 1.247 2020/02/15 09:35:48 anton Exp $ */ /* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */ /* @@ -434,7 +434,7 @@ execsigs(struct proc *p) * Clear set of signals caught on the signal stack. */ sigstkinit(&p->p_sigstk); - ps->ps_flags &= ~SAS_NOCLDWAIT; + atomic_clearbits_int(&ps->ps_flags, SAS_NOCLDWAIT); if (ps->ps_sigact[SIGCHLD] == SIG_IGN) ps->ps_sigact[SIGCHLD] = SIG_DFL; } @@ -1512,7 +1512,7 @@ coredump(struct proc *p) if (pr->ps_emul->e_coredump == NULL) return (EINVAL); - pr->ps_flags |= PS_COREDUMP; + atomic_setbits_int(&pr->ps_flags, PS_COREDUMP); /* Don't dump if will exceed file size limit. */ if (USPACE + ptoa(vm->vm_dsize + vm->vm_ssize) >= lim_cur(RLIMIT_CORE)) diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 162292d0a97..d3dcb14cfef 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.h,v 1.287 2020/01/30 08:51:27 mpi Exp $ */ +/* $OpenBSD: proc.h,v 1.288 2020/02/15 09:35:48 anton Exp $ */ /* $NetBSD: proc.h,v 1.44 1996/04/22 01:23:21 christos Exp $ */ /*- @@ -159,6 +159,7 @@ struct unveil; /* * Locks used to protect struct members in this file: + * a atomic operations * m this process' `ps_mtx' * p this process' `ps_lock' * r rlimit_lock @@ -196,7 +197,7 @@ struct process { /* The following fields are all zeroed upon creation in process_new. */ #define ps_startzero ps_klist struct klist ps_klist; /* knotes attached to this process */ - int ps_flags; /* PS_* flags. */ + u_int ps_flags; /* [a] PS_* flags. */ int ps_siglist; /* Signals pending for the process. */ struct proc *ps_single; /* Single threading to this thread. */ diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h index efd06a9738a..a13a49b5f50 100644 --- a/sys/sys/sysctl.h +++ b/sys/sys/sysctl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sysctl.h,v 1.202 2020/02/01 08:57:27 anton Exp $ */ +/* $OpenBSD: sysctl.h,v 1.203 2020/02/15 09:35:48 anton Exp $ */ /* $NetBSD: sysctl.h,v 1.16 1996/04/09 20:55:36 cgd Exp $ */ /* @@ -460,7 +460,7 @@ struct kinfo_proc { u_int32_t p_uctime_sec; /* STRUCT TIMEVAL: child u+s time. */ u_int32_t p_uctime_usec; /* STRUCT TIMEVAL: child u+s time. */ - int32_t p_psflags; /* INT: PS_* flags on the process. */ + int32_t p_psflags; /* UINT: PS_* flags on the process. */ int32_t p_spare; /* INT: unused. */ u_int32_t p_svuid; /* UID_T: saved user id */ u_int32_t p_svgid; /* GID_T: saved group id */ |