]> git.baikalelectronics.ru Git - kernel.git/commitdiff
sctp: disable BH in sctp_for_each_endpoint
authorXin Long <lucien.xin@gmail.com>
Sat, 10 Jun 2017 06:48:14 +0000 (14:48 +0800)
committerDavid S. Miller <davem@davemloft.net>
Sat, 10 Jun 2017 20:18:10 +0000 (16:18 -0400)
Now sctp holds read_lock when foreach sctp_ep_hashtable without disabling
BH. If CPU schedules to another thread A at this moment, the thread A may
be trying to hold the write_lock with disabling BH.

As BH is disabled and CPU cannot schedule back to the thread holding the
read_lock, while the thread A keeps waiting for the read_lock. A dead
lock would be triggered by this.

This patch is to fix this dead lock by calling read_lock_bh instead to
disable BH when holding the read_lock in sctp_for_each_endpoint.

Fixes: e0f10e3bd3ff ("sctp: export some apis or variables for sctp_diag and reuse some for proc")
Reported-by: Xiumei Mu <xmu@redhat.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sctp/socket.c

index f16c8d97b7f313e9f671d8bb8620b0f9566e619f..30aa0a529215ae54e43bdcb54a6e1870761996c3 100644 (file)
@@ -4622,13 +4622,13 @@ int sctp_for_each_endpoint(int (*cb)(struct sctp_endpoint *, void *),
 
        for (head = sctp_ep_hashtable; hash < sctp_ep_hashsize;
             hash++, head++) {
-               read_lock(&head->lock);
+               read_lock_bh(&head->lock);
                sctp_for_each_hentry(epb, &head->chain) {
                        err = cb(sctp_ep(epb), p);
                        if (err)
                                break;
                }
-               read_unlock(&head->lock);
+               read_unlock_bh(&head->lock);
        }
 
        return err;