Linux.com

voidlogic

voidlogic

  • Linux.com Member
  • Posts: 1
  • Member Since: 07 Nov 11
  • Last Logged In: 08 Nov 11

Latest Posts

Posted by
Topic
Post Preview
Posted
  • voidlogic
    Problem: Cannot access some valid ranges in /proc//mem
    Hey Everyone, I am having a problem accessing /proc//mem range after mprotect has made it readable. It almost seems the procfs driver is not aware of the updated permissions. Any ideas or hints would be great! [list=] [*]Process A ptrace ATTACHs to process B [*]Process A cannot access of a given range in process Bs /proc//mem due to the associated mapping in /proc//maps being non-readable [*]Process A requests process B use mprotect to mark given mapping as readable (mprotect returns success) [*]Process A now should be able to read the range in /proc//mem but can only read part of the range... [/list] [b]Example:[/b] Mapping Before Request (Step 3): [code]7f63671af000-7f63673ae000 ---p 0000c000 08:01 269062 /lib/x86_64-linux-gnu/libnss_files-2.13.so[/code] Mapping After Request (Step 3): [code]7f63671af000-7f63673ae000 r--p 0000c000 08:01 269062 /lib/x86_64-linux-gnu/libnss_files-2.13.so[/code] [b]PROBLEM:[/b] std::ifstream can read a first part of the range from /proc//mem, but cannot read the remaining range data. (By cannot read I mean !fin.good and errno = 5) [code]Mapping Range: 7f63671af000-7f63673ae000 (2044 Kbytes) Successfully Read Range: 7f63671af000-7f63671affff (4095 bytes, ~one page) Unsuccessfully Read Range: 7f63671b0000-7f63673ae000 (2040 Kbytes)[/code]
    Link to this post 07 Nov 11

    Hey Everyone,

    I am having a problem accessing /proc/<pid>/mem range after mprotect has made it readable. It almost seems the procfs driver is not aware of the updated permissions. Any ideas or hints would be great!

    1. Process A ptrace ATTACHs to process B

    2. Process A cannot access of a given range in process Bs /proc/<pid>/mem due to the associated mapping in /proc/<pid>/maps being non-readable

    3. Process A requests process B use mprotect to mark given mapping as readable (mprotect returns success)

    4. Process A now should be able to read the range in /proc/<pid>/mem but can only read part of the range...


    Example:
    Mapping Before Request (Step 3):

    7f63671af000-7f63673ae000 ---p 0000c000 08:01 269062     /lib/x86_64-linux-gnu/libnss_files-2.13.so

    Mapping After Request (Step 3):

    7f63671af000-7f63673ae000 r--p 0000c000 08:01 269062     /lib/x86_64-linux-gnu/libnss_files-2.13.so

    PROBLEM: std::ifstream can read a first part of the range from /proc/<pid>/mem, but cannot read the remaining range data. (By cannot read I mean !fin.good and errno = 5)

    Mapping Range:             7f63671af000-7f63673ae000 (2044 Kbytes)
    Successfully Read Range: 7f63671af000-7f63671affff (4095 bytes, ~one page)
    Unsuccessfully Read Range: 7f63671b0000-7f63673ae000 (2040 Kbytes)

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board