check if a kernel page is read-only

Oscar Salvador osalvador.vilardaga at gmail.com
Mon Sep 5 07:46:44 EDT 2016


I think I can do that by getting the related pte of a virtuak kaddr,
starting with

 pgd_offset_k <http://lxr.free-electrons.com/ident?i=pgd_offset_k>(address
<http://lxr.free-electrons.com/ident?i=address>)

, or directly with

pte_t <http://lxr.free-electrons.com/ident?i=pte_t> *lookup_address
<http://lxr.free-electrons.com/ident?i=lookup_address>(unsigned long
address <http://lxr.free-electrons.com/ident?i=address>, unsigned int
*level <http://lxr.free-electrons.com/ident?i=level>);

  And then I can checks the flags of this pte.





2016-09-05 12:59 GMT+02:00 Oscar Salvador <osalvador.vilardaga at gmail.com>:

> Hi all,
>
> I'm writing a module to read/write kernel memory, and for this I'd like to
> check if a page is marked as read-only, so we don't have the right to write
> there (kernel code for instance).
>
> I though about the flags field from "struct page {}", but from the name I
> can't see any useful flag to check this.
>
> The only flag I saw is different between kernel code and module code is
> that kernel code has the flag "reserved" enabled, so it's not swapped.
>
> Could someone provide me a hint about that?
>
> Thank you very much
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20160905/30b7ee5e/attachment.html 


More information about the Kernelnewbies mailing list