From: Christian Brauner <brauner@kernel.org>
To: Amir Goldstein <amir73il@gmail.com>
Cc: Vinicius Costa Gomes <vinicius.gomes@intel.com>,
hu1.chen@intel.com, miklos@szeredi.hu, malini.bhandaru@intel.com,
tim.c.chen@intel.com, mikko.ylinen@intel.com,
lizhen.you@intel.com, linux-unionfs@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
David Howells <dhowells@redhat.com>,
Seth Forshee <sforshee@kernel.org>
Subject: Re: [RFC] HACK: overlayfs: Optimize overlay/restore creds
Date: Mon, 18 Dec 2023 17:30:37 +0100 [thread overview]
Message-ID: <20231218-intim-lehrstellen-dbe053d6c3a8@brauner> (raw)
In-Reply-To: <CAOQ4uxhxvFt3_Wb3BGcjj4pGp=OFTBHNPJ4r4eH8245t-+CW+g@mail.gmail.com>
> > 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.
next prev parent reply other threads:[~2023-12-18 16:30 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAOQ4uxg-WvdcuCrQg7zp03ocNZoT-G2bpi=Y6nVxMTodyFAUbg@mail.gmail.com>
[not found] ` <20231214220222.348101-1-vinicius.gomes@intel.com>
2023-12-15 10:30 ` [RFC] HACK: overlayfs: Optimize overlay/restore creds Amir Goldstein
2023-12-15 20:00 ` Vinicius Costa Gomes
2023-12-16 10:16 ` Amir Goldstein
2023-12-16 11:38 ` Amir Goldstein
2023-12-18 16:30 ` Christian Brauner [this message]
2023-12-18 21:57 ` Vinicius Costa Gomes
2023-12-19 7:15 ` Amir Goldstein
2023-12-19 13:35 ` Christian Brauner
2023-12-19 14:33 ` Vinicius Costa Gomes
2024-01-23 15:39 ` Christian Brauner
2024-01-23 16:37 ` Vinicius Costa Gomes
2023-12-16 18:26 ` Linus Torvalds
2023-12-18 15:17 ` Christian Brauner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231218-intim-lehrstellen-dbe053d6c3a8@brauner \
--to=brauner@kernel.org \
--cc=amir73il@gmail.com \
--cc=dhowells@redhat.com \
--cc=hu1.chen@intel.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-unionfs@vger.kernel.org \
--cc=lizhen.you@intel.com \
--cc=malini.bhandaru@intel.com \
--cc=mikko.ylinen@intel.com \
--cc=miklos@szeredi.hu \
--cc=sforshee@kernel.org \
--cc=tim.c.chen@intel.com \
--cc=torvalds@linux-foundation.org \
--cc=vinicius.gomes@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox