Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1573855ybb; Thu, 9 Apr 2020 05:02:09 -0700 (PDT) X-Google-Smtp-Source: APiQypKFIEiKofqOs6NWMHn62UKFQrgb8WKOaAQAqZX/TGM8L3BvdN1RFfgrP73f5XuQnLjbOv1T X-Received: by 2002:a37:ac17:: with SMTP id e23mr11827282qkm.123.1586433729034; Thu, 09 Apr 2020 05:02:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586433729; cv=none; d=google.com; s=arc-20160816; b=qUwywX453hqUqAp6xuby4AkPnnGwOIwZvlbxB5LEi2zPxSQn2t1bSWKHcNDDfz99rV CvouVnROe4wJdbFpUPXjzLMeZqzgo6aPa+uLBlc1uHgCG+Cv7cYXoMHmfgvclvg5WfE3 10WjMQts666HXN5BD8UFQANrFyimhvjUzOpX8uVbmAsph1+h/sbE+IlrRrDDMdz/MlK/ PXpnK82yXznXTDggUeIu+0wWMwt6/BJbKvPUoLZspKl0kRYrQdCvl+fwrSl/z23TcttA kTHA967hSnpW8Afg94/mqC330NtfuH0rj9pYAnnEKdkBB3kAr/PdMfVorFUAfzYYs+4r tn3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=rGmIiM/tdKi3AM53PcJ2pcRUEgRHt2gBZH2i8LQKJhI=; b=JBz9V/QMr1KmC0UuuIu3A+2wMg2gySrNEUuS/JxrJ80t/sTsmlTgYiVaJI63FbbloS JeCxQdhBlrmS1DYIvuVslcHjFJusTMWa/ZvaCDyTJxqQNeA3gWweJFe7j+WmZh6VwB9U JTeeJuN0IcCGav9hNGBBnhxWOMPUgAvdIqUrhZ9l39b5rgoFvgf3kcOJZ9j7ZsOT1YC3 smnTw8k6LKthT0dyjDejAaEifNsar0wjX738vXT8rI9qXHhilE5EPANvMFkq5jC/5OQJ Y3ohE7/N2GxH7v62grhMlGfjyYOUcGXMr6rB2oIrqzCbUVjvR5eA+ftA8OaqcIqyjS7t IXLA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d6si5982614qki.93.2020.04.09.05.01.53; Thu, 09 Apr 2020 05:02:09 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726638AbgDIMBI (ORCPT + 99 others); Thu, 9 Apr 2020 08:01:08 -0400 Received: from foss.arm.com ([217.140.110.172]:49274 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726609AbgDIMBI (ORCPT ); Thu, 9 Apr 2020 08:01:08 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C7DCA30E; Thu, 9 Apr 2020 05:01:08 -0700 (PDT) Received: from [192.168.1.172] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BEF923F73D; Thu, 9 Apr 2020 05:01:07 -0700 (PDT) Subject: Re: [PATCH v2 2/6] arm64/vdso: Zap vvar pages when switching to a time namespace To: Andrei Vagin Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Thomas Gleixner , Dmitry Safonov References: <20200225073731.465270-1-avagin@gmail.com> <20200225073731.465270-3-avagin@gmail.com> From: Vincenzo Frascino Message-ID: Date: Thu, 9 Apr 2020 13:01:52 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20200225073731.465270-3-avagin@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/25/20 7:37 AM, Andrei Vagin wrote: > 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 Reviewed-by: Vincenzo Frascino > --- > 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) > { > -- Regards, Vincenzo