linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/6] ovl: convert creation credential override to cred guard
@ 2025-11-17  9:34 Christian Brauner
  2025-11-17  9:34 ` [PATCH v2 1/6] ovl: add ovl_override_creator_creds " Christian Brauner
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Christian Brauner @ 2025-11-17  9:34 UTC (permalink / raw)
  To: Miklos Szeredi, Amir Goldstein
  Cc: Linus Torvalds, linux-unionfs, linux-fsdevel, Christian Brauner

Hey,

This is on top of the overlayfs cleanup guard work I already sent out.
This cleans up the creation specific credential override.

The current code to override credentials for creation operations is
pretty difficult to understand as we override the credentials twice:

(1) override with the mounter's credentials
(2) copy the mounts credentials and override the fs{g,u}id with the inode {u,g}id

And then we elide the revert_creds() because it would be an idempotent
revert. That elision doesn't buy us anything anymore though because it's
all reference count less anyway.

The fact that this is done in a function and that the revert is
happening in the original override makes this a lot to grasp.

By introducing a cleanup guard for the creation case we can make this a
lot easier to understand and extremely visually prevalent:

with_ovl_creds(dentry->d_sb) {
	scoped_class(prepare_creds_ovl, cred, dentry, inode, mode) {
		if (IS_ERR(cred))
			return PTR_ERR(cred);

		ovl_path_upper(dentry->d_parent, &realparentpath);

		/* more stuff you want to do */
}

I think this is a big improvement over what we have now.

Signed-off-by: Christian Brauner <brauner@kernel.org>
---
Changes in v2:
- Rename the creation credential guard to avoid theoretical confusion
  with the removal of the ovl_revert_creds() function.
- Link to v1: https://patch.msgid.link/20251114-work-ovl-cred-guard-prepare-v1-0-4fc1208afa3d@kernel.org

---
Christian Brauner (6):
      ovl: add ovl_override_creator_creds cred guard
      ovl: port ovl_create_tmpfile() to new ovl_override_creator_creds cleanup guard
      ovl: reflow ovl_create_or_link()
      ovl: mark ovl_setup_cred_for_create() as unused temporarily
      ovl: port ovl_create_or_link() to new ovl_override_creator_creds cleanup guard
      ovl: drop ovl_setup_cred_for_create()

 fs/overlayfs/dir.c | 147 ++++++++++++++++++++++++++++-------------------------
 1 file changed, 78 insertions(+), 69 deletions(-)
---
base-commit: fc64e774b2606549fe236fbf93fa6287c93dbdaa
change-id: 20251114-work-ovl-cred-guard-prepare-53210e7e41f8


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2025-11-17  9:55 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-17  9:34 [PATCH v2 0/6] ovl: convert creation credential override to cred guard Christian Brauner
2025-11-17  9:34 ` [PATCH v2 1/6] ovl: add ovl_override_creator_creds " Christian Brauner
2025-11-17  9:34 ` [PATCH v2 2/6] ovl: port ovl_create_tmpfile() to new ovl_override_creator_creds cleanup guard Christian Brauner
2025-11-17  9:54   ` Amir Goldstein
2025-11-17  9:34 ` [PATCH v2 3/6] ovl: reflow ovl_create_or_link() Christian Brauner
2025-11-17  9:54   ` Amir Goldstein
2025-11-17  9:34 ` [PATCH v2 4/6] ovl: mark ovl_setup_cred_for_create() as unused temporarily Christian Brauner
2025-11-17  9:34 ` [PATCH v2 5/6] ovl: port ovl_create_or_link() to new ovl_override_creator_creds cleanup guard Christian Brauner
2025-11-17  9:55   ` Amir Goldstein
2025-11-17  9:34 ` [PATCH v2 6/6] ovl: drop ovl_setup_cred_for_create() Christian Brauner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).