LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices

Reply
 
Search this Thread
Old 02-24-2009, 07:46 PM   #1
DannyGilbert
LQ Newbie
 
Registered: Dec 2006
Posts: 3

Rep: Reputation: 0
Smile Kernels refuses to mmap (open FD) on /dev/mem ( CAP_SYS_RAWIO)


Hi everybody !
(sorry if it is not the good forum.. but I think it is a SECURITY issue)

I use Linux kernel 2.6.27 on a embedded system based on ARM 9 Atmel At91sam9260.

I try to access the ARM register (last 4kB memory address in physical space) by opening a FD (file descriptor) on /dev/mem.
It does not work and it seems that the problem is related to the capabilities CAP_SYS_RAWIO. I don't really know how it works but I know it is related to security... I don't need this kind of security. Nobody
has "external access" to my embedded board. I really need to activate some GPIO and modifying some register value of my ARM processor.

Can you tell me how to disable this kind of security in my kernel for my embedded system ?

Or do you have any code snippet or instruction about how to access my ARM register (GPIO and other) ?
 
Old 02-24-2009, 08:35 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,309

Rep: Reputation: 1031Reputation: 1031Reputation: 1031Reputation: 1031Reputation: 1031Reputation: 1031Reputation: 1031Reputation: 1031
Wonder if this also made its way into the ARM tree ...
Check your kernel for CONFIG_STRICT_DEVMEM
 
Old 02-25-2009, 03:59 AM   #3
win32sux
Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
Moved to Kernel for better exposure.
 
Old 02-25-2009, 04:37 AM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,309

Rep: Reputation: 1031Reputation: 1031Reputation: 1031Reputation: 1031Reputation: 1031Reputation: 1031Reputation: 1031Reputation: 1031
I should have mentioned that was merged in 2.6.27
 
Old 02-25-2009, 07:27 AM   #5
DannyGilbert
LQ Newbie
 
Registered: Dec 2006
Posts: 3

Original Poster
Rep: Reputation: 0
I am not sure what you want me to do when you talk about CONFIG_STRICT_DEVMEM. First of all, this CONFIG flag is not inside my .config file of my kernel (2.6.27). So I took a chance to add it like this: CONFIG_STRICT_DEVMEM=y but now I am not sure if we need it or if we need to remove it ... like CONFIG_STRICT_DEVMEM is not set. I saw also that there is a small bug about /dev/mem mmap breakage when PAT is disabled. I saw the small patch (only 3 lines to add in pat.c file). But my problem is before the call to MMAP function.

Remember that the problem is when I try to OPEN the /dev/mem (a character device). If I understand, inside the mem.c file,
the "desired" action over /dev/mem is open_mem (which is a #define that equate open_port) and open_port check if the system
is CAPABLE of CAP_SYS_RAWIO. That's why I think that maybe I can just GIVE the capabilities to CAP_SYS_RAWIO but I don't know
how it works, what to do, etc.

- I DON'T SEE the effect or the link with CONFIG_STRICT_DEVMEM - The only thing I see is the relation between CONFIG_STRICT_DEVMEM and function range_is_allowed() which in turn is related to mmap and read function. OK, maybe I need
to define CONFIG_STRICT_DEVMEM=y for the mmap on /dev/mem but for the OPEN function, I don't know... or I don't understand.

Thanks for your help.

NOTE: Trying to access internal register (like GPIO) of a ARM9 processor, atmel at91sam9260 with LINUX kernel 2.6.27.
 
Old 08-04-2009, 10:30 PM   #6
lingwan
LQ Newbie
 
Registered: Aug 2009
Posts: 1

Rep: Reputation: 0
Ditto

Hi, has anyone figured this out ? Thanks.
 
  


Reply


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
What would happen if I where to cat /dev/mem > /dev/null Joey.Dale Linux - General 11 07-26-2009 12:46 PM
Startx Permission problems on /dev/null and /dev/mem on freshly compiled 2.6.22.1 Eric_Cartman Linux - Kernel 2 09-09-2007 01:42 AM
mmap /dev/mem returns 0 stz Programming 2 11-27-2006 12:11 AM
How to open /dev/mem in kernl code? cyu021 Linux - Software 0 03-31-2005 12:28 PM
BLFS: XFree86; TDFX(0) Cannot open /dev/mem. And some other related questions SparceMatrix Linux From Scratch 1 06-14-2003 02:38 PM


All times are GMT -5. The time now is 09:27 AM.

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