Commit 87553aa5 authored by David S. Miller's avatar David S. Miller

Merge branch 'tcp_bh_fixes'

Eric Dumazet says:

====================
net: block BH in TCP callbacks

Four layers using TCP stack were assuming sk_callback_lock could
be locked using read_lock() in their handlers because TCP stack
was running with BH disabled.

This is no longer the case. Since presumably the rest could
also depend on BH being disabled, just use read_lock_bh().

Then each layer might consider switching to RCU protection
and no longer depend on BH.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents e00be9e4 b91083a4
...@@ -131,10 +131,10 @@ static void iscsi_sw_tcp_data_ready(struct sock *sk) ...@@ -131,10 +131,10 @@ static void iscsi_sw_tcp_data_ready(struct sock *sk)
struct iscsi_tcp_conn *tcp_conn; struct iscsi_tcp_conn *tcp_conn;
read_descriptor_t rd_desc; read_descriptor_t rd_desc;
read_lock(&sk->sk_callback_lock); read_lock_bh(&sk->sk_callback_lock);
conn = sk->sk_user_data; conn = sk->sk_user_data;
if (!conn) { if (!conn) {
read_unlock(&sk->sk_callback_lock); read_unlock_bh(&sk->sk_callback_lock);
return; return;
} }
tcp_conn = conn->dd_data; tcp_conn = conn->dd_data;
...@@ -154,7 +154,7 @@ static void iscsi_sw_tcp_data_ready(struct sock *sk) ...@@ -154,7 +154,7 @@ static void iscsi_sw_tcp_data_ready(struct sock *sk)
/* If we had to (atomically) map a highmem page, /* If we had to (atomically) map a highmem page,
* unmap it now. */ * unmap it now. */
iscsi_tcp_segment_unmap(&tcp_conn->in.segment); iscsi_tcp_segment_unmap(&tcp_conn->in.segment);
read_unlock(&sk->sk_callback_lock); read_unlock_bh(&sk->sk_callback_lock);
} }
static void iscsi_sw_tcp_state_change(struct sock *sk) static void iscsi_sw_tcp_state_change(struct sock *sk)
...@@ -165,10 +165,10 @@ static void iscsi_sw_tcp_state_change(struct sock *sk) ...@@ -165,10 +165,10 @@ static void iscsi_sw_tcp_state_change(struct sock *sk)
struct iscsi_session *session; struct iscsi_session *session;
void (*old_state_change)(struct sock *); void (*old_state_change)(struct sock *);
read_lock(&sk->sk_callback_lock); read_lock_bh(&sk->sk_callback_lock);
conn = sk->sk_user_data; conn = sk->sk_user_data;
if (!conn) { if (!conn) {
read_unlock(&sk->sk_callback_lock); read_unlock_bh(&sk->sk_callback_lock);
return; return;
} }
session = conn->session; session = conn->session;
...@@ -179,7 +179,7 @@ static void iscsi_sw_tcp_state_change(struct sock *sk) ...@@ -179,7 +179,7 @@ static void iscsi_sw_tcp_state_change(struct sock *sk)
tcp_sw_conn = tcp_conn->dd_data; tcp_sw_conn = tcp_conn->dd_data;
old_state_change = tcp_sw_conn->old_state_change; old_state_change = tcp_sw_conn->old_state_change;
read_unlock(&sk->sk_callback_lock); read_unlock_bh(&sk->sk_callback_lock);
old_state_change(sk); old_state_change(sk);
} }
......
...@@ -600,10 +600,11 @@ static void o2net_set_nn_state(struct o2net_node *nn, ...@@ -600,10 +600,11 @@ static void o2net_set_nn_state(struct o2net_node *nn,
static void o2net_data_ready(struct sock *sk) static void o2net_data_ready(struct sock *sk)
{ {
void (*ready)(struct sock *sk); void (*ready)(struct sock *sk);
struct o2net_sock_container *sc;
read_lock(&sk->sk_callback_lock); read_lock_bh(&sk->sk_callback_lock);
if (sk->sk_user_data) { sc = sk->sk_user_data;
struct o2net_sock_container *sc = sk->sk_user_data; if (sc) {
sclog(sc, "data_ready hit\n"); sclog(sc, "data_ready hit\n");
o2net_set_data_ready_time(sc); o2net_set_data_ready_time(sc);
o2net_sc_queue_work(sc, &sc->sc_rx_work); o2net_sc_queue_work(sc, &sc->sc_rx_work);
...@@ -611,7 +612,7 @@ static void o2net_data_ready(struct sock *sk) ...@@ -611,7 +612,7 @@ static void o2net_data_ready(struct sock *sk)
} else { } else {
ready = sk->sk_data_ready; ready = sk->sk_data_ready;
} }
read_unlock(&sk->sk_callback_lock); read_unlock_bh(&sk->sk_callback_lock);
ready(sk); ready(sk);
} }
...@@ -622,7 +623,7 @@ static void o2net_state_change(struct sock *sk) ...@@ -622,7 +623,7 @@ static void o2net_state_change(struct sock *sk)
void (*state_change)(struct sock *sk); void (*state_change)(struct sock *sk);
struct o2net_sock_container *sc; struct o2net_sock_container *sc;
read_lock(&sk->sk_callback_lock); read_lock_bh(&sk->sk_callback_lock);
sc = sk->sk_user_data; sc = sk->sk_user_data;
if (sc == NULL) { if (sc == NULL) {
state_change = sk->sk_state_change; state_change = sk->sk_state_change;
...@@ -649,7 +650,7 @@ static void o2net_state_change(struct sock *sk) ...@@ -649,7 +650,7 @@ static void o2net_state_change(struct sock *sk)
break; break;
} }
out: out:
read_unlock(&sk->sk_callback_lock); read_unlock_bh(&sk->sk_callback_lock);
state_change(sk); state_change(sk);
} }
...@@ -2012,7 +2013,7 @@ static void o2net_listen_data_ready(struct sock *sk) ...@@ -2012,7 +2013,7 @@ static void o2net_listen_data_ready(struct sock *sk)
{ {
void (*ready)(struct sock *sk); void (*ready)(struct sock *sk);
read_lock(&sk->sk_callback_lock); read_lock_bh(&sk->sk_callback_lock);
ready = sk->sk_user_data; ready = sk->sk_user_data;
if (ready == NULL) { /* check for teardown race */ if (ready == NULL) { /* check for teardown race */
ready = sk->sk_data_ready; ready = sk->sk_data_ready;
...@@ -2039,7 +2040,7 @@ static void o2net_listen_data_ready(struct sock *sk) ...@@ -2039,7 +2040,7 @@ static void o2net_listen_data_ready(struct sock *sk)
} }
out: out:
read_unlock(&sk->sk_callback_lock); read_unlock_bh(&sk->sk_callback_lock);
if (ready != NULL) if (ready != NULL)
ready(sk); ready(sk);
} }
......
...@@ -43,7 +43,7 @@ void rds_tcp_state_change(struct sock *sk) ...@@ -43,7 +43,7 @@ void rds_tcp_state_change(struct sock *sk)
struct rds_connection *conn; struct rds_connection *conn;
struct rds_tcp_connection *tc; struct rds_tcp_connection *tc;
read_lock(&sk->sk_callback_lock); read_lock_bh(&sk->sk_callback_lock);
conn = sk->sk_user_data; conn = sk->sk_user_data;
if (!conn) { if (!conn) {
state_change = sk->sk_state_change; state_change = sk->sk_state_change;
...@@ -69,7 +69,7 @@ void rds_tcp_state_change(struct sock *sk) ...@@ -69,7 +69,7 @@ void rds_tcp_state_change(struct sock *sk)
break; break;
} }
out: out:
read_unlock(&sk->sk_callback_lock); read_unlock_bh(&sk->sk_callback_lock);
state_change(sk); state_change(sk);
} }
......
...@@ -166,7 +166,7 @@ void rds_tcp_listen_data_ready(struct sock *sk) ...@@ -166,7 +166,7 @@ void rds_tcp_listen_data_ready(struct sock *sk)
rdsdebug("listen data ready sk %p\n", sk); rdsdebug("listen data ready sk %p\n", sk);
read_lock(&sk->sk_callback_lock); read_lock_bh(&sk->sk_callback_lock);
ready = sk->sk_user_data; ready = sk->sk_user_data;
if (!ready) { /* check for teardown race */ if (!ready) { /* check for teardown race */
ready = sk->sk_data_ready; ready = sk->sk_data_ready;
...@@ -183,7 +183,7 @@ void rds_tcp_listen_data_ready(struct sock *sk) ...@@ -183,7 +183,7 @@ void rds_tcp_listen_data_ready(struct sock *sk)
rds_tcp_accept_work(sk); rds_tcp_accept_work(sk);
out: out:
read_unlock(&sk->sk_callback_lock); read_unlock_bh(&sk->sk_callback_lock);
ready(sk); ready(sk);
} }
......
...@@ -301,7 +301,7 @@ void rds_tcp_data_ready(struct sock *sk) ...@@ -301,7 +301,7 @@ void rds_tcp_data_ready(struct sock *sk)
rdsdebug("data ready sk %p\n", sk); rdsdebug("data ready sk %p\n", sk);
read_lock(&sk->sk_callback_lock); read_lock_bh(&sk->sk_callback_lock);
conn = sk->sk_user_data; conn = sk->sk_user_data;
if (!conn) { /* check for teardown race */ if (!conn) { /* check for teardown race */
ready = sk->sk_data_ready; ready = sk->sk_data_ready;
...@@ -315,7 +315,7 @@ void rds_tcp_data_ready(struct sock *sk) ...@@ -315,7 +315,7 @@ void rds_tcp_data_ready(struct sock *sk)
if (rds_tcp_read_sock(conn, GFP_ATOMIC) == -ENOMEM) if (rds_tcp_read_sock(conn, GFP_ATOMIC) == -ENOMEM)
queue_delayed_work(rds_wq, &conn->c_recv_w, 0); queue_delayed_work(rds_wq, &conn->c_recv_w, 0);
out: out:
read_unlock(&sk->sk_callback_lock); read_unlock_bh(&sk->sk_callback_lock);
ready(sk); ready(sk);
} }
......
...@@ -180,7 +180,7 @@ void rds_tcp_write_space(struct sock *sk) ...@@ -180,7 +180,7 @@ void rds_tcp_write_space(struct sock *sk)
struct rds_connection *conn; struct rds_connection *conn;
struct rds_tcp_connection *tc; struct rds_tcp_connection *tc;
read_lock(&sk->sk_callback_lock); read_lock_bh(&sk->sk_callback_lock);
conn = sk->sk_user_data; conn = sk->sk_user_data;
if (!conn) { if (!conn) {
write_space = sk->sk_write_space; write_space = sk->sk_write_space;
...@@ -200,7 +200,7 @@ void rds_tcp_write_space(struct sock *sk) ...@@ -200,7 +200,7 @@ void rds_tcp_write_space(struct sock *sk)
queue_delayed_work(rds_wq, &conn->c_send_w, 0); queue_delayed_work(rds_wq, &conn->c_send_w, 0);
out: out:
read_unlock(&sk->sk_callback_lock); read_unlock_bh(&sk->sk_callback_lock);
/* /*
* write_space is only called when data leaves tcp's send queue if * write_space is only called when data leaves tcp's send queue if
......
...@@ -138,28 +138,28 @@ static void sock_data_ready(struct sock *sk) ...@@ -138,28 +138,28 @@ static void sock_data_ready(struct sock *sk)
{ {
struct tipc_conn *con; struct tipc_conn *con;
read_lock(&sk->sk_callback_lock); read_lock_bh(&sk->sk_callback_lock);
con = sock2con(sk); con = sock2con(sk);
if (con && test_bit(CF_CONNECTED, &con->flags)) { if (con && test_bit(CF_CONNECTED, &con->flags)) {
conn_get(con); conn_get(con);
if (!queue_work(con->server->rcv_wq, &con->rwork)) if (!queue_work(con->server->rcv_wq, &con->rwork))
conn_put(con); conn_put(con);
} }
read_unlock(&sk->sk_callback_lock); read_unlock_bh(&sk->sk_callback_lock);
} }
static void sock_write_space(struct sock *sk) static void sock_write_space(struct sock *sk)
{ {
struct tipc_conn *con; struct tipc_conn *con;
read_lock(&sk->sk_callback_lock); read_lock_bh(&sk->sk_callback_lock);
con = sock2con(sk); con = sock2con(sk);
if (con && test_bit(CF_CONNECTED, &con->flags)) { if (con && test_bit(CF_CONNECTED, &con->flags)) {
conn_get(con); conn_get(con);
if (!queue_work(con->server->send_wq, &con->swork)) if (!queue_work(con->server->send_wq, &con->swork))
conn_put(con); conn_put(con);
} }
read_unlock(&sk->sk_callback_lock); read_unlock_bh(&sk->sk_callback_lock);
} }
static void tipc_register_callbacks(struct socket *sock, struct tipc_conn *con) static void tipc_register_callbacks(struct socket *sock, struct tipc_conn *con)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment