Commit 20b4f6b
ksmbd: fix recursive locking in vfs helpers
[ Upstream commit 807252f ]
Running smb2.rename test from Samba smbtorture suite against a kernel built
with lockdep triggers a "possible recursive locking detected" warning.
This is because mnt_want_write() is called twice with no mnt_drop_write()
in between:
-> ksmbd_vfs_mkdir()
-> ksmbd_vfs_kern_path_create()
-> kern_path_create()
-> filename_create()
-> mnt_want_write()
-> mnt_want_write()
Fix this by removing the mnt_want_write/mnt_drop_write calls from vfs
helpers that call kern_path_create().
Full lockdep trace below:
============================================
WARNING: possible recursive locking detected
6.6.0-rc5 torvalds#775 Not tainted
--------------------------------------------
kworker/1:1/32 is trying to acquire lock:
ffff888005ac83f8 (sb_writers#5){.+.+}-{0:0}, at: ksmbd_vfs_mkdir+0xe1/0x410
but task is already holding lock:
ffff888005ac83f8 (sb_writers#5){.+.+}-{0:0}, at: filename_create+0xb6/0x260
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0
----
lock(sb_writers#5);
lock(sb_writers#5);
*** DEADLOCK ***
May be due to missing lock nesting notation
4 locks held by kworker/1:1/32:
#0: ffff8880064e4138 ((wq_completion)ksmbd-io){+.+.}-{0:0}, at: process_one_work+0x40e/0x980
#1: ffff888005b0fdd0 ((work_completion)(&work->work)){+.+.}-{0:0}, at: process_one_work+0x40e/0x980
#2: ffff888005ac83f8 (sb_writers#5){.+.+}-{0:0}, at: filename_create+0xb6/0x260
#3: ffff8880057ce760 (&type->i_mutex_dir_key#3/1){+.+.}-{3:3}, at: filename_create+0x123/0x260
Cc: [email protected]
Fixes: 40b268d ("ksmbd: add mnt_want_write to ksmbd vfs functions")
Signed-off-by: Marios Makassikis <[email protected]>
Acked-by: Namjae Jeon <[email protected]>
Signed-off-by: Steve French <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>1 parent f30a2ff commit 20b4f6b
1 file changed
+3
-20
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | 176 | | |
181 | 177 | | |
182 | 178 | | |
| |||
186 | 182 | | |
187 | 183 | | |
188 | 184 | | |
189 | | - | |
190 | 185 | | |
191 | | - | |
192 | 186 | | |
193 | 187 | | |
194 | 188 | | |
| |||
219 | 213 | | |
220 | 214 | | |
221 | 215 | | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | 216 | | |
227 | 217 | | |
228 | 218 | | |
| |||
233 | 223 | | |
234 | 224 | | |
235 | 225 | | |
236 | | - | |
| 226 | + | |
237 | 227 | | |
238 | 228 | | |
239 | 229 | | |
240 | 230 | | |
241 | | - | |
| 231 | + | |
242 | 232 | | |
243 | 233 | | |
244 | 234 | | |
245 | 235 | | |
246 | 236 | | |
247 | 237 | | |
248 | | - | |
249 | | - | |
250 | | - | |
| 238 | + | |
251 | 239 | | |
252 | 240 | | |
253 | 241 | | |
| |||
665 | 653 | | |
666 | 654 | | |
667 | 655 | | |
668 | | - | |
669 | | - | |
670 | | - | |
671 | | - | |
672 | 656 | | |
673 | 657 | | |
674 | 658 | | |
675 | 659 | | |
676 | 660 | | |
677 | | - | |
678 | 661 | | |
679 | 662 | | |
680 | 663 | | |
| |||
0 commit comments