Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp917407ybz; Wed, 15 Apr 2020 22:28:51 -0700 (PDT) X-Google-Smtp-Source: APiQypLhbXS6DbPiAWk96iKr/gre0KuWZ1HXfyjeBEsTb/x8vWC66pBhnsk12zsj4S7MHJ6ymcoT X-Received: by 2002:a05:6402:543:: with SMTP id i3mr11580482edx.255.1587014930926; Wed, 15 Apr 2020 22:28:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587014930; cv=none; d=google.com; s=arc-20160816; b=p+fF1zzw4Zf4kAS7yVO62qhzs8d55k2XDYvVs04KrPEgUJ0dSxk25ZQJZPMl977ddb zuzFyEOJ1Bn0rsbMq2SKLKgJZmfrwMK7wEwOBSZXIqR2Q0/WRq4+FMXR8DScH19aKrib kyekU//AsWZ/Apu1GhtCGqz+kV9+PhxPVBG2ZFaERMwI20Pc1rrRpcDsnMtAtIYekIGh Wd7zxSmDnmqq31bhQUOw42xofCaPBn6QCkKAEGWgdvoUAk7OqsGf2NqfY2FT64y4757W ilfSIjUVABhgCgJnW71D1vy9dpVQ8ybAPSAJAOR2xTdaUAezh+tekG6x+WD3tLBB3NCF e2mQ== 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=Qrvi9cfOMWugmztCzSRhVUwuOgDWuroc1zUU7Jui6fE=; b=X7qx4Nz6KkDMTUmLF7Glxk4HL0tiq9ZgModF/qwxWT90WQzaZtIcBLlAp8lf9Hx/3w NEPrBKFTTMHbjncppNBAS3VhgiuY0Wj/oUtRReBBVL6JS5JTUDyC/W9EgNheIE3U3R+a oeGPX+mCM+GQovYFLu4QYQ9yAIoV8yDQwDRQJWJMGs/O32uzjq2jGz7he2zny5RvpJlr T6qs+bSBDdFOcUk6xE2BWwvoEs4YGp6ynj+RWl0HxrtHXsqa+5OdzdVi8r1if98Gbawh 7LH6xiddCHsIMQuZA3SUFSgZj9PpA7Dn4a7XTLg8CHP+EQWHDiOLbHhmGq4JTPp2tDTF hm/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nEFR40jz; 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 i13si11530498ejj.252.2020.04.15.22.28.27; Wed, 15 Apr 2020 22:28: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=nEFR40jz; 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 S2406626AbgDPF1L (ORCPT + 99 others); Thu, 16 Apr 2020 01:27:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S2406481AbgDPF0p (ORCPT ); Thu, 16 Apr 2020 01:26:45 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DB62C061A10 for ; Wed, 15 Apr 2020 22:26:45 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id t16so946394plo.7 for ; Wed, 15 Apr 2020 22:26:45 -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=Qrvi9cfOMWugmztCzSRhVUwuOgDWuroc1zUU7Jui6fE=; b=nEFR40jzawzbAo86Fn7AlbI47j6RcYuIHU57HJodL+mJEh/+ODMMd0houcnmMRTDQm CmNFos10maNtWktoQ/xvzPG0knqvXQR5Lj9P5NaI9lto16D140T3cud32vm4qRGYF7aN bEkIpF0d16foHYOPyDCbUIK3CCmetinOblwsamt90Rqtvta2GkhCPmXmU5J1HVybRdOS kYRb/4ivlnxk16x/UPxjYKNWtKjCOjYObTVuJbBg5kpbuaOmNH2E4JA4HXkXE7nemtEG BOZsq2UU0iOk8vh8GdP0OUNqkZjolusbFMks/2NAmsEHRaHca+9q2Ya9SzKX/Xd+A5FO fBLQ== 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=Qrvi9cfOMWugmztCzSRhVUwuOgDWuroc1zUU7Jui6fE=; b=M8q8C7eq5SBck6uuOI3PjcVIoBsEP1ptnyw2THL7dWdpMA2tX7UWJDRFh2fAoxfUv7 2kdul6Td2Zo+BsH/LOUFPGaViVTFZJvTLHjsVAMEZFkF4R4ik5EQFBLjJvWLUgjdlkIo +S19gdVoAxLGkKfA3GM8mA46R0HuGjtArAZaSXj+qfTWWnMwQQ9qfGoE+rKzfvjOwpez eF+hOAJpq86cMddsahIuWwWwkALih6Wyc7koQhHs6bNVaAVJiAlAVbQVXmdm0T+v5Sa0 moRVvOebg0aq2lANjf/8tthWkk3OX/F6BCfFJ4YzaCYWj7jUFSSNRgGdaN/A9nEtr+s7 cdwQ== X-Gm-Message-State: AGi0Pub4uvCAc3FU0j5g5COFe5LtimPbTMxpb9goZ7AMB1cI9b9lpcvn 3+C0ESArgutO7z6kbbbI348= X-Received: by 2002:a17:90a:3726:: with SMTP id u35mr3113764pjb.162.1587014804922; Wed, 15 Apr 2020 22:26:44 -0700 (PDT) Received: from laptop.hsd1.wa.comcast.net ([2601:600:817f:a132:df3e:521d:99d5:710d]) by smtp.gmail.com with ESMTPSA id c21sm53699pjr.2.2020.04.15.22.26.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Apr 2020 22:26:44 -0700 (PDT) From: Andrei Vagin To: Vincenzo Frascino , Catalin Marinas , Will Deacon Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Mark Rutland , Thomas Gleixner , Andrei Vagin , Dmitry Safonov Subject: [PATCH 2/6] arm64/vdso: Zap vvar pages when switching to a time namespace Date: Wed, 15 Apr 2020 22:26:14 -0700 Message-Id: <20200416052618.804515-3-avagin@gmail.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20200416052618.804515-1-avagin@gmail.com> References: <20200416052618.804515-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 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