Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1479691ybg; Tue, 2 Jun 2020 11:05:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwyyRZwDQ/n8t+C0CrfRw1ZjlXfc5lC95oFKQ1c5mE6XfZvtcGI5Ij3vxQKl0BOBXE48d6w X-Received: by 2002:a17:906:6403:: with SMTP id d3mr16578184ejm.386.1591121150197; Tue, 02 Jun 2020 11:05:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591121150; cv=none; d=google.com; s=arc-20160816; b=gjILvrFV5X+cCtuFExA8bkpGbZ7yB0wGzB5rBl4U1H7n2I5gDcveAmBbZ3WGfnvbPf 8VLwBdBfdzovUU1yBXAInzWcHolex2O3FVNAzZek+8MzHkmPrrzkgFFZS6RgfSVbQr93 cHR2hpM3M5HeXojsRUUqYoCiKMlAvbTBAbJKfBsWcX+8w33SGPSmhECeqkBUIFhtiw8G ucCGYPIhHx5Piu5JstJPFwQlCetX0j4HwuXw3tcx45mw6yAdRcCC5xApUHZO3gCVDFMB LrktYu46DhQK6GXq5zW1t6khzae5gIeBvfhc9OW0Wo9LEYQV3zRtnW0FFuGd3swuvq8L u61w== 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=xduVDJsRlgliJcQL58QqcKbDz/BTgkkM9d/dUnD0dlk=; b=i6D/wqAZd4Uv1qbxaFE4NqJ8k+pSwkQHhPWF1b5GQxQt/WIQ16XrH+nSv181bYtHyM koStVFFh6XzREK2ce/f3EGaU+fo70w3BqbKbgct9CeJYQkSeFYfoxuSHbQ868Zk1oEq/ tEu6bCM+hhTQdHl/oBcHNhPTp5D/rCM0q6E4VyXh3Idzqvwmqtllic1ucevaArF93lLa +XO1HtFp5Vf3PuIv1YHLAt+fHy79FQ4raUFliBFii2lsaQDN735mlxQK9ktrIZ3kgO3g 0qHZn771h+RDRgyYwXmamiK6ym/qs9v8LZtUfjNISMM1mWsH9g42LtarmD4ouYtAFXgE lEfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hc9Kjh5K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id w13si1854372ejb.233.2020.06.02.11.05.26; Tue, 02 Jun 2020 11:05:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hc9Kjh5K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1727046AbgFBSDK (ORCPT + 99 others); Tue, 2 Jun 2020 14:03:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726867AbgFBSDH (ORCPT ); Tue, 2 Jun 2020 14:03:07 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CFFFC08C5C0 for ; Tue, 2 Jun 2020 11:03:07 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id h95so1889500pje.4 for ; Tue, 02 Jun 2020 11:03:07 -0700 (PDT) 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=xduVDJsRlgliJcQL58QqcKbDz/BTgkkM9d/dUnD0dlk=; b=hc9Kjh5Ksvxx2g/UwK/Xg+LMKcfr/E0AwwubQnwak+KnY2nYmkOMubnJvCD4cB5PeN QclEVzxQDq0N4VsdQnF/KvRsiMbh31TO+kFea8DLl1YPdOyGXCzdartKJvEsPoiIvAiF 461Pe0ucsyGy+BwIiJBYNg3A1t7bIpiNRonOCq3AWAHULVqjSNA1XI6lpk92ZhKV6YBc 5Ime/Yulu3Ju/sqEgIIa0P+IEB8b8y8uj0L6WIgav9J1H9NgDAJOPyJXOhdyYBIJ41yo R8N2Qc0L7POcZKwzBoIlj48/ItBOA/fcknTSIByEIOZx9Gv/f9K+p0OzrzUI4dVpIwGx p70g== 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=xduVDJsRlgliJcQL58QqcKbDz/BTgkkM9d/dUnD0dlk=; b=S+cYA1or7fTAYR1V8ymK41061UY2XZPJkR/f3l9V1TgCiizWlhfRibO1cBKg6clE6u WpKdDkMSgXY7Y4qrCH6MVFyAeNNmlwQJ6DNmEM0Gw5//sdeLfLwJD5A+uvwB+oKwQd0i aMFgcGvDtIqTGjAZy33LKVty+QlQaI2sKbd8QtdilJf7wNADAEyURm3EYnJWujrhEkjc ADsqh0+97FIpQN+oBaXuJO4STUqnRa9v5pNk9/s1DKGL8mAiNJX+Ksaf+F/YUPPriCSW yKVqdIFDq4EEeeBLY0hMuRHBOyNpb5QaQBlpGtC+WC3Y5PN4VscSpecpsjitJ8k3VsWW tyJQ== X-Gm-Message-State: AOAM530llaNFjxJPQJXZ9bSrUwCRKV+jpftHt9bD51jObkrUjg7DxIuP tcR1CWsxXoF2MdypJDqC4Tg= X-Received: by 2002:a17:90b:4c0f:: with SMTP id na15mr423404pjb.112.1591120986740; Tue, 02 Jun 2020 11:03:06 -0700 (PDT) Received: from laptop.hsd1.wa.comcast.net ([2601:600:817f:a132:df3e:521d:99d5:710d]) by smtp.gmail.com with ESMTPSA id p8sm2740053pgs.29.2020.06.02.11.03.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2020 11:03:06 -0700 (PDT) From: Andrei Vagin To: linux-arm-kernel@lists.infradead.org, Catalin Marinas , Will Deacon Cc: linux-kernel@vger.kernel.org, Vincenzo Frascino , Mark Rutland , Thomas Gleixner , Dmitry Safonov , Andrei Vagin Subject: [PATCH 2/6] arm64/vdso: Zap vvar pages when switching to a time namespace Date: Tue, 2 Jun 2020 11:02:55 -0700 Message-Id: <20200602180259.76361-3-avagin@gmail.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20200602180259.76361-1-avagin@gmail.com> References: <20200602180259.76361-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. Reviewed-by: Vincenzo Frascino 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 031ee1a8d4a8..33df3cdf7982 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