Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp5665317ima; Tue, 5 Feb 2019 16:14:56 -0800 (PST) X-Google-Smtp-Source: AHgI3IYj2rOpOGbycF+ka0uZtgeEk7Udf+2Eep7U80aohSMFEyiWPCez6f9LNJPLPkJ75tgHJgYq X-Received: by 2002:a17:902:e18c:: with SMTP id cd12mr7444251plb.279.1549412096761; Tue, 05 Feb 2019 16:14:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549412096; cv=none; d=google.com; s=arc-20160816; b=evBwpVH3ymV/VliMgBlHfcEHaZdx1B6RDHx6yTPC5cvuf8jwkioId36Rujdv+GAMmG K1/ZHGOrRUHWW/hjg/wsX0ZccQUkVLVqshsAhwPZadpWmhUiMUE2jF5dsYacC+k1Xu0s s83//eji9pmNBcvqRrzq0PVGDmpxzdXFfXURsLmj1ae+uzXX8Vi3URSC9pLSTRxQ299A 9yyNPSoTIwrBVbihErMTUm6lteau+bUD3QJillHyQCsRx6IN6lalZsMsHjB3lvt6cZUy /XfoaEiWB4pTt8PIHBD9dOqDmK/Zg1atxh4D29qeehDBJ5kAejATx8yqAQ99fkOrHniJ nleQ== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=uawMTl34Wy4zvlww/d+EeMEwJUCgahJz96WHztiok1Q=; b=Iui+1cANGTAG07UDAfVIAaXVZlclsdxOnPBjvNJbUoG5WemKTJHoZbW9bYOGuFsSeg VSMxli+hjr1fr3mfhUh3/KcLZpBxrybPAYlB81BEt5rpL83YFj+1oJy3WZNzb/vAWBDW DHx/wrU+QgHwh1b1G4SWIjXjg4IkzYoMIgsAkNo9XcPbSp3lRCpUagqjdLUnqx6vdzXi H0+PiBIRDvRDw6RxOJ94//NFiA4KMsg6+hZTp1KGOGyy/TYkbt655uz+fT9j59G/Pc6J XczWnOM5xfmT/1kIQO8lCxEwM0GPpfMkfcppqsX99+zhNfZnIUk3UJk/VhNB766fnBB7 TNnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arista.com header.s=googlenew header.b=WzfMDcgf; 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=QUARANTINE sp=REJECT dis=NONE) header.from=arista.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q2si2555871plr.204.2019.02.05.16.14.41; Tue, 05 Feb 2019 16:14:56 -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=@arista.com header.s=googlenew header.b=WzfMDcgf; 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=QUARANTINE sp=REJECT dis=NONE) header.from=arista.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727835AbfBFALX (ORCPT + 99 others); Tue, 5 Feb 2019 19:11:23 -0500 Received: from mail-ed1-f68.google.com ([209.85.208.68]:38094 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727207AbfBFALS (ORCPT ); Tue, 5 Feb 2019 19:11:18 -0500 Received: by mail-ed1-f68.google.com with SMTP id h50so4474794ede.5 for ; Tue, 05 Feb 2019 16:11:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=googlenew; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uawMTl34Wy4zvlww/d+EeMEwJUCgahJz96WHztiok1Q=; b=WzfMDcgfwTf10b1zzezHsTiAJSvNWEeGfqj6ThTTBe/ETHZRaRvPt5QkrmbIUxY8Kz tOso8kjTJWA3FdmFG7ImLY6GrPpe4xTkSiH3CxnOPXDKF1OZ4B/mg+hh7YHv7FY4XCI9 QhXp/YG9YTnF6/sK8JOuP927PzEwP153RdAsxWz21yADd5qEDifg7EYdlWXwIO+WnPDT /lNvlYZsrYogLnUaq1yr7AmTfPRBP71KvlIG0jycc1ADeygSmODUm/uoGRM0Yt9Wa3cE eksE1xsTQ2BAx9E0dZF/9ewfKTiiPsVmNfYR6ZI6p6+GQ1WMbXYtw+JVBB+NURxe4FIe QYPg== 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:mime-version:content-transfer-encoding; bh=uawMTl34Wy4zvlww/d+EeMEwJUCgahJz96WHztiok1Q=; b=kwMcW9a9V6sEi91iogyUKsedN78Jpv6LbRdz8CI4H0qTQscDCijLRTDYEtTIj90PGp zC0VwGBFUR2dmMlp4yEzE/7iDuriM4ep6ooxRFiD3YlkYJJO+dFT4kEsaqNYBKYLGB2S 4Xj19BynDcCEOG117mX/Wg/qRj6gTNutWC7aJSpb1xIXipZ/0lox7tSt/euUvi6aTng7 tVbSkEez/zzg9m59bbOUqrft26+kZGmjas3c2DQmrVli/NJ0QpxZcA7aOndzUm6AQPXM c+QB33sSHh2FbFYEaJUbo2ioBzu795lofsa4ADmjTy2wv0n4u80jpl6KBOyGY6/svola w41Q== X-Gm-Message-State: AHQUAubuPEJkXfS0UqmZWLbWNrcJh7DRD3kR1XEjbSBSL2ZHMxI3AMZW +9aY6LVEMBSmJ1alFddKX+xWFlgBEpg= X-Received: by 2002:a05:6402:643:: with SMTP id u3mr5948010edx.276.1549411876142; Tue, 05 Feb 2019 16:11:16 -0800 (PST) Received: from Mindolluin.ire.aristanetworks.com ([217.173.96.166]) by smtp.gmail.com with ESMTPSA id p30sm5489594eda.68.2019.02.05.16.11.14 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 05 Feb 2019 16:11:15 -0800 (PST) From: Dmitry Safonov To: linux-kernel@vger.kernel.org Cc: Andrei Vagin , Dmitry Safonov , Adrian Reber , Andrei Vagin , Andy Lutomirski , Andy Tucker , Arnd Bergmann , Christian Brauner , Cyrill Gorcunov , Dmitry Safonov <0x7f454c46@gmail.com>, "Eric W. Biederman" , "H. Peter Anvin" , Ingo Molnar , Jeff Dike , Oleg Nesterov , Pavel Emelyanov , Shuah Khan , Thomas Gleixner , containers@lists.linux-foundation.org, criu@openvz.org, linux-api@vger.kernel.org, x86@kernel.org Subject: [PATCH 05/32] timerfd/timens: Take into account ns clock offsets Date: Wed, 6 Feb 2019 00:10:39 +0000 Message-Id: <20190206001107.16488-6-dima@arista.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190206001107.16488-1-dima@arista.com> References: <20190206001107.16488-1-dima@arista.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrei Vagin Make timerfd respect timens offsets. Provide two helpers timens_clock_to_host() timens_clock_from_host() that are useful to wire up timens to different kernel subsystems. Following patches will use timens_clock_from_host(), added here for completeness. Signed-off-by: Andrei Vagin Co-developed-by: Dmitry Safonov Signed-off-by: Dmitry Safonov --- fs/timerfd.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/fs/timerfd.c b/fs/timerfd.c index 803ca070d42e..c7ae1e371912 100644 --- a/fs/timerfd.c +++ b/fs/timerfd.c @@ -26,6 +26,7 @@ #include #include #include +#include struct timerfd_ctx { union { @@ -433,22 +434,27 @@ SYSCALL_DEFINE2(timerfd_create, int, clockid, int, flags) } static int do_timerfd_settime(int ufd, int flags, - const struct itimerspec64 *new, + struct itimerspec64 *new, struct itimerspec64 *old) { struct fd f; struct timerfd_ctx *ctx; int ret; - if ((flags & ~TFD_SETTIME_FLAGS) || - !itimerspec64_valid(new)) - return -EINVAL; - ret = timerfd_fget(ufd, &f); if (ret) return ret; ctx = f.file->private_data; + if (flags & TFD_TIMER_ABSTIME) + timens_clock_to_host(ctx->clockid, &new->it_value); + + if ((flags & ~TFD_SETTIME_FLAGS) || + !itimerspec64_valid(new)) { + fdput(f); + return -EINVAL; + } + if (isalarm(ctx) && !capable(CAP_WAKE_ALARM)) { fdput(f); return -EPERM; -- 2.20.1