aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/cluster/tcp.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2014-04-11 16:15:36 -0400
committerDavid S. Miller <davem@davemloft.net>2014-04-11 16:15:36 -0400
commit676d23690fb62b5d51ba5d659935e9f7d9da9f8e (patch)
treef6fbceee43e05c724868153ca37b702fb5e43b8c /fs/ocfs2/cluster/tcp.c
parentad20d5f673898578f9d8a156d7a4c921f5ca4584 (diff)
net: Fix use after free by removing length arg from sk_data_ready callbacks.
Several spots in the kernel perform a sequence like: skb_queue_tail(&sk->s_receive_queue, skb); sk->sk_data_ready(sk, skb->len); But at the moment we place the SKB onto the socket receive queue it can be consumed and freed up. So this skb->len access is potentially to freed up memory. Furthermore, the skb->len can be modified by the consumer so it is possible that the value isn't accurate. And finally, no actual implementation of this callback actually uses the length argument. And since nobody actually cared about it's value, lots of call sites pass arbitrary values in such as '0' and even '1'. So just remove the length argument from the callback, that way there is no confusion whatsoever and all of these use-after-free cases get fixed as a side effect. Based upon a patch by Eric Dumazet and his suggestion to audit this issue tree-wide. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'fs/ocfs2/cluster/tcp.c')
-rw-r--r--fs/ocfs2/cluster/tcp.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c
index eb649d23a4de..d857534b886e 100644
--- a/fs/ocfs2/cluster/tcp.c
+++ b/fs/ocfs2/cluster/tcp.c
@@ -137,7 +137,7 @@ static int o2net_sys_err_translations[O2NET_ERR_MAX] =
137static void o2net_sc_connect_completed(struct work_struct *work); 137static void o2net_sc_connect_completed(struct work_struct *work);
138static void o2net_rx_until_empty(struct work_struct *work); 138static void o2net_rx_until_empty(struct work_struct *work);
139static void o2net_shutdown_sc(struct work_struct *work); 139static void o2net_shutdown_sc(struct work_struct *work);
140static void o2net_listen_data_ready(struct sock *sk, int bytes); 140static void o2net_listen_data_ready(struct sock *sk);
141static void o2net_sc_send_keep_req(struct work_struct *work); 141static void o2net_sc_send_keep_req(struct work_struct *work);
142static void o2net_idle_timer(unsigned long data); 142static void o2net_idle_timer(unsigned long data);
143static void o2net_sc_postpone_idle(struct o2net_sock_container *sc); 143static void o2net_sc_postpone_idle(struct o2net_sock_container *sc);
@@ -597,9 +597,9 @@ static void o2net_set_nn_state(struct o2net_node *nn,
597} 597}
598 598
599/* see o2net_register_callbacks() */ 599/* see o2net_register_callbacks() */
600static void o2net_data_ready(struct sock *sk, int bytes) 600static void o2net_data_ready(struct sock *sk)
601{ 601{
602 void (*ready)(struct sock *sk, int bytes); 602 void (*ready)(struct sock *sk);
603 603
604 read_lock(&sk->sk_callback_lock); 604 read_lock(&sk->sk_callback_lock);
605 if (sk->sk_user_data) { 605 if (sk->sk_user_data) {
@@ -613,7 +613,7 @@ static void o2net_data_ready(struct sock *sk, int bytes)
613 } 613 }
614 read_unlock(&sk->sk_callback_lock); 614 read_unlock(&sk->sk_callback_lock);
615 615
616 ready(sk, bytes); 616 ready(sk);
617} 617}
618 618
619/* see o2net_register_callbacks() */ 619/* see o2net_register_callbacks() */
@@ -1953,9 +1953,9 @@ static void o2net_accept_many(struct work_struct *work)
1953 cond_resched(); 1953 cond_resched();
1954} 1954}
1955 1955
1956static void o2net_listen_data_ready(struct sock *sk, int bytes) 1956static void o2net_listen_data_ready(struct sock *sk)
1957{ 1957{
1958 void (*ready)(struct sock *sk, int bytes); 1958 void (*ready)(struct sock *sk);
1959 1959
1960 read_lock(&sk->sk_callback_lock); 1960 read_lock(&sk->sk_callback_lock);
1961 ready = sk->sk_user_data; 1961 ready = sk->sk_user_data;
@@ -1978,7 +1978,6 @@ static void o2net_listen_data_ready(struct sock *sk, int bytes)
1978 */ 1978 */
1979 1979
1980 if (sk->sk_state == TCP_LISTEN) { 1980 if (sk->sk_state == TCP_LISTEN) {
1981 mlog(ML_TCP, "bytes: %d\n", bytes);
1982 queue_work(o2net_wq, &o2net_listen_work); 1981 queue_work(o2net_wq, &o2net_listen_work);
1983 } else { 1982 } else {
1984 ready = NULL; 1983 ready = NULL;
@@ -1987,7 +1986,7 @@ static void o2net_listen_data_ready(struct sock *sk, int bytes)
1987out: 1986out:
1988 read_unlock(&sk->sk_callback_lock); 1987 read_unlock(&sk->sk_callback_lock);
1989 if (ready != NULL) 1988 if (ready != NULL)
1990 ready(sk, bytes); 1989 ready(sk);
1991} 1990}
1992 1991
1993static int o2net_open_listening_sock(__be32 addr, __be16 port) 1992static int o2net_open_listening_sock(__be32 addr, __be16 port)