• F
    xfrm: do unconditional template resolution before pcpu cache check · cf379667
    Florian Westphal 提交于
    Stephen Smalley says:
     Since 4.14-rc1, the selinux-testsuite has been encountering sporadic
     failures during testing of labeled IPSEC. git bisect pointed to
     commit ec30d ("xfrm: add xdst pcpu cache").
     The xdst pcpu cache is only checking that the policies are the same,
     but does not validate that the policy, state, and flow match with respect
     to security context labeling.
     As a result, the wrong SA could be used and the receiver could end up
     performing permission checking and providing SO_PEERSEC or SCM_SECURITY
     values for the wrong security context.
    
    This fix makes it so that we always do the template resolution, and
    then checks that the found states match those in the pcpu bundle.
    
    This has the disadvantage of doing a bit more work (lookup in state hash
    table) if we can reuse the xdst entry (we only avoid xdst alloc/free)
    but we don't add a lot of extra work in case we can't reuse.
    
    xfrm_pol_dead() check is removed, reasoning is that
    xfrm_tmpl_resolve does all needed checks.
    
    Cc: Paul Moore <paul@paul-moore.com>
    Fixes: ec30d78c ("xfrm: add xdst pcpu cache")
    Reported-by: NStephen Smalley <sds@tycho.nsa.gov>
    Tested-by: NStephen Smalley <sds@tycho.nsa.gov>
    Signed-off-by: NFlorian Westphal <fw@strlen.de>
    Acked-by: NPaul Moore <paul@paul-moore.com>
    Signed-off-by: NSteffen Klassert <steffen.klassert@secunet.com>
    cf379667
xfrm_policy.c 77.0 KB