Re: [GIT PULL] overlayfs updates for 6.13

From: Linus Torvalds
Date: Sat Nov 23 2024 - 01:09:33 EST


On Fri, 22 Nov 2024 at 21:21, Linus Torvalds
<torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> So may I ask that you look at perhaps just converting the (not very
> many) users of the non-light cred override to the "light" version?

I think you could do a completely automated conversion:

(a) add a new "dup_cred()" helper

/* Get the cred without clearing the 'non_rcu' flag */
const struct cred *dup_cred(const struct cred *cred)
{ get_new_cred((struct cred *)cred); return cred; }

(b) mindlessly convert:

override_creds(cred) -> override_creds_light(dup_cred(cred))

revert_creds(cred) -> put_cred(revert_creds_light(old));

(c) rename away the "_light" again:

override_creds_light -> override_creds
revert_creds_light -> revert_creds

and then finally the only non-automated part would be

(d) simplify any obvious and trivial dup_cred -> put_cred chains.

which might take some effort, but there should be at least a couple of
really obvious cases of "that's not necessary".

Because honestly, I think I'd rather see a few cases of

old_creds = override_creds(dup_cred(cred));
...
put_cred(revert_creds(old));

that look a bit more complicated, and couldn't be trivially simplified away.

That seems better than the current case of having two very different
forms of override_creds() / put_cred() where people have to know
deeply when to use one or the other.

No?

Linus