patch-2.4.0-test2 linux/fs/proc/base.c

Next file: linux/fs/proc/generic.c
Previous file: linux/fs/partitions/msdos.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.0-test1/linux/fs/proc/base.c linux/fs/proc/base.c
@@ -160,6 +160,24 @@
 		if (len > PAGE_SIZE)
 			len = PAGE_SIZE;
 		res = access_process_vm(task, mm->arg_start, buffer, len, 0);
+		// If the nul at the end of args has been overwritten, then
+		// assume application is using setproctitle(3).
+		if ( res > 0 && buffer[res-1] != '\0' )
+		{
+			len = strnlen( buffer, res );
+			if ( len < res )
+			{
+			    res = len;
+			}
+			else
+			{
+				len = mm->env_end - mm->env_start;
+				if (len > PAGE_SIZE - res)
+					len = PAGE_SIZE - res;
+				res += access_process_vm(task, mm->env_start, buffer+res, len, 0);
+				res = strnlen( buffer, res );
+			}
+		}
 		mmput(mm);
 	}
 	return res;
@@ -285,7 +303,7 @@
 };
 
 #define MAY_PTRACE(p) \
-(p==current||(p->p_pptr==current&&(p->flags&PF_PTRACED)&&p->state==TASK_STOPPED))
+(p==current||(p->p_pptr==current&&(p->ptrace & PT_PTRACED)&&p->state==TASK_STOPPED))
 
 static ssize_t mem_read(struct file * file, char * buf,
 			size_t count, loff_t *ppos)

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)