Ir S
Ir S

Reputation: 495

vm_area_struct - find MAP_ANONYMOUS mapping

How I can detect that area represented by vm_are_struct was mapped as ANONYMOUS? I assume that vm_flags field contains VM_XXX flags but doesn't contain MAP_XX flags. Besides that vm_page_prot field contains something unexpected.

Upvotes: 1

Views: 426

Answers (1)

myaut
myaut

Reputation: 11494

By checking anon_vma pointer (which should be set to non-NULL) and vm_file (which should be NULL, if mapping is related to a file):

if(vma->anon_vma != NULL && vma->vm_file == NULL) {
     // MAP_ANON
}

But anon_vma seem to be lazily allocated (not initialized immediately after mmap() is called).

Upvotes: 1

Related Questions