From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dmitry Safonov Subject: [RFC 08/20] x86/vdso: Restrict splitting vvar vma Date: Wed, 19 Sep 2018 21:50:25 +0100 Message-ID: <20180919205037.9574-9-dima@arista.com> References: <20180919205037.9574-1-dima@arista.com> Return-path: In-Reply-To: <20180919205037.9574-1-dima@arista.com> Sender: linux-kernel-owner@vger.kernel.org To: linux-kernel@vger.kernel.org Cc: Dmitry Safonov <0x7f454c46@gmail.com>, Dmitry Safonov , Adrian Reber , Andrei Vagin , Andy Lutomirski , Christian Brauner , Cyrill Gorcunov , "Eric W. Biederman" , "H. Peter Anvin" , Ingo Molnar , Jeff Dike , Oleg Nesterov , Pavel Emelyanov , Shuah Khan , Thomas Gleixner , containers@lists.linux-foundation.org, criu@openvz.org, linux-api@vger.kernel.org, x86@kernel.org List-Id: linux-api@vger.kernel.org As offsets differ between time namespaces, we will need to flush vvar mapping for timens page during setns(), unshare(), clone(NEW_TIME). Forcing userspace to mremap() either all vvar or nothing and the same for munmap() will simplify searching for timens page to flush. Signed-off-by: Dmitry Safonov --- arch/x86/entry/vdso/vma.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/arch/x86/entry/vdso/vma.c b/arch/x86/entry/vdso/vma.c index 5b8b556dbb12..8cc0395687b0 100644 --- a/arch/x86/entry/vdso/vma.c +++ b/arch/x86/entry/vdso/vma.c @@ -84,6 +84,18 @@ static int vdso_mremap(const struct vm_special_mapping *sm, return 0; } +static int vvar_mremap(const struct vm_special_mapping *sm, + struct vm_area_struct *new_vma) +{ + unsigned long new_size = new_vma->vm_end - new_vma->vm_start; + const struct vdso_image *image = current->mm->context.vdso_image; + + if (new_size != -image->sym_vvar_start) + return -EINVAL; + + return 0; +} + static int vvar_fault(const struct vm_special_mapping *sm, struct vm_area_struct *vma, struct vm_fault *vmf) { @@ -142,6 +154,7 @@ static const struct vm_special_mapping vdso_mapping = { static const struct vm_special_mapping vvar_mapping = { .name = "[vvar]", .fault = vvar_fault, + .mremap = vvar_mremap, }; /* -- 2.13.6