mirror of https://github.com/torvalds/linux.git
ovl: port ovl_create_or_link() to new ovl_override_creator_creds cleanup guard
This clearly indicates the double-credential override and makes the code a lot easier to grasp with one glance. Link: https://patch.msgid.link/20251117-work-ovl-cred-guard-prepare-v2-5-bd1c97a36d7b@kernel.org Reviewed-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
8a227c2766
commit
e566bff963
|
|
@ -664,10 +664,9 @@ static int ovl_create_or_link(struct dentry *dentry, struct inode *inode,
|
||||||
struct ovl_cattr *attr, bool origin)
|
struct ovl_cattr *attr, bool origin)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
const struct cred *new_cred __free(put_cred) = NULL;
|
|
||||||
struct dentry *parent = dentry->d_parent;
|
struct dentry *parent = dentry->d_parent;
|
||||||
|
|
||||||
scoped_class(override_creds_ovl, old_cred, dentry->d_sb) {
|
with_ovl_creds(dentry->d_sb) {
|
||||||
/*
|
/*
|
||||||
* When linking a file with copy up origin into a new parent, mark the
|
* When linking a file with copy up origin into a new parent, mark the
|
||||||
* new parent dir "impure".
|
* new parent dir "impure".
|
||||||
|
|
@ -695,11 +694,11 @@ static int ovl_create_or_link(struct dentry *dentry, struct inode *inode,
|
||||||
if (attr->hardlink)
|
if (attr->hardlink)
|
||||||
return ovl_create_handle_whiteouts(dentry, inode, attr);
|
return ovl_create_handle_whiteouts(dentry, inode, attr);
|
||||||
|
|
||||||
new_cred = ovl_setup_cred_for_create(dentry, inode, attr->mode, old_cred);
|
scoped_class(ovl_override_creator_creds, cred, dentry, inode, attr->mode) {
|
||||||
if (IS_ERR(new_cred))
|
if (IS_ERR(cred))
|
||||||
return PTR_ERR(new_cred);
|
return PTR_ERR(cred);
|
||||||
|
return ovl_create_handle_whiteouts(dentry, inode, attr);
|
||||||
return ovl_create_handle_whiteouts(dentry, inode, attr);
|
}
|
||||||
}
|
}
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue