Subject: Re: [PATCH 1/7] xfrm: remove policy lock when accessing policy->walk.dead

From: Timo Teräs <[email-masked]>
Date: Tue, 30 Mar 2010 18:36:37 +0300

Herbert Xu wrote:
> On Tue, Mar 30, 2010 at 05:01:47PM +0300, Timo Teräs wrote:
>> Since the exported function xfrm_policy_byid() can result in deletion
>> of socket policy, it's safer to leave this change in. This is can be
>> even triggered via xfrm_user since it does not check 'dir' for the
>> policy expired message it handles. Any custom module could do similar
>> harm.
> 
> That's a bug.  Socket policies should never be deleted by anyone
> other than the socket owner through a setsockopt.

Ok. I can remove the change to xfrm_sk_policy_insert() if you want.

I only added it because it's non-trivial to figure out if there's
any code path that could race. It's a great help for reader of the
code to see that it's correct even if it's not strictly needed.
My initial feeling is that the change produces better code as the
original 'old_pol' does not have to get stored and restored.

I'm fine either way.

I will also include a patch to fix the missing 'dir' check in
xfrm_user.