[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231218-intim-lehrstellen-dbe053d6c3a8@brauner>
Date: Mon, 18 Dec 2023 17:30:37 +0100
From: Christian Brauner <brauner@...nel.org>
To: Amir Goldstein <amir73il@...il.com>
Cc: Vinicius Costa Gomes <vinicius.gomes@...el.com>, hu1.chen@...el.com,
miklos@...redi.hu, malini.bhandaru@...el.com, tim.c.chen@...el.com,
mikko.ylinen@...el.com, lizhen.you@...el.com,
linux-unionfs@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-fsdevel <linux-fsdevel@...r.kernel.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
David Howells <dhowells@...hat.com>,
Seth Forshee <sforshee@...nel.org>
Subject: Re: [RFC] HACK: overlayfs: Optimize overlay/restore creds
> > Yes, the important thing is that an object cannot change
> > its non_refcount property during its lifetime -
>
> ... which means that put_creds_ref() should assert that
> there is only a single refcount - the one handed out by
> prepare_creds_ref() before removing non_refcount or
> directly freeing the cred object.
>
> I must say that the semantics of making a non-refcounted copy
> to an object whose lifetime is managed by the caller sounds a lot
> less confusing to me.
So can't we do an override_creds() variant that is effectively just:
/* caller guarantees lifetime of @new */
const struct cred *foo_override_cred(const struct cred *new)
{
const struct cred *old = current->cred;
rcu_assign_pointer(current->cred, new);
return old;
}
/* caller guarantees lifetime of @old */
void foo_revert_creds(const struct cred *old)
{
const struct cred *override = current->cred;
rcu_assign_pointer(current->cred, old);
}
Maybe I really fail to understand this problem or the proposed solution:
the single reference that overlayfs keeps in ovl->creator_cred is tied
to the lifetime of the overlayfs superblock, no? And anyone who needs a
long term cred reference e.g, file->f_cred will take it's own reference
anyway. So it should be safe to just keep that reference alive until
overlayfs is unmounted, no? I'm sure it's something quite obvious why
that doesn't work but I'm just not seeing it currently.
Powered by blists - more mailing lists