Re: Crazy things you didn't know about OpenSSI

John Hughes <[email protected]>
Newsgroups gmane.linux.cluster.ssic.devel
Message-ID <[email protected]>
John Hughes wrote:
> Did you know that the kernel migrates processes by writing to 
> /proc/pid/goto?!#
>
> (I.E. proc_migrate calls do_ssi_write, and not the other way round!)
>
> (This may be a problem 'cos do_ssi_write has a silly 256 byte buffer on 
> the stack to read the stuff written from user space).
>
> (Also it's crazy - to migrate a process the kernel has to snprintf the 
> nodenum, so do_ssi_write can sscanf it!)
>   
Not a fix to the ugliness, but at least reduces stack usage in do_ssi_write

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword

_______________________________________________
ssic-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ssic-linux-devel
ci-fs-proc-base-c.patch (text/x-patch, 1.7 KB)
Index: kernel/fs/proc/base.c
===================================================================
RCS file: /usr/local/lib/cvs-repo/sourceforge-openssi/kernel/fs/proc/base.c,v
retrieving revision 1.23.2.4
retrieving revision 1.23.2.4.2.1
diff -u -r1.23.2.4 -r1.23.2.4.2.1
--- kernel/fs/proc/base.c	17 Nov 2008 09:21:53 -0000	1.23.2.4
+++ kernel/fs/proc/base.c	16 Jan 2009 10:09:57 -0000	1.23.2.4.2.1
@@ -2983,24 +2983,28 @@
 ssize_t do_ssi_write(struct task_struct *task, char * buf,
 			size_t count, loff_t *ppos, int type)
 {
-	char data[256];
+	char data[32];	/* should be small; if need big then get free page */
+	char *end;
 	long nodenum = 0;
 	int action;
 	int len;
 	int result = -EINVAL;
 	struct pvproc *pvp;
 
-	if (count >= sizeof(data))
-		return -EFAULT;
+	if (count >= sizeof data)
+		count = sizeof data - 1;
 	if (copy_from_user(data, buf, count))
 		return -EFAULT;
-	if (data[count - 1] == '\n')
+	if (count && data[count - 1] == '\n')
 		data[count - 1] = '\0';
 	else
 		data[count] = '\0';
 	switch (type) {
 		case PROC_TGID_GOTO:
-			nodenum = simple_strtol(data, NULL, 10);
+			nodenum = simple_strtol(data, &end, 10);
+
+			if (end == data)
+				return -EIO;
 
 			if (!nodenum)
 				return count;
@@ -3029,7 +3033,11 @@
 			return count;
 		case PROC_TGID_LOADLEVEL:
 
-			action = simple_strtoul(data, NULL, 10);
+			action = simple_strtoul(data, &end, 10);
+
+			if (end == data)
+				return -EIO;
+
 			if (action < 0 ||  action > 1)
 				return -EINVAL;
 
@@ -3043,7 +3051,9 @@
 
 			return count;
 		case PROC_TGID_PIN:
-			action = simple_strtoul(data, NULL, 10);
+			action = simple_strtoul(data, &end, 10);
+			if (end == data)
+				return -EIO;
 			if (action < 0 ||  action > 1)
 				return -EINVAL;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.