From 1cca41e2bda74de8e5192c7833379206280e6617 Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Wed, 29 Oct 2003 18:28:54 -0800 Subject: [PATCH] [IPSEC]: Missing NULL algorithm checks in AH and IPCOMP init. --- net/ipv4/ah4.c | 3 +++ net/ipv4/ipcomp.c | 7 ++++++- net/ipv6/ah6.c | 3 +++ net/ipv6/ipcomp6.c | 7 ++++++- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c index d15c4ce97edac..7f153f28fa40f 100644 --- a/net/ipv4/ah4.c +++ b/net/ipv4/ah4.c @@ -245,6 +245,9 @@ static int ah_init_state(struct xfrm_state *x, void *args) struct ah_data *ahp = NULL; struct xfrm_algo_desc *aalg_desc; + if (!x->aalg) + goto error; + /* null auth can use a zero length key */ if (x->aalg->alg_key_len > 512) goto error; diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c index eb61d3454015e..7ab0b1c81dd23 100644 --- a/net/ipv4/ipcomp.c +++ b/net/ipv4/ipcomp.c @@ -344,10 +344,15 @@ static void ipcomp_destroy(struct xfrm_state *x) static int ipcomp_init_state(struct xfrm_state *x, void *args) { - int err = -ENOMEM; + int err; struct ipcomp_data *ipcd; struct xfrm_algo_desc *calg_desc; + err = -EINVAL; + if (!x->calg) + goto out; + + err = -ENOMEM; ipcd = kmalloc(sizeof(*ipcd), GFP_KERNEL); if (!ipcd) goto error; diff --git a/net/ipv6/ah6.c b/net/ipv6/ah6.c index a97c931c5549f..a52b6c8577c00 100644 --- a/net/ipv6/ah6.c +++ b/net/ipv6/ah6.c @@ -380,6 +380,9 @@ static int ah6_init_state(struct xfrm_state *x, void *args) struct ah_data *ahp = NULL; struct xfrm_algo_desc *aalg_desc; + if (!x->aalg) + goto error; + /* null auth can use a zero length key */ if (x->aalg->alg_key_len > 512) goto error; diff --git a/net/ipv6/ipcomp6.c b/net/ipv6/ipcomp6.c index 58ddfcab5b84d..97db913bf1b33 100644 --- a/net/ipv6/ipcomp6.c +++ b/net/ipv6/ipcomp6.c @@ -276,10 +276,15 @@ static void ipcomp6_destroy(struct xfrm_state *x) static int ipcomp6_init_state(struct xfrm_state *x, void *args) { - int err = -ENOMEM; + int err; struct ipcomp_data *ipcd; struct xfrm_algo_desc *calg_desc; + err = -EINVAL; + if (!x->calg) + goto out; + + err = -ENOMEM; ipcd = kmalloc(sizeof(*ipcd), GFP_KERNEL); if (!ipcd) goto error; -- 2.53.0