netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* act_mirred: remove spinlock in fast path
@ 2016-06-17 21:03 Cong Wang
  2016-06-17 21:24 ` Eric Dumazet
  0 siblings, 1 reply; 10+ messages in thread
From: Cong Wang @ 2016-06-17 21:03 UTC (permalink / raw)
  To: Eric Dumazet, Jamal Hadi Salim, David Miller
  Cc: Linux Kernel Network Developers

Hi, Eric

During code review, I notice we might have some problem after we go
lockless for the fast path in act_mirred.

That is, what prevents us from the following possible race condition?

change a standalone action with tcf_mirred_init():
  // search for an existing action in hash
  // found it and got struct tcf_common
  m = to_mirred(a);
  m->tcf_action = parm->action;
  // Interrupted by BH

tcf_mirred() jumps in:
  rcu_read_lock()
  retval = READ_ONCE(m->tcf_action);
  if (m->tcfm_eaction != TCA_EGRESS_MIRROR)
  ....
  rcu_unread_lock()

now go back to tcf_mirred_init():
  m->tcfm_eaction = parm->eaction;
  ....

IOW, the fast path could read a partially written change which could
be a problem? We need to allocate a new copy and then replace the old
one with it via RCU, don't we?

I can work on some patches, I want to make sure I don't miss anything here.

Thanks!

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

end of thread, other threads:[~2016-06-18 16:13 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-17 21:03 act_mirred: remove spinlock in fast path Cong Wang
2016-06-17 21:24 ` Eric Dumazet
2016-06-17 21:35   ` Cong Wang
2016-06-17 21:40     ` Eric Dumazet
2016-06-17 21:59       ` Cong Wang
2016-06-17 22:03         ` Eric Dumazet
2016-06-18 13:45           ` Jamal Hadi Salim
2016-06-18 15:16             ` Eric Dumazet
2016-06-18 15:24               ` Jamal Hadi Salim
2016-06-18 16:13                 ` Eric Dumazet

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