Skip to contentSkip to conversation

Possible BUG on net/ipv4/ipcomp.c, line 358 (fwd)

DISCUSSION Applied Herbert Xu 2 participants 2 messages Nov 7, 2007 1 message not in the archive

Subsystems (4)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Herbert Xu

author maintainer
#1 lore raw
Quoted 11 lines · James Morris

---------- Forwarded message ----------
Date: Tue, 06 Nov 2007 14:53:30 +0100
From: Vicenç <[email protected]>
To: [email protected]
Subject: Possible BUG on net/ipv4/ipcomp.c, line 358

Hi James,

I think there is a bug on net/ipv4/ipcomp.c line 358. The trivial patch that should fix it is:

Thanks for the report! The same bug exists in IPv6 too and this patch should fix both.

[IPSEC]: Fix crypto_alloc_comp error checking

The function crypto_alloc_comp returns an errno instead of NULL to indicate error. So it needs to be tested with IS_ERR.

This is based on a patch by Vicenç Beltran Querol.

Cheers,

Signature · 5 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
net/ipv4/ipcomp.c +2 -1
index ca1b5fd..2c44a94 100644
@@ -16,6 +16,7 @@
 #include <linux/module.h>
 #include <asm/semaphore.h>
 #include <linux/crypto.h>
+#include <linux/err.h>
 #include <linux/pfkeyv2.h>
 #include <linux/percpu.h>
 #include <linux/smp.h>
@@ -344,7 +345,7 @@ static struct crypto_comp **ipcomp_alloc_tfms(const char *alg_name)
 	for_each_possible_cpu(cpu) {
 		struct crypto_comp *tfm = crypto_alloc_comp(alg_name, 0,
 							    CRYPTO_ALG_ASYNC);
-		if (!tfm)
+		if (IS_ERR(tfm))
 			goto error;
 		*per_cpu_ptr(tfms, cpu) = tfm;
 	}
net/ipv6/ipcomp6.c +2 -1
index 85eb479..0cd4056 100644
@@ -36,6 +36,7 @@
 #include <net/ipcomp.h>
 #include <asm/semaphore.h>
 #include <linux/crypto.h>
+#include <linux/err.h>
 #include <linux/pfkeyv2.h>
 #include <linux/random.h>
 #include <linux/percpu.h>
@@ -358,7 +359,7 @@ static struct crypto_comp **ipcomp6_alloc_tfms(const char *alg_name)
 	for_each_possible_cpu(cpu) {
 		struct crypto_comp *tfm = crypto_alloc_comp(alg_name, 0,
 							    CRYPTO_ALG_ASYNC);
-		if (!tfm)
+		if (IS_ERR(tfm))
 			goto error;
 		*per_cpu_ptr(tfms, cpu) = tfm;
 	}
maintainer Applied
#2 lore raw

From: Herbert Xu <[email protected]>
Date: Wed, 7 Nov 2007 09:11:24 +0800

Quoted 8 lines

[IPSEC]: Fix crypto_alloc_comp error checking

The function crypto_alloc_comp returns an errno instead of NULL to indicate error. So it needs to be tested with IS_ERR.

This is based on a patch by Vicenç Beltran Querol.

Applied, and I'll queue this up for -stable too.

Thanks!