mm, gup: add missing refcount overflow checks on x86 and s390
authorVlastimil Babka <vbabka@suse.cz>
Fri, 29 Nov 2019 09:03:49 +0000 (10:03 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 5 Dec 2019 14:35:19 +0000 (15:35 +0100)
commit5224c40ed38f1f1e0f5e9b872c5de51a51203034
treeb2fc5f8194743accfcf791f2a1d6c3c5689ab57e
parentfb87c6c5ea2030dac837a97d41dfbd48b8b07c5a
mm, gup: add missing refcount overflow checks on x86 and s390

The mainline commit 8fde12ca79af ("mm: prevent get_user_pages() from
overflowing page refcount") was backported to 4.9.y stable as commit
2ed768cfd895. The backport however missed that in 4.9, there are several
arch-specific gup.c versions with fast gup implementations, so these do not
prevent refcount overflow.

This is partially fixed for x86 in stable-only commit d73af79742e7 ("x86, mm,
gup: prevent get_page() race with munmap in paravirt guest"). This stable-only
commit adds missing parts to x86 version, as well as s390 version, both taken
from the SUSE SLES/openSUSE 4.12-based kernels.

The remaining architectures with own gup.c are sparc, mips, sh. It's unlikely
the known overflow scenario based on FUSE, which needs 140GB of RAM, is a
problem for those architectures, and I don't feel confident enough to patch
them.

Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/s390/mm/gup.c
arch/x86/mm/gup.c