]> git.ipfire.org Git - thirdparty/linux.git/commit - fs/smb/server/vfs.c
ksmbd: fix racy issue from using ->d_parent and ->d_name
authorNamjae Jeon <linkinjeon@kernel.org>
Fri, 21 Apr 2023 07:09:01 +0000 (16:09 +0900)
committerSteve French <stfrench@microsoft.com>
Mon, 24 Apr 2023 05:09:20 +0000 (00:09 -0500)
commit74d7970febf7e9005375aeda0df821d2edffc9f7
tree0f4dbbd9bb7a756397c8b33d17b6066200b17fc8
parentaf36c51e0e111de4e908328d49cba49de758f66e
ksmbd: fix racy issue from using ->d_parent and ->d_name

Al pointed out that ksmbd has racy issue from using ->d_parent and ->d_name
in ksmbd_vfs_unlink and smb2_vfs_rename(). and use new lock_rename_child()
to lock stable parent while underlying rename racy.
Introduce vfs_path_parent_lookup helper to avoid out of share access and
export vfs functions like the following ones to use
vfs_path_parent_lookup().
 - rename __lookup_hash() to lookup_one_qstr_excl().
 - export lookup_one_qstr_excl().
 - export getname_kernel() and putname().

vfs_path_parent_lookup() is used for parent lookup of destination file
using absolute pathname given from FILE_RENAME_INFORMATION request.

Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/ksmbd/smb2pdu.c
fs/ksmbd/vfs.c
fs/ksmbd/vfs.h
fs/ksmbd/vfs_cache.c
fs/namei.c
include/linux/namei.h