Re: bug in generic strncpy_from_user

From: Linus Torvalds
Date: Tue Feb 26 2013 - 11:08:21 EST

On Tue, Feb 26, 2013 at 7:51 AM, Linus Torvalds
<torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
> I think the problem is that we add the guard page *after* we do the
> normal "let's try to expand" logic.
> I'll take a look.

Ahh, no. The guard page logic happens later at the fault time. We do
this in two phases - first "find_extend_vma()" does what the name
claims, and then check_stack_guard_page() is done for the last-page
case from within do_anonymous_page() when we actually touch the last
page itself.

But that's actually fine. We can simply make "find_extend_vma()" do
the obvious "refuse to extend the vma all the way", because we will
later allow the guard page to extend downwards to "touch" the mapping,
but that uses separate logic. So the attached trivial patch seems to
make perfect sense:

It is totally untested, though. Does it work for you (and we should
do the same thing for the grows-up case, obviously)?


Attachment: patch.diff
Description: Binary data