• Tobias Brunner's avatar
    xfrm: Ignore socket policies when rebuilding hash tables · 6916fb3b
    Tobias Brunner authored
    Whenever thresholds are changed the hash tables are rebuilt.  This is
    done by enumerating all policies and hashing and inserting them into
    the right table according to the thresholds and direction.
    
    Because socket policies are also contained in net->xfrm.policy_all but
    no hash tables are defined for their direction (dir + XFRM_POLICY_MAX)
    this causes a NULL or invalid pointer dereference after returning from
    policy_hash_bysel() if the rebuild is done while any socket policies
    are installed.
    
    Since the rebuild after changing thresholds is scheduled this crash
    could even occur if the userland sets thresholds seemingly before
    installing any socket policies.
    
    Fixes: 53c2e285 ("xfrm: Do not hash socket policies")
    Signed-off-by: default avatarTobias Brunner <tobias@strongswan.org>
    Acked-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
    Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
    6916fb3b
xfrm_policy.c 79.8 KB