]> git.baikalelectronics.ru Git - kernel.git/commit
xfrm: fix RCU bugs
authorEric Dumazet <edumazet@google.com>
Sun, 19 Aug 2012 10:31:48 +0000 (12:31 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 23 Aug 2012 05:39:46 +0000 (22:39 -0700)
commit27922acdb974a975ef92ab69b0e37b54524af0eb
tree685df5cd6a04c761d3f7d3927185e4c0678c4dbb
parentb3bd97ca39019efe29d30f0973197c9bf8f9e74b
xfrm: fix RCU bugs

This patch reverts commit 950d192b75eb (xfrm: Use rcu_dereference_bh to
deference pointer protected by rcu_read_lock_bh), and fixes bugs
introduced in commit 1b663d368db ( Replace rwlock on xfrm_policy_afinfo
with rcu )

1) We properly use RCU variant in this file, not a mix of RCU/RCU_BH

2) We must defer some writes after the synchronize_rcu() call or a reader
 can crash dereferencing NULL pointer.

3) Now we use the xfrm_policy_afinfo_lock spinlock only from process
context, we no longer need to block BH in xfrm_policy_register_afinfo()
and xfrm_policy_unregister_afinfo()

4) Can use RCU_INIT_POINTER() instead of rcu_assign_pointer() in
xfrm_policy_unregister_afinfo()

5) Remove a forward inline declaration (xfrm_policy_put_afinfo()),
  and also move xfrm_policy_get_afinfo() declaration.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Fan Du <fan.du@windriver.com>
Cc: Priyanka Jain <Priyanka.Jain@freescale.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/xfrm/xfrm_policy.c