Skip to content

Commit 6fe55c2

Browse files
namjaejeonSteve French
authored andcommitted
ksmbd: call putname after using the last component
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>
1 parent 6cc2268 commit 6fe55c2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

fs/smb/server/vfs.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,14 @@ static int ksmbd_vfs_path_lookup_locked(struct ksmbd_share_config *share_conf,
8686
err = vfs_path_parent_lookup(filename, flags,
8787
&parent_path, &last, &type,
8888
root_share_path);
89-
putname(filename);
90-
if (err)
89+
if (err) {
90+
putname(filename);
9191
return err;
92+
}
9293

9394
if (unlikely(type != LAST_NORM)) {
9495
path_put(&parent_path);
96+
putname(filename);
9597
return -ENOENT;
9698
}
9799

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

112115
return 0;
113116

114117
err_out:
115118
inode_unlock(parent_path.dentry->d_inode);
116119
path_put(&parent_path);
120+
putname(filename);
117121
return -ENOENT;
118122
}
119123

0 commit comments

Comments
 (0)