Re: heap-stack-gap for 2.6

From: Andrea Arcangeli
Date: Sat Sep 25 2004 - 19:42:13 EST


On Sat, Sep 25, 2004 at 07:57:04PM -0400, Rik van Riel wrote:
> On Sat, 25 Sep 2004, Andrea Arcangeli wrote:
>
> > I didn't check the topdown model, in theory it should be extended to
> > cover that too, this is only working for the legacy model right now
> > because those apps aren't going to use topdown anyways.
>
> Looks like it should just work, topdown shouldn't affect
> expand_stack() or find_vma_prev() ...

expand_stack growsdown page faults are already covered.

but the mmap side of topdown doesn't seem covered instead. Think if an
application maps everything from TASK_UNMAPPED_BASE to the last byte of
heap allowed by topdown. Then userspace unmaps the nearest page to the
stack. Then the stack growsdown of 1 page. Then you mmap again for
a PAGE_SIZE area. You will then fill the gap, and that shouldn't happen,
mmap should fail instead to guarantee a failure notification to
userspace. This is what I meant with topdown not being fully covered.

BTW, I never tried to enforce a gap with MAP_FIXED, that's more a
feature than a bug, I expect people playing MAP_FIXED games, to know
what they're doing, and if they want they can also close the gap. But
they've to do it by hand. If they put a MAP_FIXED near the stack, the
growsdown page faults will then enforce the gap to be sure the stack
doesn't overwrite such MAP_FIXED.

So it's more a stack-growsdown only thing, but the get_unmapped_area
needs collaboration too to really enforce it, and that's the part
missing for topdown. MAP_FIXED is more than a stack-growsdown only thing
and so I still allow that.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/