/proc/<pid>/mem unreadable (was strace and linux 1.3.97)

gs@sismosr.com.ar
Tue, 30 Apr 1996 21:50:36 -0300 (ARST)


On Mon, 29 Apr 1996, Aaron Ucko wrote:

> I'm not sure if this problem occurred in older kernels, as I don't use
> strace extremely frequently, but when I tried to run strace version 3.0.8
> (the latest, AFAIK) under Linux 1.3.97, only the strings in the initial
> exec were dereferenced. The only recent changes I've made to my
> predominantly Red Hat 3.0.3 system were kernel upgrades, and I know this
> version of strace worked a few kernel versions ago.

The same happened to me. The problem is that strace accesses the tracee's
memory through /proc/<pid>/mem but as of 1.3.96 any read from processes
different from the one which owns the memory fail with EACCES.
Here is the relevant piece of code from linux/fs/proc/mem.c in function
mem_read:

if (count < 0)
return -EINVAL;
pid = inode->i_ino;
pid >>= 16;
! if (pid != current->pid)
! return -EACCES;
tsk = current;
addr = file->f_pos;
count = check_range(tsk, addr, count);
if (count < 0)
return count;
tmp = buf;

Can anyone out there tell me if there is any reason for this new behavior?

TIA
Guille