From patchwork Mon Jul 6 15:49:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 11646087 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D57CB912 for ; Mon, 6 Jul 2020 15:51:10 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AA51020715 for ; Mon, 6 Jul 2020 15:51:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="qLkc9F0P" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AA51020715 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ubuntu.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=87CCUZYzISqzZ3Xyvqz5j1xZih9ngxFRzVOCxiG8vsU=; b=qLkc9F0PneE1Ur0gK9ifyxfga cf3luHkz21mU9mwq2hQrfxXdHDrhnNculnFAk81AY67L6zD7r2KS1WOqxvqiiVsDdSrnLztgjdRwX IaYrLnendNQcjFH6kaKay3NWTWOKlAHlBYkIxT51suppzxKAzo7NGin8gZI04mtjXxlQh3oYIzlk1 GAPOF6TN5zASqFdkex7FWKQFXpyFmocvvxpc0M3lV7T8a2OoIHCLqlZhIYKsyrFiDxuBH6rp4l/X7 ld04dbjMdjP/3yg+9D7EKreZtjUHW3MCMhcM7pAj4S1X3+QNXsWgsKx/Q5GEkXhg3VIwfeQpJuy32 H62luVBgQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jsTN9-00014b-8T; Mon, 06 Jul 2020 15:49:35 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jsTMy-0000ya-Db for linux-arm-kernel@lists.infradead.org; Mon, 06 Jul 2020 15:49:25 +0000 Received: from ip5f5af08c.dynamic.kabel-deutschland.de ([95.90.240.140] helo=wittgenstein.fritz.box) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jsTMv-0005O9-05; Mon, 06 Jul 2020 15:49:21 +0000 From: Christian Brauner To: linux-kernel@vger.kernel.org Subject: [PATCH v2 2/4] timens: add timens_commit() helper Date: Mon, 6 Jul 2020 17:49:10 +0200 Message-Id: <20200706154912.3248030-3-christian.brauner@ubuntu.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200706154912.3248030-1-christian.brauner@ubuntu.com> References: <20200706154912.3248030-1-christian.brauner@ubuntu.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200706_114924_621547_3F5DB942 X-CRM114-Status: GOOD ( 10.75 ) X-Spam-Score: -1.4 (-) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-1.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [91.189.89.112 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [91.189.89.112 listed in wl.mailspike.net] 3.6 RCVD_IN_SBL_CSS RBL: Received via a relay in Spamhaus SBL-CSS [95.90.240.140 listed in zen.spamhaus.org] 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Dmitry Safonov , Catalin Marinas , x86@kernel.org, Andrei Vagin , Michael Kerrisk , Andy Lutomirski , Thomas Gleixner , Vincenzo Frascino , Will Deacon , Christian Brauner , linux-arm-kernel@lists.infradead.org, Serge Hallyn Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Wrap the calls to timens_set_vvar_page() and vdso_join_timens() in timens_on_fork() and timens_install() in a new timens_commit() helper. We'll use this helper in a follow-up patch in nsproxy too. Signed-off-by: Christian Brauner Reviewed-by: Andrei Vagin Cc: Will Deacon Cc: Vincenzo Frascino Cc: Thomas Gleixner Cc: Catalin Marinas Cc: Mark Rutland Cc: Dmitry Safonov Cc: linux-arm-kernel@lists.infradead.org Link: https://lore.kernel.org/r/20200619153559.724863-3-christian.brauner@ubuntu.com --- kernel/time/namespace.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/kernel/time/namespace.c b/kernel/time/namespace.c index e5af6fe87af8..aa7b90aac2a7 100644 --- a/kernel/time/namespace.c +++ b/kernel/time/namespace.c @@ -280,6 +280,12 @@ static void timens_put(struct ns_common *ns) put_time_ns(to_time_ns(ns)); } +static void timens_commit(struct task_struct *tsk, struct time_namespace *ns) +{ + timens_set_vvar_page(tsk, ns); + vdso_join_timens(tsk, ns); +} + static int timens_install(struct nsset *nsset, struct ns_common *new) { struct nsproxy *nsproxy = nsset->nsproxy; @@ -292,9 +298,8 @@ static int timens_install(struct nsset *nsset, struct ns_common *new) !ns_capable(nsset->cred->user_ns, CAP_SYS_ADMIN)) return -EPERM; - timens_set_vvar_page(current, ns); - vdso_join_timens(current, ns); + timens_commit(current, ns); get_time_ns(ns); put_time_ns(nsproxy->time_ns); @@ -315,14 +320,12 @@ int timens_on_fork(struct nsproxy *nsproxy, struct task_struct *tsk) if (nsproxy->time_ns == nsproxy->time_ns_for_children) return 0; - timens_set_vvar_page(tsk, ns); - - vdso_join_timens(tsk, ns); - get_time_ns(ns); put_time_ns(nsproxy->time_ns); nsproxy->time_ns = ns; + timens_commit(tsk, ns); + return 0; }