mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 06:44:00 -04:00
cred: Add a light version of override/revert_creds()
Add a light version of override/revert_creds(), this should only be used when the credentials in question will outlive the critical section and the critical section doesn't change the ->usage of the credentials. Suggested-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
This commit is contained in:
committed by
Amir Goldstein
parent
48b50624ae
commit
49dffdfde4
@@ -485,7 +485,7 @@ EXPORT_SYMBOL(abort_creds);
|
||||
*/
|
||||
const struct cred *override_creds(const struct cred *new)
|
||||
{
|
||||
const struct cred *old = current->cred;
|
||||
const struct cred *old;
|
||||
|
||||
kdebug("override_creds(%p{%ld})", new,
|
||||
atomic_long_read(&new->usage));
|
||||
@@ -499,7 +499,7 @@ const struct cred *override_creds(const struct cred *new)
|
||||
* visible to other threads under RCU.
|
||||
*/
|
||||
get_new_cred((struct cred *)new);
|
||||
rcu_assign_pointer(current->cred, new);
|
||||
old = override_creds_light(new);
|
||||
|
||||
kdebug("override_creds() = %p{%ld}", old,
|
||||
atomic_long_read(&old->usage));
|
||||
@@ -521,7 +521,7 @@ void revert_creds(const struct cred *old)
|
||||
kdebug("revert_creds(%p{%ld})", old,
|
||||
atomic_long_read(&old->usage));
|
||||
|
||||
rcu_assign_pointer(current->cred, old);
|
||||
revert_creds_light(old);
|
||||
put_cred(override);
|
||||
}
|
||||
EXPORT_SYMBOL(revert_creds);
|
||||
|
||||
Reference in New Issue
Block a user