Commit d5fc140
smb/server: avoid deadlock when linking with ReplaceIfExists
If smb2_create_link() is called with ReplaceIfExists set and the name
does exist then a deadlock will happen.
ksmbd_vfs_kern_path_locked() will return with success and the parent
directory will be locked. ksmbd_vfs_remove_file() will then remove the
file. ksmbd_vfs_link() will then be called while the parent is still
locked. It will try to lock the same parent and will deadlock.
This patch moves the ksmbd_vfs_kern_path_unlock() call to *before*
ksmbd_vfs_link() and then simplifies the code, removing the file_present
flag variable.
Signed-off-by: NeilBrown <neil@brown.name>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>1 parent a5dc90a commit d5fc140
1 file changed
Lines changed: 4 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6037 | 6037 | | |
6038 | 6038 | | |
6039 | 6039 | | |
6040 | | - | |
6041 | 6040 | | |
6042 | 6041 | | |
6043 | 6042 | | |
| |||
6070 | 6069 | | |
6071 | 6070 | | |
6072 | 6071 | | |
6073 | | - | |
6074 | | - | |
6075 | | - | |
6076 | | - | |
6077 | | - | |
| 6072 | + | |
| 6073 | + | |
6078 | 6074 | | |
6079 | 6075 | | |
6080 | 6076 | | |
6081 | 6077 | | |
6082 | 6078 | | |
6083 | 6079 | | |
6084 | 6080 | | |
6085 | | - | |
6086 | | - | |
6087 | | - | |
| 6081 | + | |
6088 | 6082 | | |
6089 | 6083 | | |
6090 | 6084 | | |
6091 | 6085 | | |
| 6086 | + | |
6092 | 6087 | | |
6093 | | - | |
6094 | 6088 | | |
6095 | 6089 | | |
6096 | 6090 | | |
6097 | 6091 | | |
6098 | | - | |
6099 | | - | |
6100 | 6092 | | |
6101 | 6093 | | |
6102 | 6094 | | |
| |||
0 commit comments