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 16:33:52 +0300

Herbert Xu wrote:
> On Tue, Mar 30, 2010 at 03:41:02PM +0300, Timo Teräs wrote:
>> So it'd make more sense to nuke the hashes entirely for
>> per-socket policies?
> 
> Absolutely.

I checked now the xfrm_user, and mostly it seems to prevent
modification to per-socket policies.

The only exception is XFRM_MSG_POLEXPIRE handler
xfrm_add_pol_expire(). It calls xfrm_policy_byid() without
verifying the direction, and can thus complete successfully on
a per-socket policy. This can actually result in per-socket
policy deletion via netlink.

I guess the proper thing is to add the direction check there.

It also seems that the by-index hash is also used when
generating new index. It's to double check that the index
is unique. So deleting the by-index hash from per-socket
policies seems tricky.

Removing bydst hashing should be trivial.