diff options
| author | Olivier Certner <olce@FreeBSD.org> | 2025-11-03 18:21:08 +0000 |
|---|---|---|
| committer | Olivier Certner <olce@FreeBSD.org> | 2025-11-06 04:06:41 +0000 |
| commit | a5d1a0c9bfcca38528b861c5afb51ea9b1696b65 (patch) | |
| tree | 0063282a1a57be98d1f88d500f1ca985679f2a0e /doc/html/appdev/refs/macros/KRB5_NT_ENTERPRISE_PRINCIPAL.html | |
| parent | 744c8d55445300074fc1906ad50aa6f394c1b8cf (diff) | |
In system calls changing process credentials, on RACCT, calls to
racct_proc_ucred_changed() must be issued on the new credentials.
Currently, this is done after the new credentials have been installed on
the process via proc_set_cred() or proc_set_cred_enforce_proc_lim(),
which modifies 'p_ucred'. Only the process lock guarantees that the new
credentials pointed to by 'p_ucred' cannot themselves be concurrently
modified, which would cause their 'struct ucred' to potentially lose its
last reference from the process before the call to
racct_proc_ucred_changed(), which needs one.
For better code understandability and to avoid errors in future
modifications, stop relying on proc_set_cred*() storing the passed
'struct ucred' in the process 'p_ucred' and on the process lock to avoid
the reference taken by proc_set_cred*() to vanish. Instead, ensure that
a reference is held when racct_proc_ucred_changed() is called.
As racct_proc_ucred_changed() is actually passed explicit pointers to
the old and new credentials, there is in fact no need to call it after
proc_set_cred(). Instead, call it before proc_set_cred() and its taking
over the reference.
Since setcred() uses proc_set_cred_enforce_proc_lim(), which can fail,
instead of proc_set_cred(), we instead take an additional reference with
crhold(). Indeed, racct_proc_ucred_changed() should update resource
accounting only if proc_set_cred_enforce_proc_lim() succeeds (an
alternative would be to call it in advance and then in case of failure
of the latter to call it again in order to backpedal the updated
accounting, but we don't see a compelling reason to do that instead of
taking an additional reference).
While here, add to the documentation of proc_set_cred_enforce_proc_lim()
that it does not take over the credentials reference in case of failure.
While here, in racct_proc_ucred_changed()'s herald comment, add the
precise condition in which this function must be called.
No functional change intended.
Reviewed by: kib
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D53563
Diffstat (limited to 'doc/html/appdev/refs/macros/KRB5_NT_ENTERPRISE_PRINCIPAL.html')
0 files changed, 0 insertions, 0 deletions
