From mboxrd@z Thu Jan 1 00:00:00 1970 From: Cyrill Gorcunov Subject: Re: [PATCH 05/32] timerfd/timens: Take into account ns clock offsets Date: Wed, 6 Feb 2019 11:52:03 +0300 Message-ID: <20190206085203.GB25251@uranus> References: <20190206001107.16488-1-dima@arista.com> <20190206001107.16488-6-dima@arista.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <20190206001107.16488-6-dima@arista.com> Sender: linux-kernel-owner@vger.kernel.org To: Dmitry Safonov Cc: linux-kernel@vger.kernel.org, Andrei Vagin , Adrian Reber , Andrei Vagin , Andy Lutomirski , Andy Tucker , Arnd Bergmann , Christian Brauner , 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 List-Id: linux-api@vger.kernel.org On Wed, Feb 06, 2019 at 12:10:39AM +0000, Dmitry Safonov wrote: > 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; Please don't defer this early test of a @flags value. Otherwise if @flags is invalid you continue fget/put/clock-to-host even if result will be dropped out then.