r4086 - branches/dist/sarge/kernel/source/kernel-source-2.6.8-2.6.8/debian/patches

Simon Horman horms at costa.debian.org
Wed Aug 31 09:51:53 UTC 2005


Author: horms
Date: 2005-08-31 09:51:53 +0000 (Wed, 31 Aug 2005)
New Revision: 4086

Added:
   branches/dist/sarge/kernel/source/kernel-source-2.6.8-2.6.8/debian/patches/fix-memory-leak-in-sg.c-seq_file.dpatch
   branches/dist/sarge/kernel/source/kernel-source-2.6.8-2.6.8/debian/patches/ipv6-skb-leak.dpatch
Log:
Added missing patches

Added: branches/dist/sarge/kernel/source/kernel-source-2.6.8-2.6.8/debian/patches/fix-memory-leak-in-sg.c-seq_file.dpatch
===================================================================
--- branches/dist/sarge/kernel/source/kernel-source-2.6.8-2.6.8/debian/patches/fix-memory-leak-in-sg.c-seq_file.dpatch	2005-08-31 09:16:55 UTC (rev 4085)
+++ branches/dist/sarge/kernel/source/kernel-source-2.6.8-2.6.8/debian/patches/fix-memory-leak-in-sg.c-seq_file.dpatch	2005-08-31 09:51:53 UTC (rev 4086)
@@ -0,0 +1,75 @@
+From linux-kernel-owner+chrisw=40osdl.org-S932372AbVHWUZ3 at vger.kernel.org  Tue Aug 23 13:25:47 2005
+Date: 	Tue, 23 Aug 2005 22:25:14 +0200
+From: Jan Blunck <j.blunck at tu-harburg.de>
+To: Ingo Oeser <ioe-lkml at rameria.de>
+CC: linux-scsi at vger.kernel.org, Andrew Morton <akpm at osdl.org>, linux-kernel at vger.kernel.org
+Subject: [PATCH] sg.c: fix a memory leak in devices seq_file implementation (2nd)
+
+I know that scsi procfs is legacy code but this is a fix for a memory leak.
+
+While reading through sg.c I realized that the implementation of
+/proc/scsi/sg/devices with seq_file is leaking memory due to freeing the
+pointer returned by the next() iterator method. Since next() might
+return NULL or an error this is wrong. This patch fixes it through using
+the seq_files private field for holding the reference to the iterator
+object.
+
+Here is a small bash script to trigger the leak. Use slabtop to watch
+the size-32 usage grow and grow.
+
+#!/bin/sh
+
+while true; do
+	cat /proc/scsi/sg/devices > /dev/null
+done
+
+Signed-off-by: Jan Blunck <j.blunck at tu-harburg.de>
+Signed-off-by: Chris Wright <chrisw at osdl.org>
+---
+ drivers/scsi/sg.c |   15 ++++++++-------
+ 1 files changed, 8 insertions(+), 7 deletions(-)
+
+Index: linux-2.6.12.y/drivers/scsi/sg.c
+===================================================================
+--- linux-2.6.12.y.orig/drivers/scsi/sg.c
++++ linux-2.6.12.y/drivers/scsi/sg.c
+@@ -2969,23 +2969,22 @@ static void * dev_seq_start(struct seq_f
+ {
+ 	struct sg_proc_deviter * it = kmalloc(sizeof(*it), GFP_KERNEL);
+ 
++	s->private = it;
+ 	if (! it)
+ 		return NULL;
++
+ 	if (NULL == sg_dev_arr)
+-		goto err1;
++		return NULL;
+ 	it->index = *pos;
+ 	it->max = sg_last_dev();
+ 	if (it->index >= it->max)
+-		goto err1;
++		return NULL;
+ 	return it;
+-err1:
+-	kfree(it);
+-	return NULL;
+ }
+ 
+ static void * dev_seq_next(struct seq_file *s, void *v, loff_t *pos)
+ {
+-	struct sg_proc_deviter * it = (struct sg_proc_deviter *) v;
++	struct sg_proc_deviter * it = s->private;
+ 
+ 	*pos = ++it->index;
+ 	return (it->index < it->max) ? it : NULL;
+@@ -2993,7 +2992,9 @@ static void * dev_seq_next(struct seq_fi
+ 
+ static void dev_seq_stop(struct seq_file *s, void *v)
+ {
+-	kfree (v);
++	struct sg_proc_deviter * it = s->private;
++
++	kfree (it);
+ }
+ 
+ static int sg_proc_open_dev(struct inode *inode, struct file *file)

Added: branches/dist/sarge/kernel/source/kernel-source-2.6.8-2.6.8/debian/patches/ipv6-skb-leak.dpatch
===================================================================
--- branches/dist/sarge/kernel/source/kernel-source-2.6.8-2.6.8/debian/patches/ipv6-skb-leak.dpatch	2005-08-31 09:16:55 UTC (rev 4085)
+++ branches/dist/sarge/kernel/source/kernel-source-2.6.8-2.6.8/debian/patches/ipv6-skb-leak.dpatch	2005-08-31 09:51:53 UTC (rev 4086)
@@ -0,0 +1,36 @@
+From foo at baz.com Thu Aug 18 12:00:13 2005
+From: Patrick McHardy <kaber at trash.net>
+Date:   Wed Aug 17 12:04:22 2005 -0700
+Subject: [IPV6]: Fix SKB leak in ip6_input_finish()
+
+Changing it to how ip_input handles should fix it.
+
+Signed-off-by: Patrick McHardy <kaber at trash.net>
+Signed-off-by: "David S. Miller" <davem at davemloft.net>
+Signed-off-by: Chris Wright <chrisw at osdl.org>
+---
+ net/ipv6/ip6_input.c |    9 +++++----
+ 1 files changed, 5 insertions(+), 4 deletions(-)
+
+Index: linux-2.6.12.y/net/ipv6/ip6_input.c
+===================================================================
+--- linux-2.6.12.y.orig/net/ipv6/ip6_input.c
++++ linux-2.6.12.y/net/ipv6/ip6_input.c
+@@ -198,12 +198,13 @@ resubmit:
+ 		if (!raw_sk) {
+ 			if (xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) {
+ 				IP6_INC_STATS_BH(IPSTATS_MIB_INUNKNOWNPROTOS);
+-				icmpv6_param_prob(skb, ICMPV6_UNK_NEXTHDR, nhoff);
++				icmpv6_send(skb, ICMPV6_PARAMPROB,
++				            ICMPV6_UNK_NEXTHDR, nhoff,
++				            skb->dev);
+ 			}
+-		} else {
++		} else
+ 			IP6_INC_STATS_BH(IPSTATS_MIB_INDELIVERS);
+-			kfree_skb(skb);
+-		}
++		kfree_skb(skb);
+ 	}
+ 	rcu_read_unlock();
+ 	return 0;




More information about the Kernel-svn-changes mailing list