2

How could I know if an address is readable or not?

If an address is not readable or not mapped, the kernel usually respond with messages like this BUG: unable to handle kernel paging request at ffffffff80000018.

So, are there any functions to verify if a specific address is readable (or an address range)?

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
daisy
  • 22,498
  • 29
  • 129
  • 265
  • 1
    Accessing any random hardware's memory might blow up the computer. What think are you searching for? – CL. Jul 07 '13 at 16:04

1 Answers1

1

The copy_from_user and related functions get the address from some untrusted user space program; they protect against invalid addresses by installing a special exception handler. (See this answer for details.)

You could do the same, but this would protect only against addresses that the kernel has marked as invalid in the page tables; accesses to some random device's MMIO range might have unpredictable results.

If you want to search for something in some BIOS ROM, remap that memory like any other PCI resource.

If you want to search for something in main memory, you could use some function like ioremap or kmap to get a valid virtual address for a specific physical address.

Community
  • 1
  • 1
CL.
  • 173,858
  • 17
  • 217
  • 259