aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorTom Herbert <therbert@google.com>2010-07-14 20:50:29 -0700
committerGreg Kroah-Hartman <gregkh@suse.de>2010-08-02 10:26:28 -0700
commit47f13456eadc6b8cf591bd7ab11ed829c4af4b55 (patch)
tree90f0fc1bd7cf48d0c99a09c5f337307b656a2aeb /include
parentaf0216e8d8f1c2f8dade974a4db6cb08b732b484 (diff)
net: fix problem in reading sock TX queue
commit b0f77d0eae0c58a5a9691a067ada112ceeae2d00 upstream. Fix problem in reading the tx_queue recorded in a socket. In dev_pick_tx, the TX queue is read by doing a check with sk_tx_queue_recorded on the socket, followed by a sk_tx_queue_get. The problem is that there is not mutual exclusion across these calls in the socket so it it is possible that the queue in the sock can be invalidated after sk_tx_queue_recorded is called so that sk_tx_queue get returns -1, which sets 65535 in queue_index and thus dev_pick_tx returns 65536 which is a bogus queue and can cause crash in dev_queue_xmit. We fix this by only calling sk_tx_queue_get which does the proper checks. The interface is that sk_tx_queue_get returns the TX queue if the sock argument is non-NULL and TX queue is recorded, else it returns -1. sk_tx_queue_recorded is no longer used so it can be completely removed. Signed-off-by: Tom Herbert <therbert@google.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'include')
-rw-r--r--include/net/sock.h7
1 files changed, 1 insertions, 6 deletions
diff --git a/include/net/sock.h b/include/net/sock.h
index 86f2da1b9488..e45305d37f58 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1130,12 +1130,7 @@ static inline void sk_tx_queue_clear(struct sock *sk)
static inline int sk_tx_queue_get(const struct sock *sk)
{
- return sk->sk_tx_queue_mapping;
-}
-
-static inline bool sk_tx_queue_recorded(const struct sock *sk)
-{
- return (sk && sk->sk_tx_queue_mapping >= 0);
+ return sk ? sk->sk_tx_queue_mapping : -1;
}
static inline void sk_set_socket(struct sock *sk, struct socket *sock)