non-root access to physical memory

Hello,

I use the mmap_device_memory() function to map and use some physical
memory.

It works as long as I log in as root. If I log in as some other user,
the function fails with the error “Operation not permitted”.

I tried mmap (with MAP_PHYS and NOFD) and I get the same behavior.

I then made sure that “/dev/mem” had rw permissions for everyone and
then tried the normal mmap way. This time, it was the open() function
that complained “Operation not permitted”.

  1. Could someone explain whats going on ?

  2. More important, could someone please tell me how I can access
    physical memory without being root ?

Thanks a lot.

-Pavan


Pavan Sikka
CSIRO Manufacturing Science and Technology Telephone: +61 7 3327 4652
Qld Centre for Advanced Technologies Facsimile: +61 7 3327 4455
Technology Court, Pullenvale QLD 4069 Email:
p.sikka@cat.csiro.au
Postal: P O Box 883, Kenmore QLD 4069 Web: www.cat.csiro.au/cmst

Pavan Sikka <p.sikka@cat.csiro.au> wrote in message
news:3A666DE1.99AA9B76@cat.csiro.au

Hello,

I use the mmap_device_memory() function to map and use some physical
memory.

It works as long as I log in as root. If I log in as some other user,
the function fails with the error “Operation not permitted”.

I tried mmap (with MAP_PHYS and NOFD) and I get the same behavior.

I then made sure that “/dev/mem” had rw permissions for everyone and
then tried the normal mmap way. This time, it was the open() function
that complained “Operation not permitted”.

  1. Could someone explain whats going on ?

  2. More important, could someone please tell me how I can access
    physical memory without being root ?

  1. Silly Answer: Just use a variable - it will be in physical memory
    somewhere - you just won’t know where!! 8-0

  2. Unhelpful (but accurate) answer: You cain’t - t’would be a security
    hole!!

  3. Best attempt at a helpful answer: Please tell us (the readers of this
    group) what you are trying to accomplish so we can offer the best solution.
    e.g. If you are trying to control a peripheral device, you need to write (a
    root-enabled) resource manager or equivalent.



Thanks a lot.

-Pavan


Pavan Sikka
CSIRO Manufacturing Science and Technology Telephone: +61 7 3327 4652
Qld Centre for Advanced Technologies Facsimile: +61 7 3327 4455
Technology Court, Pullenvale QLD 4069 Email:
p.sikka@cat.csiro.au
Postal: P O Box 883, Kenmore QLD 4069 Web: > www.cat.csiro.au/cmst

Steve’s answer #3 is the way to go.

Write a progess that runs as root that can access any memory you want. Then
add an API to it from non-root processes. You resource manager will have to
verify/validate that the non-root client has the right to access the memory
that they are trying to access.


Steve Munnings, Corman Technologies <steve@cormantech.com> wrote in message
news:946tih$69$1@inn.qnx.com

  1. Silly Answer: Just use a variable - it will be in physical memory
    somewhere - you just won’t know where!! 8-0

  2. Unhelpful (but accurate) answer: You cain’t - t’would be a security
    hole!!

  3. Best attempt at a helpful answer: Please tell us (the readers of this
    group) what you are trying to accomplish so we can offer the best
    solution.
    e.g. If you are trying to control a peripheral device, you need to write
    (a
    root-enabled) resource manager or equivalent.

Yes, but that would mean some overhead. If he wants to map memory he’s
probably looking for high-performance access. How about setting SUID bit
on the executable so it runs as root even though started by regular
user?

Bill at Sierra Design wrote:

Steve’s answer #3 is the way to go.

Write a progess that runs as root that can access any memory you want. Then
add an API to it from non-root processes. You resource manager will have to
verify/validate that the non-root client has the right to access the memory
that they are trying to access.

Steve Munnings, Corman Technologies <> steve@cormantech.com> > wrote in message
news:946tih$69$> 1@inn.qnx.com> …

  1. Silly Answer: Just use a variable - it will be in physical memory
    somewhere - you just won’t know where!! 8-0

  2. Unhelpful (but accurate) answer: You cain’t - t’would be a security
    hole!!

  3. Best attempt at a helpful answer: Please tell us (the readers of this
    group) what you are trying to accomplish so we can offer the best
    solution.
    e.g. If you are trying to control a peripheral device, you need to write
    (a
    root-enabled) resource manager or equivalent.