Skip to content

Commit

Permalink
netpoll: Disable IRQ around RCU dereference in netpoll_rx
Browse files Browse the repository at this point in the history
We cannot use rcu_dereference_bh safely in netpoll_rx as we may
be called with IRQs disabled.  We could however simply disable
IRQs as that too causes BH to be disabled and is safe in either
case.

Thanks to John Linville for discovering this bug and providing
a patch.

Signed-off-by: Herbert Xu <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
herbertx authored and davem330 committed Sep 17, 2010
1 parent 4bdab43 commit f0f9dea
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions include/linux/netpoll.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,20 @@ static inline bool netpoll_rx(struct sk_buff *skb)
unsigned long flags;
bool ret = false;

rcu_read_lock_bh();
local_irq_save(flags);
npinfo = rcu_dereference_bh(skb->dev->npinfo);

if (!npinfo || (list_empty(&npinfo->rx_np) && !npinfo->rx_flags))
goto out;

spin_lock_irqsave(&npinfo->rx_lock, flags);
spin_lock(&npinfo->rx_lock);
/* check rx_flags again with the lock held */
if (npinfo->rx_flags && __netpoll_rx(skb))
ret = true;
spin_unlock_irqrestore(&npinfo->rx_lock, flags);
spin_unlock(&npinfo->rx_lock);

out:
rcu_read_unlock_bh();
local_irq_restore(flags);
return ret;
}

Expand Down

0 comments on commit f0f9dea

Please sign in to comment.