Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932171AbbFDPE7 (ORCPT ); Thu, 4 Jun 2015 11:04:59 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:59923 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932119AbbFDPE5 (ORCPT ); Thu, 4 Jun 2015 11:04:57 -0400 From: Arnd Bergmann To: y2038@lists.linaro.org Cc: Thomas Gleixner , Baolin Wang , linux-kernel@vger.kernel.org Subject: Re: [Y2038] [PATCH v4 06/25] time/posix-timers:Introduce {get, put}_timespec and {get, put}_itimerspec Date: Thu, 04 Jun 2015 17:04:53 +0200 Message-ID: <13035006.xRdC2jB7D9@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) In-Reply-To: References: <1433159708-4780-1-git-send-email-baolin.wang@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:w+SApElrW0TTwCHvNGOdWzwRCSZ1TMuv4v+hQUY04bCuu5y3noZ cSOelai/3QrU+ia4byLC7jJaAHmV5OEIP1fHdUABAdTymy7ybN2yQBWwFxmTA8GRC66+fQ/ 5v7Ixb2Lv57VybDx4topb4EEo+y8JFaudZtdX5rtXBYyaqgccP8CKZ4qVZd166+QF5fg+q2 kywEZmMMizLrBSPsMEzrQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:iZjmsx2ttbc=:jo2rPmP49mJLMpRT3z9dJY GT7JJAUNIqZvKqCr4pV3b8IPR0BgAbmRFTUY9Cfl5jSAGDVRNmjHck/+OWOi5wPRsIif1W/Wh 5/dL+iFmhKj+6RlCbIA6xU2xv5nB4EmgnDk1T/H3yMbYYG1z8OQsb3oQ/O1iSXAOAo7/yI5lZ ngfq1BWs8WCpVUITwDFuWMRuXaUf46uAfojwME67RZuUeBFN16cSg1KNbC2ZZV1ukKQga22H1 88OuoPdE96TG1JmSuYLfsc1fNMEvsjDug/sNuO5LEuU/hgeo1rBqEAxMi+Ykx/f+wjg5TIXhd ley2DpoUiF0sQBNdvAHMCvXIQE9st9vJCruZ0+nmlLdax7BrCIT0YtNktecl2ClDv1/z6FTFY sLkchUB4KL2M1Ht5WiBsxdn0ulgKznqThf+8haFzv97YlDUCBexOPyquB0y4DvWLO9E3gn9pR Rd/WVAkm9JQLv8poYLTRMde52TILLYaiXGbSl5vbPxr9bSk5aYdMks7fZRULQ+jeyH5FpTiZZ XHzq+52+/hlX98W84VVaF7Cm8ARD4njhZEiCEqQZSrOJynHHs1WqI2OSJlEloRJGcqz35vEUW dxaZiAFHga7jvyV7JqP8fXvnkr/zHl4nK/yNBAaiv26BISF5CidxF96KbJXosqWWUNhZxamxN mkuiAN0LIyNOKfwNIHHrsOQZiXFmkchnKEyR7qViOysX21A== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3158 Lines: 81 On Tuesday 02 June 2015 21:20:08 Thomas Gleixner wrote: > On Mon, 1 Jun 2015, Baolin Wang wrote: > > > These are new helper functions that convert between a user timespec/ > > itimerspec and a kernel timespec64/itimerspec64 structure. > > These are not functions, these are macros. > > > These macros can change the types underneath from both ends and it > > will work efficiently on both 32-bit and 64-bit that can avoid the > > CONFIG_64BIT macro in syscall functions, and also it can make the > > syscall functions more simple. > > Lots of useless blurb which fails to explain WHY this works and WHY > this magically converts the types. > > And you fail to mention WHY dropping type safety is a good choice and > WHY dropping the might_fault() check is a proper thing to do. > > I also doubt the efficiency part as you replace a linear > copy_to_user() with four seperate ones for an itimerspec. > > This can be done proper with typesafe inline helpers, if you want to > spare the ifdef in the syscall implementation. > I suggested these macros on IRC, as a way to help coordinate Baolin's series with my own patches that conver the entry points at first to use __kernel_timespec equal to the normal timespec, and then changing that type to be based on __kernel_time64_t. Specifically, we otherwise need to deal with these combinations: user timespec (32 bit), kernel timespec (32 bit) user timespec (64 bit), kernel timespec (64 bit) user timespec (32 bit), kernel timespec64 (64 bit) user timespec (64 bit), kernel timespec64 (64 bit) user __kernel_timespec (32 bit), kernel timespec (32 bit) user __kernel_timespec (64 bit), kernel timespec (32 bit) user __kernel_timespec (64 bit), kernel timespec (64 bit) user __kernel_timespec (32 bit), kernel timespec64 (64 bit) user __kernel_timespec (64 bit), kernel timespec64 (64 bit) My existing patche series handles this with fully type-safe functions, but causes more churn than using less safe functions, which can handle all the combinations above. We could also do untyped get/put functions based on copy_to_user and copy_from_user, but I guess what you're after is more along the lines of typed accessor functions like I had at first: int get_timespec64(struct timespec64 *ts, const struct timespec __user *uts) { struct timespec64 tmp; int ret; if (sizeof(tmp) == sizeof(*ts)) return copy_from_user(&tmp, uts, sizeof(*ts)) ? -EFAULT : 0; ret = copy_from_user(&tmp, uts, sizeof(*ts)); if (ret) return -EFAULT; ts->tv_sec = tmp.tv_sec; ts->tv_nsec = tmp.tv_nsec; return 0; } This works fine, but I'd have to change it to copy from a __user __kernel_timespec instead of timespec in my system call series, and in order to do that, we must ensure that I can change over all callers at the same time, so with the function prototype above, we should not start using get_timespec64 for anything outside of posix-timers.c. Arnd -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/