Skip to content

Commit 714d02b

Browse files
amir73ilbrauner
authored andcommitted
ovl: fix regression caused by lookup helpers API changes
The lookup helpers API was changed by merge of vfs-6.16-rc1.async.dir to pass a non-const qstr pointer argument to lookup_one*() helpers. All of the callers of this API were changed to pass a pointer to temp copy of qstr, except overlays that was passing a const pointer to dentry->d_name that was changed to pass a non-const copy instead when doing a lookup in lower layer which is not the fs of said dentry. This wrong use of the API caused a regression in fstest overlay/012. Fix the regression by making a non-const copy of dentry->d_name prior to calling the lookup API, but the API should be fixed to not allow this class of bugs. Cc: NeilBrown <[email protected]> Fixes: 5741909 ("VFS: improve interface for lookup_one functions") Fixes: 390e34b ("VFS: change lookup_one_common and lookup_noperm_common to take a qstr") Signed-off-by: Amir Goldstein <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent b55eb6e commit 714d02b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

fs/overlayfs/namei.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,7 +1371,7 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
13711371
bool ovl_lower_positive(struct dentry *dentry)
13721372
{
13731373
struct ovl_entry *poe = OVL_E(dentry->d_parent);
1374-
struct qstr *name = &dentry->d_name;
1374+
const struct qstr *name = &dentry->d_name;
13751375
const struct cred *old_cred;
13761376
unsigned int i;
13771377
bool positive = false;
@@ -1394,9 +1394,15 @@ bool ovl_lower_positive(struct dentry *dentry)
13941394
struct dentry *this;
13951395
struct ovl_path *parentpath = &ovl_lowerstack(poe)[i];
13961396

1397+
/*
1398+
* We need to make a non-const copy of dentry->d_name,
1399+
* because lookup_one_positive_unlocked() will hash name
1400+
* with parentpath base, which is on another (lower fs).
1401+
*/
13971402
this = lookup_one_positive_unlocked(
13981403
mnt_idmap(parentpath->layer->mnt),
1399-
name, parentpath->dentry);
1404+
&QSTR_LEN(name->name, name->len),
1405+
parentpath->dentry);
14001406
if (IS_ERR(this)) {
14011407
switch (PTR_ERR(this)) {
14021408
case -ENOENT:

0 commit comments

Comments
 (0)