Commit bcf3a29
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 a79af8a ("[SCSI] iscsi_tcp: use iscsi_conn_get_addr_param
libiscsi function") introduced getpeername() within the session spinlock.
Commit 1b66d25 ("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: a79af8a ("[SCSI] iscsi_tcp: use iscsi_conn_get_addr_param libiscsi function")
Fixes: 1b66d25 ("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>1 parent 1494155 commit bcf3a29
1 file changed
Lines changed: 15 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
736 | 736 | | |
737 | 737 | | |
738 | 738 | | |
| 739 | + | |
739 | 740 | | |
740 | 741 | | |
741 | 742 | | |
| |||
747 | 748 | | |
748 | 749 | | |
749 | 750 | | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
750 | 755 | | |
751 | | - | |
| 756 | + | |
752 | 757 | | |
753 | 758 | | |
754 | | - | |
| 759 | + | |
755 | 760 | | |
756 | | - | |
| 761 | + | |
757 | 762 | | |
758 | 763 | | |
759 | 764 | | |
| |||
775 | 780 | | |
776 | 781 | | |
777 | 782 | | |
| 783 | + | |
778 | 784 | | |
779 | 785 | | |
780 | 786 | | |
| |||
789 | 795 | | |
790 | 796 | | |
791 | 797 | | |
792 | | - | |
793 | 798 | | |
794 | | - | |
| 799 | + | |
| 800 | + | |
795 | 801 | | |
796 | 802 | | |
797 | 803 | | |
| 804 | + | |
| 805 | + | |
798 | 806 | | |
799 | | - | |
| 807 | + | |
800 | 808 | | |
801 | | - | |
| 809 | + | |
802 | 810 | | |
803 | 811 | | |
804 | 812 | | |
| |||
0 commit comments