Commit 1891abe
ksmbd: fix recursive locking in RPC handle list access
[ Upstream commit 88f1708 ]
Since commit 305853c ("ksmbd: Fix race condition in RPC handle list
access"), ksmbd_session_rpc_method() attempts to lock sess->rpc_lock.
This causes hung connections / tasks when a client attempts to open
a named pipe. Using Samba's rpcclient tool:
$ rpcclient //192.168.1.254 -U user%password
$ rpcclient $> srvinfo
<connection hung here>
Kernel side:
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:kworker/0:0 state:D stack:0 pid:5021 tgid:5021 ppid:2 flags:0x00200000
Workqueue: ksmbd-io handle_ksmbd_work
Call trace:
__schedule from schedule+0x3c/0x58
schedule from schedule_preempt_disabled+0xc/0x10
schedule_preempt_disabled from rwsem_down_read_slowpath+0x1b0/0x1d8
rwsem_down_read_slowpath from down_read+0x28/0x30
down_read from ksmbd_session_rpc_method+0x18/0x3c
ksmbd_session_rpc_method from ksmbd_rpc_open+0x34/0x68
ksmbd_rpc_open from ksmbd_session_rpc_open+0x194/0x228
ksmbd_session_rpc_open from create_smb2_pipe+0x8c/0x2c8
create_smb2_pipe from smb2_open+0x10c/0x27ac
smb2_open from handle_ksmbd_work+0x238/0x3dc
handle_ksmbd_work from process_scheduled_works+0x160/0x25c
process_scheduled_works from worker_thread+0x16c/0x1e8
worker_thread from kthread+0xa8/0xb8
kthread from ret_from_fork+0x14/0x38
Exception stack(0x8529ffb0 to 0x8529fff8)
The task deadlocks because the lock is already held:
ksmbd_session_rpc_open
down_write(&sess->rpc_lock)
ksmbd_rpc_open
ksmbd_session_rpc_method
down_read(&sess->rpc_lock) <-- deadlock
Adjust ksmbd_session_rpc_method() callers to take the lock when necessary.
Fixes: 305853c ("ksmbd: Fix race condition in RPC handle list access")
Signed-off-by: Marios Makassikis <mmakassikis@freebox.fr>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Li hongliang <1468888505@139.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>1 parent b6978c5 commit 1891abe
3 files changed
Lines changed: 22 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
150 | | - | |
151 | 150 | | |
152 | | - | |
| 151 | + | |
153 | 152 | | |
154 | | - | |
155 | | - | |
156 | 153 | | |
157 | | - | |
| 154 | + | |
158 | 155 | | |
159 | 156 | | |
160 | 157 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4614 | 4614 | | |
4615 | 4615 | | |
4616 | 4616 | | |
4617 | | - | |
| 4617 | + | |
| 4618 | + | |
| 4619 | + | |
| 4620 | + | |
| 4621 | + | |
| 4622 | + | |
4618 | 4623 | | |
| 4624 | + | |
| 4625 | + | |
4619 | 4626 | | |
4620 | 4627 | | |
4621 | 4628 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
778 | 778 | | |
779 | 779 | | |
780 | 780 | | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
781 | 784 | | |
782 | 785 | | |
783 | 786 | | |
| |||
786 | 789 | | |
787 | 790 | | |
788 | 791 | | |
| 792 | + | |
789 | 793 | | |
790 | 794 | | |
791 | 795 | | |
| |||
802 | 806 | | |
803 | 807 | | |
804 | 808 | | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
805 | 812 | | |
806 | 813 | | |
807 | 814 | | |
808 | 815 | | |
809 | 816 | | |
810 | 817 | | |
811 | 818 | | |
| 819 | + | |
812 | 820 | | |
813 | 821 | | |
814 | 822 | | |
| |||
829 | 837 | | |
830 | 838 | | |
831 | 839 | | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
832 | 843 | | |
833 | 844 | | |
834 | 845 | | |
| |||
837 | 848 | | |
838 | 849 | | |
839 | 850 | | |
| 851 | + | |
840 | 852 | | |
841 | 853 | | |
842 | 854 | | |
| |||
0 commit comments