Linux cgroups development
 help / color / mirror / Atom feed
From: Christian Brauner <brauner@kernel.org>
To: Amir Goldstein <amir73il@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	 linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-aio@kvack.org,  linux-unionfs@vger.kernel.org,
	linux-erofs@lists.ozlabs.org, linux-nfs@vger.kernel.org,
	 linux-cifs@vger.kernel.org, samba-technical@lists.samba.org,
	cgroups@vger.kernel.org,  netdev@vger.kernel.org
Subject: Re: [PATCH 00/16] credentials guards: the easy cases
Date: Mon, 3 Nov 2025 15:53:41 +0100	[thread overview]
Message-ID: <20251103-studien-anwalt-1991078e7e12@brauner> (raw)
In-Reply-To: <CAOQ4uxgr33rf1tzjqdJex_tzNYDqj45=qLzi3BkMUaezgbJqoQ@mail.gmail.com>

On Mon, Nov 03, 2025 at 02:29:40PM +0100, Amir Goldstein wrote:
> On Mon, Nov 3, 2025 at 12:28 PM Christian Brauner <brauner@kernel.org> wrote:
> >
> > This converts all users of override_creds() to rely on credentials
> > guards. Leave all those that do the prepare_creds() + modify creds +
> > override_creds() dance alone for now. Some of them qualify for their own
> > variant.
> 
> Nice!
> 
> What about with_ovl_creator_cred()/scoped_with_ovl_creator_cred()?
> Is there any reason not to do it as well?

No, I don't think there is other than that the complexity of it warrants
a separate patch series.

When override_creds()/revert_creds() still was a reference count
bonanza, we struggled with two issues related to overlayfs:

(1) reference counting was sometimes very non-obvious
    (think:
    cred = get_cred(creator_cred);
    old_cred = override_cred(cred);
    put_cred(revert_creds(old_cred));
    put_cred(cred); or worse )

    and thus the credential override logic when creating files where you
    change the fsuid and you essentially override credentials _twice_
    lead to pretty twisted logic that wasn't necessarily clarified by
    the scope-based semantics.

    This problem is now resolved since my prior rework.

(2) The scope based cleanup did struggle in switch() statements that
    messed with the scope-based logic iirc. I don't have the details in
    my head right now anymore but basically this is why we originally
    punted on the original conversion so we wouldn't end up chasing bugs
    in two semantic changes done at the same time.

    I think we're ready to do (2) now.

What I tried in this series is to reduce the amount of scope switching
due to gotos and that's why I also moved some code around. It also helps
to visually clarify the guards when the scope is reduced by moving large
portions where work is done under a guard out to a helper. That's
especially true when the guard overrides credentials imho. That's
something I already aimed for during the first conversion.

> 
> I can try to clear some time for this cleanup.
> 
> For this series, feel free to add:
> 
> Reviewed-by: Amir Goldstein <amir73il@gmail.com>
> 
> Thanks,
> Amir.
> 
> >
> > Signed-off-by: Christian Brauner <brauner@kernel.org>
> > ---
> > Christian Brauner (16):
> >       cred: add {scoped_}with_creds() guards
> >       aio: use credential guards
> >       backing-file: use credential guards for reads
> >       backing-file: use credential guards for writes
> >       backing-file: use credential guards for splice read
> >       backing-file: use credential guards for splice write
> >       backing-file: use credential guards for mmap
> >       binfmt_misc: use credential guards
> >       erofs: use credential guards
> >       nfs: use credential guards in nfs_local_call_read()
> >       nfs: use credential guards in nfs_local_call_write()
> >       nfs: use credential guards in nfs_idmap_get_key()
> >       smb: use credential guards in cifs_get_spnego_key()
> >       act: use credential guards in acct_write_process()
> >       cgroup: use credential guards in cgroup_attach_permissions()
> >       net/dns_resolver: use credential guards in dns_query()
> >
> >  fs/aio.c                     |   6 +-
> >  fs/backing-file.c            | 147 ++++++++++++++++++++++---------------------
> >  fs/binfmt_misc.c             |   7 +--
> >  fs/erofs/fileio.c            |   6 +-
> >  fs/nfs/localio.c             |  59 +++++++++--------
> >  fs/nfs/nfs4idmap.c           |   7 +--
> >  fs/smb/client/cifs_spnego.c  |   6 +-
> >  include/linux/cred.h         |  12 ++--
> >  kernel/acct.c                |   6 +-
> >  kernel/cgroup/cgroup.c       |  10 ++-
> >  net/dns_resolver/dns_query.c |   6 +-
> >  11 files changed, 133 insertions(+), 139 deletions(-)
> > ---
> > base-commit: fea79c89ff947a69a55fed5ce86a70840e6d719c
> > change-id: 20251103-work-creds-guards-simple-619ef2200d22
> >
> >

      reply	other threads:[~2025-11-03 14:53 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-03 11:26 [PATCH 00/16] credentials guards: the easy cases Christian Brauner
2025-11-03 11:26 ` [PATCH 01/16] cred: add {scoped_}with_creds() guards Christian Brauner
2025-11-03 11:26 ` [PATCH 02/16] aio: use credential guards Christian Brauner
2025-11-03 11:26 ` [PATCH 03/16] backing-file: use credential guards for reads Christian Brauner
2025-11-03 11:26 ` [PATCH 04/16] backing-file: use credential guards for writes Christian Brauner
2025-11-03 13:24   ` Amir Goldstein
2025-11-03 11:26 ` [PATCH 05/16] backing-file: use credential guards for splice read Christian Brauner
2025-11-03 11:26 ` [PATCH 06/16] backing-file: use credential guards for splice write Christian Brauner
2025-11-03 11:26 ` [PATCH 07/16] backing-file: use credential guards for mmap Christian Brauner
2025-11-03 11:26 ` [PATCH 08/16] binfmt_misc: use credential guards Christian Brauner
2025-11-03 11:26 ` [PATCH 09/16] erofs: " Christian Brauner
2025-11-03 11:26 ` [PATCH 10/16] nfs: use credential guards in nfs_local_call_read() Christian Brauner
2025-11-03 11:26 ` [PATCH 11/16] nfs: use credential guards in nfs_local_call_write() Christian Brauner
2025-11-03 11:27 ` [PATCH 12/16] nfs: use credential guards in nfs_idmap_get_key() Christian Brauner
2025-11-03 11:27 ` [PATCH 13/16] smb: use credential guards in cifs_get_spnego_key() Christian Brauner
2025-11-03 11:27 ` [PATCH 14/16] act: use credential guards in acct_write_process() Christian Brauner
2025-11-03 23:04   ` Linus Torvalds
2025-11-04  9:45     ` Amir Goldstein
2025-11-04 11:40     ` Christian Brauner
2025-11-03 11:27 ` [PATCH 15/16] cgroup: use credential guards in cgroup_attach_permissions() Christian Brauner
2025-11-03 11:27 ` [PATCH 16/16] net/dns_resolver: use credential guards in dns_query() Christian Brauner
2025-11-03 13:29 ` [PATCH 00/16] credentials guards: the easy cases Amir Goldstein
2025-11-03 14:53   ` Christian Brauner [this message]

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=20251103-studien-anwalt-1991078e7e12@brauner \
    --to=brauner@kernel.org \
    --cc=amir73il@gmail.com \
    --cc=cgroups@vger.kernel.org \
    --cc=linux-aio@kvack.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=samba-technical@lists.samba.org \
    --cc=torvalds@linux-foundation.org \
    /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