]> git.baikalelectronics.ru Git - kernel.git/commit
scsi: iscsi: iscsi_tcp: Avoid holding spinlock while calling getpeername()
authorMark Mielke <mark.mielke@gmail.com>
Mon, 28 Sep 2020 04:33:29 +0000 (00:33 -0400)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 30 Sep 2020 03:09:19 +0000 (23:09 -0400)
commit01645d29ea4f985ca0467971090ec03fcdca4079
tree106b1dc9736cd1e3310d68c0beaaee4627b2b5f5
parent699cda5447c9a4e7e444198115e83c6a4c416762
scsi: iscsi: iscsi_tcp: Avoid holding spinlock while calling getpeername()

The kernel may fail to boot or devices may fail to come up when
initializing iscsi_tcp devices starting with Linux 5.8.

Commit 5e418e970a57 ("[SCSI] iscsi_tcp: use iscsi_conn_get_addr_param
libiscsi function") introduced getpeername() within the session spinlock.

Commit e3c6afd97e0f ("bpf: Add get{peer, sock}name attach types for
sock_addr") introduced BPF_CGROUP_RUN_SA_PROG_LOCK() within getpeername(),
which acquires a mutex and when used from iscsi_tcp devices can now lead to
"BUG: scheduling while atomic:" and subsequent damage.

Ensure that the spinlock is released before calling getpeername() or
getsockname(). sock_hold() and sock_put() are used to ensure that the
socket reference is preserved until after the getpeername() or
getsockname() complete.

Link: https://bugzilla.redhat.com/show_bug.cgi?id=1877345
Link: https://lkml.org/lkml/2020/7/28/1085
Link: https://lkml.org/lkml/2020/8/31/459
Link: https://lore.kernel.org/r/20200928043329.606781-1-mark.mielke@gmail.com
Fixes: 5e418e970a57 ("[SCSI] iscsi_tcp: use iscsi_conn_get_addr_param libiscsi function")
Fixes: e3c6afd97e0f ("bpf: Add get{peer, sock}name attach types for sock_addr")
Cc: stable@vger.kernel.org
Reported-by: Marc Dionne <marc.c.dionne@gmail.com>
Tested-by: Marc Dionne <marc.c.dionne@gmail.com>
Reviewed-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Mark Mielke <mark.mielke@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/iscsi_tcp.c