ovl: port ovl_lower_positive() to cred guard

Use the scoped ovl cred guard.

Link: https://patch.msgid.link/20251117-work-ovl-cred-guard-v4-39-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:34:10 +01:00
parent 6b6ef7d16f
commit db7cfe8783
No known key found for this signature in database
GPG Key ID: 91C61BC06578DCA2
1 changed files with 34 additions and 36 deletions

View File

@ -1418,7 +1418,6 @@ bool ovl_lower_positive(struct dentry *dentry)
{ {
struct ovl_entry *poe = OVL_E(dentry->d_parent); struct ovl_entry *poe = OVL_E(dentry->d_parent);
const struct qstr *name = &dentry->d_name; const struct qstr *name = &dentry->d_name;
const struct cred *old_cred;
unsigned int i; unsigned int i;
bool positive = false; bool positive = false;
bool done = false; bool done = false;
@ -1434,7 +1433,7 @@ bool ovl_lower_positive(struct dentry *dentry)
if (!ovl_dentry_upper(dentry)) if (!ovl_dentry_upper(dentry))
return true; return true;
old_cred = ovl_override_creds(dentry->d_sb); with_ovl_creds(dentry->d_sb) {
/* Positive upper -> have to look up lower to see whether it exists */ /* Positive upper -> have to look up lower to see whether it exists */
for (i = 0; !done && !positive && i < ovl_numlower(poe); i++) { for (i = 0; !done && !positive && i < ovl_numlower(poe); i++) {
struct dentry *this; struct dentry *this;
@ -1445,8 +1444,7 @@ bool ovl_lower_positive(struct dentry *dentry)
* because lookup_one_positive_unlocked() will hash name * because lookup_one_positive_unlocked() will hash name
* with parentpath base, which is on another (lower fs). * with parentpath base, which is on another (lower fs).
*/ */
this = lookup_one_positive_unlocked( this = lookup_one_positive_unlocked(mnt_idmap(parentpath->layer->mnt),
mnt_idmap(parentpath->layer->mnt),
&QSTR_LEN(name->name, name->len), &QSTR_LEN(name->name, name->len),
parentpath->dentry); parentpath->dentry);
if (IS_ERR(this)) { if (IS_ERR(this)) {
@ -1473,7 +1471,7 @@ bool ovl_lower_positive(struct dentry *dentry)
dput(this); dput(this);
} }
} }
ovl_revert_creds(old_cred); }
return positive; return positive;
} }