Re: [PATCH v2 2/2] drop_monitor: Make updating data->skb smp safe
From: Neil Horman <nhorman@tuxdriver.com>
Date: 2012-06-04 10:39:27
On Mon, Jun 04, 2012 at 09:45:10AM +0200, Eric Dumazet wrote:
On Fri, 2012-04-27 at 16:11 -0400, Neil Horman wrote:quoted
Eric Dumazet pointed out to me that the drop_monitor protocol has some holes in its smp protections. Specifically, its possible to replace data->skb while its being written. This patch corrects that by making data->skb and rcu protected variable. That will prevent it from being overwritten while a tracepoint is modifying it.quoted
static void send_dm_alert(struct work_struct *unused) { struct sk_buff *skb; - struct per_cpu_dm_data *data = &__get_cpu_var(dm_cpu_data); + struct per_cpu_dm_data *data = &get_cpu_var(dm_cpu_data); /* * Grab the skb we're about to send */ - skb = data->skb; + skb = rcu_dereference_protected(data->skb, 1); /* * Replace it with a new one@@ -111,8 +134,10 @@ static void send_dm_alert(struct work_struct *unused) /* * Ship it! */ - genlmsg_multicast(skb, 0, NET_DM_GRP_ALERT, GFP_KERNEL); + if (skb) + genlmsg_multicast(skb, 0, NET_DM_GRP_ALERT, GFP_KERNEL); + put_cpu_var(dm_cpu_data); }Oh well, drop_monitor can still trigger alerts :
Grr, Not sure why I didn't see this before. I'll take care of it shortly. Neil