Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Security
User Name
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.


  Search this Thread
Old 07-19-2010, 11:14 PM   #1
LQ Newbie
Registered: Jul 2010
Posts: 5

Rep: Reputation: 1
Use /proc/[0-9]*/maps to see what's mapped, what's shared in memory

I just thought up an interesting shell-command phrase, in answer to
"What files are mapped into memory? Do I have
/.evil/.overlord/.control/.program hidden somewhere?":

$ sudo cat /proc/[0-9]*/maps | cut -c82- | sort | uniq -c | sort -n

which tells me which files are mapped into memory by every existing
task, and how many tasks have them mapped. Both the top and bottom of
the list are worth a look - files mapped in to memory only once, and
files mapped into memory lots of times. On my system the outputs ends

512 /lib/
664 /lib/
1927 /dev/dri/card0

I interpret the last number as the number of non-file-mapped memory
segments owned by tasks, that is, memory allocated by mapping /dev/zero
with copy-on-write, then writing.

This won't show files mapped by the kernel (e.g. loaded kernel modules),
and I don't understand /proc/[0-9]*/maps entries that look like this

7ffa46651000-7ffa46653000 r-xp 00000000 00:00 0

or this

7f9d4229a000-7f9d4250a000 rwxp 00000000 00:00 0
7f9d4250a000-7f9d4529a000 rwxp 00000000 00:00 0

Why are these blocks of memory marked Executable? Where did the code
that's executable come from?

Old 07-21-2010, 09:12 AM   #2
harry edwards
Registered: Nov 2007
Location: Lincolnshire, UK
Distribution: CentOS, Fedora, and Suse
Posts: 365

Rep: Reputation: 48
I'm not sure what your commands doing what you say it is. The files mapped into memory can be obtained from the lsof command. Any file with 'mem' in the file-descriptor column is a memory-mapped file. Running the command
lsof /dev/dri/card0
consistently returns a different result from running your command.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] /proc/pid/maps files empty for all processes alexroux Linux - Kernel 6 02-16-2010 10:05 AM
memory mapped i/o and i/o mapped i/o shilpa rangappa General 1 12-14-2009 10:27 PM
Network device Memory mapped or Port mapped ?? Bignon Linux - Hardware 0 10-20-2009 08:36 AM
/proc/pid/maps Moraxus Linux - General 0 02-11-2009 08:49 AM
maps from /proc/pid RHEL 4 sanjaykhuntia Linux - Enterprise 0 10-29-2007 07:39 AM > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 06:00 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration