]> git.baikalelectronics.ru Git - kernel.git/commit
xfrm: fix race between netns cleanup and state expire notification
authorMichal Kubecek <mkubecek@suse.cz>
Tue, 3 Jun 2014 08:26:06 +0000 (10:26 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 3 Jun 2014 23:07:44 +0000 (16:07 -0700)
commit1949ab2c309d95bb72d358c71012258846291cb8
tree75ebd1123fd7f54e1712e0e3232c859548781e95
parent3476a758aab981fb887c728b79796422bdd67e7c
xfrm: fix race between netns cleanup and state expire notification

The xfrm_user module registers its pernet init/exit after xfrm
itself so that its net exit function xfrm_user_net_exit() is
executed before xfrm_net_exit() which calls xfrm_state_fini() to
cleanup the SA's (xfrm states). This opens a window between
zeroing net->xfrm.nlsk pointer and deleting all xfrm_state
instances which may access it (via the timer). If an xfrm state
expires in this window, xfrm_exp_state_notify() will pass null
pointer as socket to nlmsg_multicast().

As the notifications are called inside rcu_read_lock() block, it
is sufficient to retrieve the nlsk socket with rcu_dereference()
and check the it for null.

Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/xfrm/xfrm_user.c