]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit - mm/memory.c
vm: fix mlock() on stack guard page
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 12 Apr 2011 21:15:51 +0000 (14:15 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 12 Apr 2011 21:15:51 +0000 (14:15 -0700)
commit95042f9eb78a8d9a17455e2ef263f2f310ecef15
treeac9fe0a5e17c4b94b18b84338ffbeca2cee140cb
parentbe85bccaa5aa5a11dcaf85f9e945ffefd253f631
vm: fix mlock() on stack guard page

Commit 53a7706d5ed8 ("mlock: do not hold mmap_sem for extended periods
of time") changed mlock() to care about the exact number of pages that
__get_user_pages() had brought it.  Before, it would only care about
errors.

And that doesn't work, because we also handled one page specially in
__mlock_vma_pages_range(), namely the stack guard page.  So when that
case was handled, the number of pages that the function returned was off
by one.  In particular, it could be zero, and then the caller would end
up not making any progress at all.

Rather than try to fix up that off-by-one error for the mlock case
specially, this just moves the logic to handle the stack guard page
into__get_user_pages() itself, thus making all the counts come out
right automatically.

Reported-by: Robert Święcki <robert@swiecki.net>
Cc: Hugh Dickins <hughd@google.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: stable@kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/memory.c
mm/mlock.c