mirror of https://github.com/torvalds/linux.git
ovl: port ovl_set_or_remove_acl() to cred guard
Use the scoped ovl cred guard. Link: https://patch.msgid.link/20251117-work-ovl-cred-guard-v4-18-b31603935724@kernel.org Reviewed-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
71ac28fbcd
commit
8e9698d6e4
|
|
@ -472,7 +472,6 @@ static int ovl_set_or_remove_acl(struct dentry *dentry, struct inode *inode,
|
|||
int err;
|
||||
struct path realpath;
|
||||
const char *acl_name;
|
||||
const struct cred *old_cred;
|
||||
struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
|
||||
struct dentry *upperdentry = ovl_dentry_upper(dentry);
|
||||
struct dentry *realdentry = upperdentry ?: ovl_dentry_lower(dentry);
|
||||
|
|
@ -486,10 +485,8 @@ static int ovl_set_or_remove_acl(struct dentry *dentry, struct inode *inode,
|
|||
struct posix_acl *real_acl;
|
||||
|
||||
ovl_path_lower(dentry, &realpath);
|
||||
old_cred = ovl_override_creds(dentry->d_sb);
|
||||
real_acl = vfs_get_acl(mnt_idmap(realpath.mnt), realdentry,
|
||||
acl_name);
|
||||
ovl_revert_creds(old_cred);
|
||||
with_ovl_creds(dentry->d_sb)
|
||||
real_acl = vfs_get_acl(mnt_idmap(realpath.mnt), realdentry, acl_name);
|
||||
if (IS_ERR(real_acl)) {
|
||||
err = PTR_ERR(real_acl);
|
||||
goto out;
|
||||
|
|
@ -509,12 +506,12 @@ static int ovl_set_or_remove_acl(struct dentry *dentry, struct inode *inode,
|
|||
if (err)
|
||||
goto out;
|
||||
|
||||
old_cred = ovl_override_creds(dentry->d_sb);
|
||||
if (acl)
|
||||
err = ovl_do_set_acl(ofs, realdentry, acl_name, acl);
|
||||
else
|
||||
err = ovl_do_remove_acl(ofs, realdentry, acl_name);
|
||||
ovl_revert_creds(old_cred);
|
||||
with_ovl_creds(dentry->d_sb) {
|
||||
if (acl)
|
||||
err = ovl_do_set_acl(ofs, realdentry, acl_name, acl);
|
||||
else
|
||||
err = ovl_do_remove_acl(ofs, realdentry, acl_name);
|
||||
}
|
||||
ovl_drop_write(dentry);
|
||||
|
||||
/* copy c/mtime */
|
||||
|
|
|
|||
Loading…
Reference in New Issue