netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rps: fix insufficient bounds checking in store_rps_dev_flow_table_cnt()
@ 2011-12-21 18:50 Xi Wang
  2011-12-21 19:22 ` Eric Dumazet
  2011-12-22 23:35 ` [PATCH v2] " Xi Wang
  0 siblings, 2 replies; 20+ messages in thread
From: Xi Wang @ 2011-12-21 18:50 UTC (permalink / raw)
  To: Tom Herbert, David S. Miller; +Cc: netdev, Xi Wang

Setting a large rps_flow_cnt like 1073741824 (1 << 30) on 32-bit
platform will cause a kernel oops due to insufficient bounds checking.

	if (count > 1<<30) {
		/* Enforce a limit to prevent overflow */
		return -EINVAL;
	}
	count = roundup_pow_of_two(count);
	table = vmalloc(RPS_DEV_FLOW_TABLE_SIZE(count));

Note that the macro RPS_DEV_FLOW_TABLE_SIZE(count) is defined as:

	... + (count * sizeof(struct rps_dev_flow))

where sizeof(struct rps_dev_flow) is 8.  (1 << 30) * 8 will overflow
32 bits.  This patch changes the upper bound to (1 << 28).

Signed-off-by: Xi Wang <xi.wang@gmail.com>
---
 net/core/net-sysfs.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index c71c434..f53a947 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -665,7 +665,7 @@ static ssize_t store_rps_dev_flow_table_cnt(struct netdev_rx_queue *queue,
 	if (count) {
 		int i;
 
-		if (count > 1<<30) {
+		if (count > 1<<28) {
 			/* Enforce a limit to prevent overflow */
 			return -EINVAL;
 		}
-- 
1.7.5.4

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

end of thread, other threads:[~2011-12-24 21:19 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-21 18:50 [PATCH] rps: fix insufficient bounds checking in store_rps_dev_flow_table_cnt() Xi Wang
2011-12-21 19:22 ` Eric Dumazet
2011-12-21 19:41   ` David Miller
2011-12-21 23:41     ` Xi Wang
2011-12-22 23:35 ` [PATCH v2] " Xi Wang
2011-12-23  3:37   ` David Miller
2011-12-23  4:10   ` Eric Dumazet
2011-12-23  4:44     ` Xi Wang
2011-12-23  4:53       ` Eric Dumazet
2011-12-23  5:10         ` Xi Wang
2011-12-23  5:16           ` Eric Dumazet
2011-12-23  5:35             ` Eric Dumazet
2011-12-23  5:56               ` Xi Wang
2011-12-23 13:06                 ` Eric Dumazet
2011-12-23 14:30                   ` Xi Wang
2011-12-23 14:53                     ` Eric Dumazet
2011-12-23 15:07                       ` Xi Wang
2011-12-24 16:56                         ` [PATCH net-next] rfs: better sizing of dev_flow_table Eric Dumazet
2011-12-24 21:19                           ` David Miller
2011-12-23  5:49             ` [PATCH v2] rps: fix insufficient bounds checking in store_rps_dev_flow_table_cnt() Xi Wang

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).