Skip to content

Commit

Permalink
ksmbd: call putname after using the last component
Browse files Browse the repository at this point in the history
last component point filename struct. Currently putname is called after
vfs_path_parent_lookup(). And then last component is used for
lookup_one_qstr_excl(). name in last component is freed by previous
calling putname(). And It cause file lookup failure when testing
generic/464 test of xfstest.

Fixes: 74d7970 ("ksmbd: fix racy issue from using ->d_parent and ->d_name")
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
  • Loading branch information
Namjae Jeon authored and Steve French committed May 27, 2023
1 parent 6cc2268 commit 6fe55c2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions fs/smb/server/vfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,14 @@ static int ksmbd_vfs_path_lookup_locked(struct ksmbd_share_config *share_conf,
err = vfs_path_parent_lookup(filename, flags,
&parent_path, &last, &type,
root_share_path);
putname(filename);
if (err)
if (err) {
putname(filename);
return err;
}

if (unlikely(type != LAST_NORM)) {
path_put(&parent_path);
putname(filename);
return -ENOENT;
}

Expand All @@ -108,12 +110,14 @@ static int ksmbd_vfs_path_lookup_locked(struct ksmbd_share_config *share_conf,
path->dentry = d;
path->mnt = share_conf->vfs_path.mnt;
path_put(&parent_path);
putname(filename);

return 0;

err_out:
inode_unlock(parent_path.dentry->d_inode);
path_put(&parent_path);
putname(filename);
return -ENOENT;
}

Expand Down

0 comments on commit 6fe55c2

Please sign in to comment.