Patchwork TARPIT: fix memory leak when tarpit_generic() fails

login
register
mail settings
Submitter Josh Hunt
Date Aug. 1, 2012, 10:07 p.m.
Message ID <1343858862-32366-1-git-send-email-johunt@akamai.com>
Download mbox | patch
Permalink /patch/174613/
State Not Applicable
Headers show

Comments

Josh Hunt - Aug. 1, 2012, 10:07 p.m.
Currently tarpit_generic() just returns on failure, but this does
not free nskb.

Signed-off-by: Josh Hunt <johunt@akamai.com>
---
 extensions/xt_TARPIT.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
Jan Engelhardt - Aug. 2, 2012, 3:48 p.m.
On Thursday 2012-08-02 00:07, Josh Hunt wrote:

>Currently tarpit_generic() just returns on failure, but this does
>not free nskb.

Processed.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/extensions/xt_TARPIT.c b/extensions/xt_TARPIT.c
index 58f12e4..0e66279 100644
--- a/extensions/xt_TARPIT.c
+++ b/extensions/xt_TARPIT.c
@@ -237,7 +237,7 @@  static void tarpit_tcp4(struct sk_buff *oldskb, unsigned int hook,
 	((u_int8_t *)tcph)[13] = 0;
 
 	if (!tarpit_generic(tcph, oth, payload, mode))
-		return;
+		goto free_nskb;
 
 	/* Adjust TCP checksum */
 	tcph->check = 0;
@@ -398,7 +398,7 @@  static void tarpit_tcp6(struct sk_buff *oldskb, unsigned int hook,
 
 	payload = nskb->len - sizeof(struct ipv6hdr) - sizeof(struct tcphdr);
 	if (!tarpit_generic(&oth, tcph, payload, mode))
-		return;
+		goto free_nskb;
 
 	ip6h->payload_len = htons(sizeof(struct tcphdr));
 	tcph->check = 0;