[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1539: strace source package does not compile

Package: strace
Version: 3.0-1

I needed to recompile strace so that it didn't use /proc/<pid>/mem to
get the arguments to system calls.  This is because /proc/<pid>/mem is
only available to root on my system, since having it available to
anyone else is a security hole in even the most recent development
kernels.  (See the thread about my /proc paranoia patch on

"Fine", I thought, "I'll just reconfigure it to use some variant of
ptrace to get at the data".  That bit was easy - I just copied the
`old-style SunOS' code, which looked quite plausible and compiled OK.

However, most of the rest of the strace source package is a screaming

It uses #define __KERNEL__ in several places, obviously to get at
constants that probably ought to be in the general namespace.

It uses in its own namespace sys_<foo> for many system calls <foo>,
which clashes with the stuff you get when you say __KERNEL__.

It doesn't appear to be compatible at all with my current kernel,
which is 1.2.13.

Below is a diff of the changes I made to the strace source tree before
giving up.  Note that I'm not sure whether my portability changes were
going in the right direction.  I think my ptrace fix was, though.

Could the strace package maintaner and the program's author please get
together and produce a version that (a) compiles and (b) works on
secure systems.

(It is possible that the procfs will be made secure in a forthcoming
kernel version in a way that doesn't make it - including
/proc/<pid>/mem - a gigantic security hole.  Therefore, it may be a
good idea to have strace try to open /proc/<pid>/mem.  However, since
there is an alternative strategy available it should use it if it
discovers - at run time - that /proc/<pid>/mem doesn't work.)


Only in /usr/local/src/strace-3.0: Makefile
Only in /usr/local/src/strace-3.0: config.h
Only in /usr/local/src/strace-3.0: config.status
Only in /usr/local/src/strace-3.0: desc.o
Only in /usr/local/src/strace-3.0: file.o
Only in /usr/local/src/strace-3.0: io.o
diff -ru /usr/local/src/strace-3.0/ipc.c /u/ian/download/strace-3.0/ipc.c
--- /usr/local/src/strace-3.0/ipc.c	Tue Oct  3 20:20:09 1995
+++ /u/ian/download/strace-3.0/ipc.c	Sat Mar 12 23:11:45 1994
@@ -38,33 +38,10 @@
 #ifdef LINUX

 #define __KERNEL__
-#include <linux/linkage.h>
-#define sys_semop x_sys_semop
-#define sys_semget x_sys_semget
-#define sys_semctl x_sys_semctl
-#define sys_shmget x_sys_shmget
-#define sys_shmctl x_sys_shmctl
-#define sys_shmat x_sys_shmat
-#define sys_shmdt x_sys_shmdt
-#define sys_msgget x_sys_msgget
-#define sys_msgctl x_sys_msgctl
-#define sys_msgsnd x_sys_msgsnd
-#define sys_msgrcv x_sys_msgrcv
 #include <sys/ipc.h>
-#include <sys/msg.h>
 #include <sys/sem.h>
+#include <sys/msg.h>
 #include <sys/shm.h>
-#undef sys_msgget
-#undef sys_msgctl
-#undef sys_msgsnd
-#undef sys_msgrcv
-#undef sys_semop
-#undef sys_semget
-#undef sys_semctl
-#undef sys_shmget
-#undef sys_shmctl
-#undef sys_shmat
-#undef sys_shmdt
 #undef __KERNEL__

 static struct xlat msgctl_flags[] = {
Only in /usr/local/src/strace-3.0: ipc.c~
Only in /usr/local/src/strace-3.0: ipc.o
Only in /usr/local/src/strace-3.0/linux: Makefile
Only in /usr/local/src/strace-3.0/linux: errnoent.h
Only in /usr/local/src/strace-3.0/linux: ioctlent.raw
Only in /usr/local/src/strace-3.0: strace.o
diff -ru /usr/local/src/strace-3.0/syscall.c /u/ian/download/strace-3.0/syscall.c
--- /usr/local/src/strace-3.0/syscall.c	Tue Oct  3 20:07:50 1995
+++ /u/ian/download/strace-3.0/syscall.c	Sat Mar 12 23:11:57 1994
@@ -475,7 +475,6 @@
 				tprintf("= %#x", tcp->u_rval);
 		else if (!(sys_res & RVAL_NONE) && u_error) {
-#ifdef THIS_IS_NOT_IN_LINUX_1_2_13
 #ifdef LINUX
 			switch (u_error) {
@@ -489,7 +488,6 @@
 #endif /* LINUX */
-#endif /* THIS_IS_NOT_IN_LINUX_1_2_13 */
 				tprintf("= -1 ");
 				if (u_error < nerrnos && u_error < sys_nerr)
 					tprintf("%s (%s)", errnoent[u_error],
@@ -502,12 +500,10 @@
 					tprintf("E??? (errno %d)", u_error);
-#ifdef THIS_IS_NOT_IN_LINUX_1_2_13
 #ifdef LINUX
 #endif /* LINUX */
-#endif /* THIS_IS_NOT_IN_LINUX_1_2_13 */
 		else {
 			if (sys_res & RVAL_NONE)
Only in /usr/local/src/strace-3.0: syscall.c~
Only in /usr/local/src/strace-3.0: syscall.o
diff -ru /usr/local/src/strace-3.0/util.c /u/ian/download/strace-3.0/util.c
--- /usr/local/src/strace-3.0/util.c	Tue Oct  3 20:01:04 1995
+++ /u/ian/download/strace-3.0/util.c	Mon Mar 21 05:45:46 1994
@@ -474,30 +474,6 @@

 #ifdef LINUX
-/* This bit of code copied from the SunOS4 oldway version */
-	int pid = tcp->pid;
-	int n, m;
-	union {
-		int val;
-		char x[4];
-	} u;
-	if (addr & 3) {
-		/* addr not a multiple of 4 */
-		n = addr - (addr & -4); /* residue */
-		addr &= -4; /* residue */
-		u.val = ptrace(PTRACE_PEEKDATA, pid, (char *) addr, 0);
-		memcpy(laddr, &u.x[n], m = MIN(4 - n, len));
-		addr += 4, laddr += m, len -= m;
-	}
-	while (len) {
-		u.val = ptrace(PTRACE_PEEKDATA, pid, (char *) addr, 0);
-		memcpy(laddr, u.x, m = MIN(4, len));
-		addr += 4, laddr += m, len -= m;
-	}
 	if (tcp->pfd == -2)
 		return -1;
 	if (tcp->pfd == -1) {
@@ -513,7 +489,6 @@
 	lseek(tcp->pfd, addr, 0);
 	if (read(tcp->pfd, laddr, len) == -1)
 		return -1;
 #endif /* LINUX */

 #ifdef SUNOS4
Only in /usr/local/src/strace-3.0: util.c~
Only in /usr/local/src/strace-3.0: util.o
Only in /usr/local/src/strace-3.0: version.o

Reply to: