netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: check queue_index from sock is valid for device
@ 2010-11-01 19:53 Tom Herbert
  2010-11-01 19:56 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Tom Herbert @ 2010-11-01 19:53 UTC (permalink / raw)
  To: davem, netdev

In dev_pick_tx recompute the queue index if the value stored in the
socket is greater than or equal to the number of real queues for the
device.  The saved index in the sock structure is not guaranteed to
be appropriate for the egress device (this could happen on a route
change or in presence of tunnelling).  The result of the queue index
being bad would be to return a bogus queue (crash could prersumably
follow).

Signed-off-by: Tom Herbert <therbert@google.com>
---
 net/core/dev.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index 78b5a89..dc2a307 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2135,7 +2135,7 @@ static struct netdev_queue *dev_pick_tx(struct net_device *dev,
 	} else {
 		struct sock *sk = skb->sk;
 		queue_index = sk_tx_queue_get(sk);
-		if (queue_index < 0) {
+		if (queue_index < 0 || queue_index >= dev->real_num_tx_queues) {
 
 			queue_index = 0;
 			if (dev->real_num_tx_queues > 1)
-- 
1.7.3.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-11-01 19:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-01 19:53 [PATCH] net: check queue_index from sock is valid for device Tom Herbert
2010-11-01 19:56 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).