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:

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”.

Since access to physical memory is pretty dangerous it is limited
to root access only. But, since many things need root access
you can “chown root /bin/whatever” and “chmod u+s /bin/whatever”
which will cause /bin/whatever to run with root priv’s by any user.

If you are doing development and don’t want to mess around with
loggin in as root to test - consider doing…

cp /usr/bin/op /usr/bin/
chmod u+s /usr/bin/op

and then running “op /bin/whatever” as a user. This is a HUGE
security hole since anyone can now run op and anyone can do
anything as root - but it is handy sometimes.

chris

\

cdm@qnx.com > “The faster I go, the behinder I get.”

Chris McKillop – Lewis Carroll –
Software Engineer, QSSL
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

I am mapping physical memory from a PCI card and I have the same problem.
The 'how to’s that I have read suggested that the problem is with the thread
permissions. I was instructed to do the the following so that the thread
could have permission to access the hardware:

ThreadCtl(_NTO_TCTL_IO,0);

I cannot access memory from our PCI card unless I am logged in as root
though and I don’t know a way around this. If I find a means to do this
without having root access I will post the info to the group.

Chris

Pavan Sikka <p.sikka@cat.csiro.au> wrote in message
news:3A666D7A.BF015685@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 ?

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

Chris Fought <cfought@systran.com> wrote:

I cannot access memory from our PCI card unless I am logged in as root
though and I don’t know a way around this. If I find a means to do this
without having root access I will post the info to the group.

If you find a way to do this, we will take whatever steps are neccessary to
prevent you from being able to do it.

Your application needs to have root permission to access arbitrary areas of
memory or I/O ports. That is by design.