Skip to content

Commit

Permalink
NOMMU: Teach kobjsize() about VMA regions.
Browse files Browse the repository at this point in the history
Now that we no longer use compound pages for all large allocations,
kobjsize() actively breaks things like binfmt_flat by always handing
back PAGE_SIZE for mmap'ed regions. Fix this up by looking up the
VMA region for non-compounds.

Ideally binfmt_flat wants to get rid of kobjsize() completely, but
this is an incremental step.

Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Signed-off-by: David Howells <dhowells@redhat.com>
Tested-by: Mike Frysinger <vapier.adi@gmail.com>
  • Loading branch information
pmundt authored and dhowells committed Jan 8, 2009
1 parent 0f3e442 commit ab2e83e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions mm/nommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,20 @@ unsigned int kobjsize(const void *objp)
if (PageSlab(page))
return ksize(objp);

/*
* If it's not a compound page, see if we have a matching VMA
* region. This test is intentionally done in reverse order,
* so if there's no VMA, we still fall through and hand back
* PAGE_SIZE for 0-order pages.
*/
if (!PageCompound(page)) {
struct vm_area_struct *vma;

vma = find_vma(current->mm, (unsigned long)objp);
if (vma)
return vma->vm_end - vma->vm_start;
}

/*
* The ksize() function is only guaranteed to work for pointers
* returned by kmalloc(). So handle arbitrary pointers here.
Expand Down

0 comments on commit ab2e83e

Please sign in to comment.