ovl: port ovl_fileattr_set() to cred guard

Use the scoped ovl cred guard.

Link: https://patch.msgid.link/20251117-work-ovl-cred-guard-v4-20-b31603935724@kernel.org
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
Christian Brauner
2025-11-17 10:33:51 +01:00
parent a3860a808f
commit af1d5d62f3

View File

@@ -636,7 +636,6 @@ int ovl_fileattr_set(struct mnt_idmap *idmap,
{
struct inode *inode = d_inode(dentry);
struct path upperpath;
const struct cred *old_cred;
unsigned int flags;
int err;
@@ -648,18 +647,18 @@ int ovl_fileattr_set(struct mnt_idmap *idmap,
if (err)
goto out;
old_cred = ovl_override_creds(inode->i_sb);
/*
* Store immutable/append-only flags in xattr and clear them
* in upper fileattr (in case they were set by older kernel)
* so children of "ovl-immutable" directories lower aliases of
* "ovl-immutable" hardlinks could be copied up.
* Clear xattr when flags are cleared.
*/
err = ovl_set_protattr(inode, upperpath.dentry, fa);
if (!err)
err = ovl_real_fileattr_set(&upperpath, fa);
ovl_revert_creds(old_cred);
with_ovl_creds(inode->i_sb) {
/*
* Store immutable/append-only flags in xattr and clear them
* in upper fileattr (in case they were set by older kernel)
* so children of "ovl-immutable" directories lower aliases of
* "ovl-immutable" hardlinks could be copied up.
* Clear xattr when flags are cleared.
*/
err = ovl_set_protattr(inode, upperpath.dentry, fa);
if (!err)
err = ovl_real_fileattr_set(&upperpath, fa);
}
ovl_drop_write(dentry);
/*