Skip to contentSkip to conversation

top stack (l)users for 2.5.67

DISCUSSION Randy.Dunlap 1 participant 1 message Apr 15, 2003

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi,

I'm reposting these 2 patches in case anyone is interested in them.

~Randy

Begin forwarded message:

Date: Mon, 14 Apr 2003 13:26:12 -0700
From: "Randy.Dunlap" <[email protected]>
To: Jörn Engel <[email protected]>
Subject: Re: top stack (l)users for 2.5.67

On Mon, 14 Apr 2003 21:44:42 +0200 Jörn Engel <[email protected]> wrote:

| On Mon, 14 April 2003 12:38:10 -0700, Randy.Dunlap wrote:
| > On Mon, 14 Apr 2003 19:30:47 +0200 Jörn Engel <[email protected]> wrote:
| > 
| > 
| > | 0xc05e2733 ida_ioctl:                                    sub    $0x54c,%esp
| > 
| > patch posted 2003.APR.03 (on lkml); Steve Cameron saw it...
| > 
| > | 0xc0fb00e3 device_new_if:                                sub    $0x520,%esp
| > 
| > patch posted 2003.APR.03 (on linux-net);
| > no reply from Nenad Corbic ([email protected])
| 
| Hm, all these stack reduction patches are relevant to -je as well.
| Could I have a copy of those two?

patch_name: wan-stack.patch
patch_version: 2003-04-02.20:59:49
author: Randy.Dunlap <[email protected]>
description: reduce stack in net/wanrouter/wanmain.c::device_new_if()

		from 0x520 to 0x24;

product: Linux
product_versions: 2.5.66
changelog: allocate and free the <wanif_conf_t> data;
maintainer: Gideon Hack (no email address listed)
diffstat: =

 net/wanrouter/wanmain.c |   52 +++++++++++++++++++++++++++++++-----------------
 1 files changed, 34 insertions(+), 18 deletions(-)
net/wanrouter/wanmain.c renamed from net/wanrouter/wanmain.c%WANSTK +34 -18
diff -Naur ./net/wanrouter/wanmain.c%WANSTK ./net/wanrouter/wanmain.c
@@ -660,7 +660,7 @@
 
 static int device_new_if (wan_device_t *wandev, wanif_conf_t *u_conf)
 {
-	wanif_conf_t conf;
+	wanif_conf_t *cnf;
 	netdevice_t *dev=NULL;
 #ifdef CONFIG_WANPIPE_MULTPPP
 	struct ppp_device *pppdev=NULL;
@@ -670,37 +670,51 @@
 	if ((wandev->state == WAN_UNCONFIGURED) || (wandev->new_if == NULL))
 		return -ENODEV;
 
-	if (copy_from_user(&conf, u_conf, sizeof(wanif_conf_t)))
-		return -EFAULT;
+	cnf = kmalloc(sizeof(wanif_conf_t), GFP_KERNEL);
+	if (!cnf)
+		return -ENOBUFS;
+
+	if (copy_from_user(cnf, u_conf, sizeof(wanif_conf_t))) {
+		err = -EFAULT;
+		goto conffree;
+	}
 
-	if (conf.magic != ROUTER_MAGIC)
-		return -EINVAL;
+	if (cnf->magic != ROUTER_MAGIC) {
+		err = -EINVAL;
+		goto conffree;
+	}
 
-	if (conf.config_id == WANCONFIG_MPPP) {
+	if (cnf->config_id == WANCONFIG_MPPP) {
 #ifdef CONFIG_WANPIPE_MULTPPP
 		pppdev = kmalloc(sizeof(struct ppp_device), GFP_KERNEL);
-		if (pppdev == NULL)
-			return -ENOBUFS;
+		if (pppdev == NULL) {
+			err = -ENOBUFS;
+			goto conffree;
+		}
 		memset(pppdev, 0, sizeof(struct ppp_device));
 		pppdev->dev = kmalloc(sizeof(netdevice_t), GFP_KERNEL);
 		if (pppdev->dev == NULL) {
 			kfree(pppdev);
-			return -ENOBUFS;
+			err = -ENOBUFS;
+			goto conffree;
 		}
 		memset(pppdev->dev, 0, sizeof(netdevice_t));
-		err = wandev->new_if(wandev, (netdevice_t *)pppdev, &conf);
+		err = wandev->new_if(wandev, (netdevice_t *)pppdev, cnf);
 		dev = pppdev->dev;
 #else
 		printk(KERN_INFO "%s: Wanpipe Mulit-Port PPP support has not been compiled in!\n",
 				wandev->name);
-		return -EPROTONOSUPPORT;
+		err = -EPROTONOSUPPORT;
+		goto conffree;
 #endif
 	} else {
 		dev = kmalloc(sizeof(netdevice_t), GFP_KERNEL);
-		if (dev == NULL)
-			return -ENOBUFS;
+		if (dev == NULL) {
+			err = -ENOBUFS;
+			goto conffree;
+		}
 		memset(dev, 0, sizeof(netdevice_t));
-		err = wandev->new_if(wandev, dev, &conf);
+		err = wandev->new_if(wandev, dev, cnf);
 	}
 
 	if (!err) {
@@ -739,7 +753,8 @@
 				++wandev->ndev;
 
 				unlock_adapter_irq(&wandev->lock, &smp_flags);
-				return 0;	/* done !!! */
+				err = 0;	/* done !!! */
+				goto conffree;
 			}
 		}
 		if (wandev->del_if)
@@ -752,18 +767,19 @@
 		dev->priv = NULL;
 	}
 
-
 #ifdef CONFIG_WANPIPE_MULTPPP
-	if (conf.config_id == WANCONFIG_MPPP)
+	if (cnf->config_id == WANCONFIG_MPPP)
 		kfree(pppdev);
 	else
 		kfree(dev);
 #else
 	/* Sync PPP is disabled */
-	if (conf.config_id != WANCONFIG_MPPP)
+	if (cnf->config_id != WANCONFIG_MPPP)
 		kfree(dev);
 #endif
 
+ conffree:
+	kfree(cnf);
 	return err;
 }
 

patch_name: cpqarray-stack.patch
patch_version: 2003-04-02.21:10:01
author: Randy.Dunlap <[email protected]>
description: reduce stack in block/cqparray.c::ida_ioctl()

		from 0x550 to 0x48;

product: Linux
product_versions: linux-2566
changelog: allocate and free <ida_ioctl_t>
maintainer: Steve Cameron: [email protected], [email protected]
diffstat: =

 drivers/block/cpqarray.c |   20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)
drivers/block/cpqarray.c renamed from drivers/block/cpqarray.c%IDAIOC +14 -6
diff -Naur ./drivers/block/cpqarray.c%IDAIOC ./drivers/block/cpqarray.c
@@ -1021,7 +1021,7 @@
 	int diskinfo[4];
 	struct hd_geometry *geo = (struct hd_geometry *)arg;
 	ida_ioctl_t *io = (ida_ioctl_t*)arg;
-	ida_ioctl_t my_io;
+	ida_ioctl_t *my_io;
 
 	switch(cmd) {
 	case HDIO_GETGEO:
@@ -1046,11 +1046,19 @@
 		return 0;
 	case IDAPASSTHRU:
 		if (!capable(CAP_SYS_RAWIO)) return -EPERM;
-		if (copy_from_user(&my_io, io, sizeof(my_io)))
-			return -EFAULT;
-		error = ida_ctlr_ioctl(ctlr, dsk, &my_io);
-		if (error) return error;
-		return copy_to_user(io, &my_io, sizeof(my_io)) ? -EFAULT : 0;
+		my_io = kmalloc(sizeof(ida_ioctl_t), GFP_KERNEL);
+		if (!my_io)
+			return -ENOMEM;
+		if (copy_from_user(my_io, io, sizeof(*my_io))) {
+			error = -EFAULT;
+			goto iocfree;
+		}
+		error = ida_ctlr_ioctl(ctlr, dsk, my_io);
+		if (error) goto iocfree;
+		error = copy_to_user(io, my_io, sizeof(*my_io)) ? -EFAULT : 0;
+  iocfree:
+		kfree(my_io);
+		return error;
 	case IDAGETCTLRSIG:
 		if (!arg) return -EINVAL;
 		put_user(hba[ctlr]->ctlr_sig, (int*)arg);