• Herbert Xu's avatar
    xfrm: Return error on unknown encap_type in init_state · bcfd09f7
    Herbert Xu authored
    Currently esp will happily create an xfrm state with an unknown
    encap type for IPv4, without setting the necessary state parameters.
    This patch fixes it by returning -EINVAL.
    
    There is a similar problem in IPv6 where if the mode is unknown
    we will skip initialisation while returning zero.  However, this
    is harmless as the mode has already been checked further up the
    stack.  This patch removes this anomaly by aligning the IPv6
    behaviour with IPv4 and treating unknown modes (which cannot
    actually happen) as transport mode.
    
    Fixes: 38320c70 ("[IPSEC]: Use crypto_aead and authenc in ESP")
    Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
    Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
    bcfd09f7
esp6.c 21.7 KB