On Thu, Nov 14, 2024 at 11:05:36AM +0100, Amir Goldstein wrote: > ovl_setup_cred_for_create() decrements one refcount of new creds and > ovl_revert_creds() in callers decrements the last refcount. > > In preparation to revert_creds_light() back to caller creds, pass an > explicit reference of the creators creds to the callers and drop the > refcount explicitly in the callers after ovl_revert_creds(). > > Signed-off-by: Amir Goldstein <amir73il@xxxxxxxxx> > --- > > Miklos, Christian, > > I was chasing a suspect memleak in revert_creds_light() patches. > This fix is unrelated to memleak but I think it is needed for > correctness anyway. > > This applies in the middle of the series after adding the > ovl_revert_creds() helper. Ok, so you're moving the put_cred() on the cred_for_create creds into the callers. Tbh, that patch alone here is very confusing because with the last patch in your tree at 07532f7f8450 you're calling old_cred = override_creds(override_cred); which made it buggy. But I see in 3756f22061c2 this is fixed and correctly uses old_cred = override_creds_light(override_cred); as expected. And together with that change your patch here makes perfect sense. I don't want to complain too much but it would've been nice if that was spelled out in the commit message. Would've spared me 30 minutes of staring at the code until I refreshed your branch. :) Reviewed-by: Christian Brauner <brauner@xxxxxxxxxx>