aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/kern_racct.c
diff options
context:
space:
mode:
authorAndriy Gapon <avg@FreeBSD.org>2018-04-20 13:08:04 +0000
committerAndriy Gapon <avg@FreeBSD.org>2018-04-20 13:08:04 +0000
commitf87beb93e86c118848dcc8d3099b96470aa0a0f9 (patch)
tree3fb1f4b51cd600756f5afd307e1dfef5dd536662 /sys/kern/kern_racct.c
parentcb0d9834d4d1213f81da0f81c701a13668fc7dc9 (diff)
downloadsrc-f87beb93e86c118848dcc8d3099b96470aa0a0f9.tar.gz
src-f87beb93e86c118848dcc8d3099b96470aa0a0f9.zip
call racct_proc_ucred_changed() under the proc lock
The lock is required to ensure that the switch to the new credentials and the transfer of the process's accounting data from the old credentials to the new ones is done atomically. Otherwise, some updates may be applied to the new credentials and then additionally transferred from the old credentials if the updates happen after proc_set_cred() and before racct_proc_ucred_changed(). The problem is especially pronounced for RACCT_RSS because - there is a strict accounting for this resource (it's reclaimable) - it's updated asynchronously by the vm daemon - it's updated by setting an absolute value instead of applying a delta I had to remove a call to rctl_proc_ucred_changed() from racct_proc_ucred_changed() and make all callers of latter call the former as well. The reason is that rctl_proc_ucred_changed, as it is implemented now, cannot be called while holding the proc lock, so the lock is dropped after calling racct_proc_ucred_changed. Additionally, I've added calls to crhold / crfree around the rctl call, because without the proc lock there is no gurantee that the new credentials, owned by the process, will stay stable. That does not eliminate a possibility that the credentials passed to the rctl will get stale. Ideally, rctl_proc_ucred_changed should be able to work under the proc lock. Many thanks to kib for pointing out the above problems. PR: 222027 Discussed with: kib No comment: trasz MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D15048
Notes
Notes: svn path=/head/; revision=332816
Diffstat (limited to 'sys/kern/kern_racct.c')
-rw-r--r--sys/kern/kern_racct.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/sys/kern/kern_racct.c b/sys/kern/kern_racct.c
index 0081d4b0424d..d1ec1db880d4 100644
--- a/sys/kern/kern_racct.c
+++ b/sys/kern/kern_racct.c
@@ -1046,7 +1046,7 @@ racct_proc_ucred_changed(struct proc *p, struct ucred *oldcred,
if (!racct_enable)
return;
- PROC_LOCK_ASSERT(p, MA_NOTOWNED);
+ PROC_LOCK_ASSERT(p, MA_OWNED);
newuip = newcred->cr_ruidinfo;
olduip = oldcred->cr_ruidinfo;
@@ -1073,10 +1073,6 @@ racct_proc_ucred_changed(struct proc *p, struct ucred *oldcred,
p->p_racct);
}
RACCT_UNLOCK();
-
-#ifdef RCTL
- rctl_proc_ucred_changed(p, newcred);
-#endif
}
void