diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2018-01-05 22:12:32 +1100 |
---|---|---|
committer | Steffen Klassert <steffen.klassert@secunet.com> | 2018-01-08 07:17:52 +0100 |
commit | bcfd09f7837f5240c30fd2f52ee7293516641faa (patch) | |
tree | a444825e0d2b435030057d0995533c25ca8e4f0b /net/ipv4/esp4.c | |
parent | d16b46e4fd8bc6063624605f25b8c0835bb1fbe3 (diff) | |
download | linux-bcfd09f7837f5240c30fd2f52ee7293516641faa.tar.bz2 |
xfrm: Return error on unknown encap_type in init_state
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: 38320c70d282 ("[IPSEC]: Use crypto_aead and authenc in ESP")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Diffstat (limited to 'net/ipv4/esp4.c')
-rw-r--r-- | net/ipv4/esp4.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c index d57aa64fa7c7..61fe6e4d23fc 100644 --- a/net/ipv4/esp4.c +++ b/net/ipv4/esp4.c @@ -981,6 +981,7 @@ static int esp_init_state(struct xfrm_state *x) switch (encap->encap_type) { default: + err = -EINVAL; goto error; case UDP_ENCAP_ESPINUDP: x->props.header_len += sizeof(struct udphdr); |