Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3354828ybv; Mon, 24 Feb 2020 23:39:33 -0800 (PST) X-Google-Smtp-Source: APXvYqw6PMtu0/LX/T5rKOA5lko8rKWohROVJ/WjfR/zryVFc1GIx2Skw3Nwssn0V7CLuBtI79E0 X-Received: by 2002:a05:6830:10d5:: with SMTP id z21mr45161354oto.30.1582616373483; Mon, 24 Feb 2020 23:39:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582616373; cv=none; d=google.com; s=arc-20160816; b=O5pICK7OeWgTzZTuvBf/BRAlDLKdBpTBJzmA9IeinaAGxlO+kF5IaIS4rCaSyFVDZn nupBH9NRiKCBRLDyCxeFwZmE0p//PDApAQzu/MQVL2vwK0TNprAeHm0LE4/rJ8CenGck hOw7cUSXl3ikkQXLOFXTUUZz+QPtjO8oZsQlOTKVmTo33K87yGkC6L+NwPP+bR9294cD 2rIdZ4n5TmccAVPMkJ6NybKrz4s8doSAmjQ1s7bKkp3uWMbQ48qFcOQ7u0KjyvQGNv6i 9VpGjKaSzaAZV5u9+JB9EuZbfQ/vBvc/mH+7KGzbxQoujzpScZ1pInhAUdRHX3yTdY+R B2Sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=AkyLcT/M41H8pNXfB2E+BzqT+C+wAkbHPxgbVN+0zTc=; b=TwSrK60IMoRJi5se96U/7YNZzlh8lhzs3Nz7RzNEfHj1soeArW12D9+u+cyl9pgb6I 4rjeGzINtBWbyTsmmfyg9DvUeY6VU3p8LbAZztdMvEFMoARVEJHmfo6hvA9vcxxM4brK JIEvI6qexizBW9h5S9DGmnVPluz/87CDrMknWL0PPrm3jlzzs0Ystqn29cABMsnZIm02 rWJpkaoXawC/zI1EXnaze0FPwseGmy4hlFYGfFLz+x3VCGRiRRam5L7jwFfWMlDYBqvF ZSYiHETMcoMIym0YrRPZs3IR2+Z48dTGSGqkEpPs6Ff6L8jWvlMbCQQtshJ3CSEjISlr Bz/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hF+L0SkX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i6si8534413otj.24.2020.02.24.23.39.21; Mon, 24 Feb 2020 23:39:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hF+L0SkX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729390AbgBYHho (ORCPT + 99 others); Tue, 25 Feb 2020 02:37:44 -0500 Received: from mail-pj1-f68.google.com ([209.85.216.68]:51562 "EHLO mail-pj1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729317AbgBYHhm (ORCPT ); Tue, 25 Feb 2020 02:37:42 -0500 Received: by mail-pj1-f68.google.com with SMTP id fa20so884936pjb.1 for ; Mon, 24 Feb 2020 23:37:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=AkyLcT/M41H8pNXfB2E+BzqT+C+wAkbHPxgbVN+0zTc=; b=hF+L0SkX3QFj58j9vqoEJ6IjIYswDgAEBWiesoy+sopgxymcU+R/Q2leded9N+UiPA yLatd1d8S25usCpHooLBktyUToJ6eO0zSHRZzBlsSzsunV4XlcRcGT0cIKFD3nSRfKRA hipJWwUyXC+TViT9VcLD5RfONN7yAKMnvq67oknJIIqp85Vjf9rRN00+pt2KGDF2MbX3 4c2AS/WkRmpUJLcqnV5MFTtxJbVPA1SM/u1fgEFN8ngV5GbrP8Ta+3zhKlv449eH4MO6 3Ri631Htals7fy2Oh4T/voA6GGp3QfuJ+uNLmwjxjsuMRgeetUxhrk4ctpQJvmQJOSOo 0cLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AkyLcT/M41H8pNXfB2E+BzqT+C+wAkbHPxgbVN+0zTc=; b=T1lgeE0pu2zB60k8CEdbBur+b8GnI+jNXtw/zIilXi7mm5Pf/fqtyBSjW3/UlmxGQl Gn3QC+JGj99wlGotzvVoZX21oTSoJ3wIGBVm8+VO0+9D1/hRTxoBBqaCJc2MiI8IR7Bg jcU+Rb74FOL/A2d2BWYKF10TUO5WsKrrQyUHj3iWKnkPbYPQAAObyLGN3Lzdl7TincGF 3r7Wq4qUkVB9pbPMOfoRtaqn4HSUI9HIgGaucDIXD4cr6UUhfplPlTJP4tKeKVPUvY06 P6NvyaH5SCfoNSSBo0U+xCExFlIk6qdejfRMONpAJXk5P1cPV3laoPZGgS+n6SmyKgxP 1viQ== X-Gm-Message-State: APjAAAVrIAOQUqgkZjuKExl4Ht1ziu5QYWKMgXZ/o73s/KX10vOb368S 2o5uefzRprNIfX8FcFOvXco= X-Received: by 2002:a17:902:9308:: with SMTP id bc8mr55796788plb.268.1582616262049; Mon, 24 Feb 2020 23:37:42 -0800 (PST) Received: from laptop.hsd1.wa.comcast.net ([2601:600:817f:a132:df3e:521d:99d5:710d]) by smtp.gmail.com with ESMTPSA id m128sm15979390pfm.183.2020.02.24.23.37.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Feb 2020 23:37:41 -0800 (PST) From: Andrei Vagin To: Vincenzo Frascino Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Andrei Vagin , Thomas Gleixner , Dmitry Safonov Subject: [PATCH v2 2/6] arm64/vdso: Zap vvar pages when switching to a time namespace Date: Mon, 24 Feb 2020 23:37:27 -0800 Message-Id: <20200225073731.465270-3-avagin@gmail.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20200225073731.465270-1-avagin@gmail.com> References: <20200225073731.465270-1-avagin@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The VVAR page layout depends on whether a task belongs to the root or non-root time namespace. Whenever a task changes its namespace, the VVAR page tables are cleared and then they will be re-faulted with a corresponding layout. Signed-off-by: Andrei Vagin --- arch/arm64/kernel/vdso.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c index 290c36d74e03..6ac9cdeac5be 100644 --- a/arch/arm64/kernel/vdso.c +++ b/arch/arm64/kernel/vdso.c @@ -131,6 +131,38 @@ static int __vdso_init(enum arch_vdso_type arch_index) return 0; } +#ifdef CONFIG_TIME_NS +/* + * The vvar page layout depends on whether a task belongs to the root or + * non-root time namespace. Whenever a task changes its namespace, the VVAR + * page tables are cleared and then they will re-faulted with a + * corresponding layout. + * See also the comment near timens_setup_vdso_data() for details. + */ +int vdso_join_timens(struct task_struct *task, struct time_namespace *ns) +{ + struct mm_struct *mm = task->mm; + struct vm_area_struct *vma; + + if (down_write_killable(&mm->mmap_sem)) + return -EINTR; + + for (vma = mm->mmap; vma; vma = vma->vm_next) { + unsigned long size = vma->vm_end - vma->vm_start; + + if (vma_is_special_mapping(vma, vdso_lookup[ARM64_VDSO].dm)) + zap_page_range(vma, vma->vm_start, size); +#ifdef CONFIG_COMPAT_VDSO + if (vma_is_special_mapping(vma, vdso_lookup[ARM64_VDSO32].dm)) + zap_page_range(vma, vma->vm_start, size); +#endif + } + + up_write(&mm->mmap_sem); + return 0; +} +#endif + static vm_fault_t vvar_fault(const struct vm_special_mapping *sm, struct vm_area_struct *vma, struct vm_fault *vmf) { -- 2.24.1