Re: [RFC v2 2/4] cred: Add a light version of override/revert_creds()

From: Vinicius Costa Gomes
Date: Fri Jan 26 2024 - 19:16:52 EST


Amir Goldstein <amir73il@xxxxxxxxx> writes:

> On Fri, Jan 26, 2024 at 1:57 AM Vinicius Costa Gomes
> <vinicius.gomes@xxxxxxxxx> wrote:
>>
>> 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.
>>
>> To make their usage less error prone, introduce cleanup guards asto be
>> used like this:
>>
>> guard(cred)(credentials_to_override_and_restore);
>>
>> or this:
>>
>> scoped_guard(cred, credentials_to_override_and_restore) {
>> /* with credentials overridden */
>> }
>>
>> Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@xxxxxxxxx>
>
> You may add:
> Reviewed-by: Amir Goldstein <amir73il@xxxxxxxxx>
>
> I would also add:
> Suggested-by: Christian Brauner <brauner@xxxxxxxxxx>
>

Forgot about that one.


Cheers,
--
Vinicius