diff options
author | Jeremie Courreges-Anglas <jca@cvs.openbsd.org> | 2022-06-29 12:01:23 +0000 |
---|---|---|
committer | Jeremie Courreges-Anglas <jca@cvs.openbsd.org> | 2022-06-29 12:01:23 +0000 |
commit | 7d735f1e9ebf94f01a27dede3f1f36845450ff30 (patch) | |
tree | 295a42f1a5ecdfece9503042d7a18bae3b963462 /sys/kern/kern_pledge.c | |
parent | 317a2ca125a39767430ea456a6c188c579172186 (diff) |
Use READ_ONCE() when saving pr->ps_pledge to a local variable
This prevents the compiler from reloading a possibly different value
from memory. Even if it doesn't matter in this code it's just better
practice. Discussed with kettenis@ and deraadt@, ok deraadt@
Diffstat (limited to 'sys/kern/kern_pledge.c')
-rw-r--r-- | sys/kern/kern_pledge.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/sys/kern/kern_pledge.c b/sys/kern/kern_pledge.c index 4939a6e8bb2..7f554108097 100644 --- a/sys/kern/kern_pledge.c +++ b/sys/kern/kern_pledge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_pledge.c,v 1.282 2022/06/26 06:11:49 jsg Exp $ */ +/* $OpenBSD: kern_pledge.c,v 1.283 2022/06/29 12:01:22 jca Exp $ */ /* * Copyright (c) 2015 Nicholas Marriott <nicm@openbsd.org> @@ -583,7 +583,7 @@ pledge_namei(struct proc *p, struct nameidata *ni, char *origpath) if ((p->p_p->ps_flags & PS_PLEDGE) == 0 || (p->p_p->ps_flags & PS_COREDUMP)) return (0); - pledge = p->p_p->ps_pledge; + pledge = READ_ONCE(p->p_p->ps_pledge); if (ni->ni_pledge == 0) panic("pledge_namei: ni_pledge"); @@ -826,7 +826,7 @@ pledge_sysctl(struct proc *p, int miblen, int *mib, void *new) if ((p->p_p->ps_flags & PS_PLEDGE) == 0) return (0); - pledge = p->p_p->ps_pledge; + pledge = READ_ONCE(p->p_p->ps_pledge); if (new) return pledge_fail(p, EFAULT, 0); @@ -1070,7 +1070,7 @@ pledge_ioctl(struct proc *p, long com, struct file *fp) if ((p->p_p->ps_flags & PS_PLEDGE) == 0) return (0); - pledge = p->p_p->ps_pledge; + pledge = READ_ONCE(p->p_p->ps_pledge); /* * The ioctl's which are always allowed. @@ -1365,7 +1365,7 @@ pledge_sockopt(struct proc *p, int set, int level, int optname) if ((p->p_p->ps_flags & PS_PLEDGE) == 0) return (0); - pledge = p->p_p->ps_pledge; + pledge = READ_ONCE(p->p_p->ps_pledge); /* Always allow these, which are too common to reject */ switch (level) { @@ -1515,7 +1515,7 @@ pledge_socket(struct proc *p, int domain, unsigned int state) if (!ISSET(p->p_p->ps_flags, PS_PLEDGE)) return 0; - pledge = p->p_p->ps_pledge; + pledge = READ_ONCE(p->p_p->ps_pledge); if (ISSET(state, SS_DNS)) { if (ISSET(pledge, PLEDGE_DNS)) |