Re: [Linux-ia64] /proc/pid/mem and stack variables

From: Pete Wyckoff <>
Date: 2001-01-13 05:45:10 said:
> I have recompiled the library on IA64 under 2.4.0-test12
> and using version 2.9-ia64-000216-final. The library works
> OK except when the address it tries to access via /proc/pid/mem
> refers to variables allocated on stack (e.g. local arrays defined
> in functions).
> This is a snippet of code used to access memory via /proc/pid/mem:
> void mem_read (int fd, void *buf, void *addr, size_t len) {
> 	if (lseek (fd, (off_t)addr, SEEK_SET) == (off_t)-1)
>                 perror ("lseek");
> 	read (fd, buf, len);
> lseek in this code fails (EINVAL) always when addr is address of
> a variable allocated on stack.

Try removing the "offset >= 0" check in default_llseek in
fs/read_write.c.  Stack pages seem to have the high bit set which
is flummoxing that test.

If you keep this "solution" you may want to write an llseek function
for /proc/pid/mem so that the entire kernel doesn't suffer any unforseen

		-- Pete
Received on Fri Jan 12 10:48:08 2001

This archive was generated by hypermail 2.1.8 : 2005-08-02 09:20:01 EST