]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
ksmbd: fix racy issue from using ->d_parent and ->d_name
authorNamjae Jeon <linkinjeon@kernel.org>
Sun, 31 Dec 2023 07:12:37 +0000 (16:12 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 5 Jan 2024 14:18:29 +0000 (15:18 +0100)
commit6927ffe7479c72e7ebf885507227266a75f7c97d
tree844007646c22b2fdce3b294e40f62f0983e29155
parent6e99fbb4296ad0a2f8c6674246a345045ef1eccb
ksmbd: fix racy issue from using ->d_parent and ->d_name

[ Upstream commit 74d7970febf7e9005375aeda0df821d2edffc9f7 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/namei.c
fs/smb/server/smb2pdu.c
fs/smb/server/vfs.c
fs/smb/server/vfs.h
fs/smb/server/vfs_cache.c
include/linux/namei.h