lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <1393538677-21268-1-git-send-email-zoltan.kiss@citrix.com>
Date:	Thu, 27 Feb 2014 22:04:37 +0000
From:	Zoltan Kiss <zoltan.kiss@...rix.com>
To:	Jesse Gross <jesse@...ira.com>, <pshelar@...ira.com>,
	<dev@...nvswitch.org>
CC:	<netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
	Zoltan Kiss <zoltan.kiss@...rix.com>
Subject: [PATCH] openvswitch: Disable bottom half when grabbing stats lock in userspace context

The megaflow feature introduced per-CPU stats, and the new code did some
refactoring as well [1]. However the new functions doesn't disable bottom halves
when locking the stat, and as they can be called from userspace context, they
can be interrupted by netif_receive_skb.

[1] e298e50570: openvswitch: Per cpu flow stats.

Signed-off-by: Zoltan Kiss <zoltan.kiss@...rix.com>
---
 net/openvswitch/flow.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
index 16f4b46..07a4672 100644
--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -90,13 +90,14 @@ static void stats_read(struct flow_stats *stats,
 		       struct ovs_flow_stats *ovs_stats,
 		       unsigned long *used, __be16 *tcp_flags)
 {
-	spin_lock(&stats->lock);
+	unsigned long flags;
+	spin_lock_irqsave(&stats->lock, flags);
 	if (time_after(stats->used, *used))
 		*used = stats->used;
 	*tcp_flags |= stats->tcp_flags;
 	ovs_stats->n_packets += stats->packet_count;
 	ovs_stats->n_bytes += stats->byte_count;
-	spin_unlock(&stats->lock);
+	spin_unlock_irqrestore(&stats->lock, flags);
 }
 
 void ovs_flow_stats_get(struct sw_flow *flow, struct ovs_flow_stats *ovs_stats,
@@ -130,12 +131,13 @@ void ovs_flow_stats_get(struct sw_flow *flow, struct ovs_flow_stats *ovs_stats,
 
 static void stats_reset(struct flow_stats *stats)
 {
-	spin_lock(&stats->lock);
+	unsigned long flags;
+	spin_lock_irqsave(&stats->lock, flags);
 	stats->used = 0;
 	stats->packet_count = 0;
 	stats->byte_count = 0;
 	stats->tcp_flags = 0;
-	spin_unlock(&stats->lock);
+	spin_unlock_irqrestore(&stats->lock, flags);
 }
 
 void ovs_flow_stats_clear(struct sw_flow *flow)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ