From patchwork Mon Nov 27 17:00:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 24554 Received: (qmail 27629 invoked by alias); 27 Nov 2017 17:04:45 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 26924 invoked by uid 89); 27 Nov 2017 17:04:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KB_WAM_FROM_NAME_SINGLEWORD, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=H*Ad:U*rth, accessed, H*Ad:U*oleg, Hx-languages-length:3363 X-HELO: mout.kundenserver.de From: Arnd Bergmann To: John Stultz , Thomas Gleixner Cc: y2038@lists.linaro.org, libc-alpha@sourceware.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, Albert ARIBAUD , Arnd Bergmann , Richard Henderson , Ivan Kokshaysky , Matt Turner , Al Viro , Ingo Molnar , Frederic Weisbecker , Deepa Dinamani , Greg Kroah-Hartman , "Eric W. Biederman" , Oleg Nesterov , Andrew Morton , Kirill Tkhai , linux-alpha@vger.kernel.org Subject: [PATCH 3/3] y2038: rusage: use __kernel_old_timeval for process times Date: Mon, 27 Nov 2017 18:00:47 +0100 Message-Id: <20171127170121.634826-3-arnd@arndb.de> In-Reply-To: <20171127170121.634826-1-arnd@arndb.de> References: <20171127170121.634826-1-arnd@arndb.de> X-UI-Out-Filterresults: notjunk:1; V01:K0:kK16DXKrCMw=:MdIDOX2KxJQNgAH9TlKjgg afTI5P+j96VQ/Ygtppq510g7FFD5h4JmIomSy4ddLozQgAyFnNsF8aggzywEKcO/oAQkaPMCX QoOmZPD/3jmG0lHBbmLTA9ulpJQGMg3PSnzGsbO1ZZvlaU2pwjLqufW8+PqPpiS9xi3PUI4RQ J9LcGB9NOzvMUnAByuCy+Ep4x5RQsQ+Vo1QX9Q+924jDhRaB7Xq/69DN2kn1fwJ33SVrJBAOj k+YJudm+Fvg4U5Ik87SPA5cT0Hf+9pO1MB4bmFV1Lu+G1oCePb45h5z/dd3YjJ0B+bQnGo+9I u67Ie+mbe4u8rGNJDgvxPVY+zz5vswFiMXKbT3oQEaIh0XxIcqvmSXOuaILa5ypv5XNgYTySj 5KC2NV7hzMBgvF+Y2vJALqR+MHFk8tzLORenn7dZQ+8FemAstVB34WJ00+2Q7hk8W+KDZoh0M ZJJFdylV+5CiTUSSXvWx1O1LEkcQYP0jFRikuCn1lvHWy5rvDELXkZtew0mv/Ft6V3XGAH2nX qPB44GLSXZugh3qvYFHQFWm0TNxprWpzIoVCa7MqQrQ98jxfF8b3pP8QvyPM1/6gwbBhZL1QJ deqAIVX/s9QxlQ4iT87VKELhcmlk+/R4rrmO+42tSJmPxQo2+lLKDpRIAFwrTQBi3PXS9LOe2 HfC9/6k5xLnV7FjRG7cX74YwLvS3wqBxYEkJ1cduTImYjc0MUAjr3euvzVUGhMcy2vSP2bQym FNqwwmoH+lK8HudhEP4LaPRNIPhTtvEHEZBUaw== 'struct rusage' contains the run times of a process in 'timeval' format and is accessed through the wait4() and getrusage() system calls. This is not a problem for y2038 safety by itself, but causes an issue when the C library starts using 64-bit time_t on 32-bit architectures because the structure layout becomes incompatible. There are three possible ways of dealing with this: a) deprecate the wait4() and getrusage() system calls, and create a set of kernel interfaces based around a newly defined structure that could solve multiple problems at once, e.g. provide more fine-grained timestamps. The C library could then implement the posix interfaces on top of the new system calls. b) Extend the approach taken by the x32 ABI, and use the 64-bit native structure layout for rusage on all architectures with new system calls that is otherwise compatible. A possible problem here is that we end up with incompatible definitions of rusage between /usr/include/linux/resource.h and /usr/include/bits/resource.h c) Change the definition of struct rusage to be independent of time_t. This is the easiest change, as it does not involve new system call entry points, but it has the risk of introducing compile-time incompatibilities with user space sources that rely on the type of ru_utime and ru_stime. I'm picking approch c) for its simplicity, but I'd like to hear from others whether they would prefer a different approach. Signed-off-by: Arnd Bergmann --- arch/alpha/kernel/osf_sys.c | 2 +- include/uapi/linux/resource.h | 4 ++-- kernel/sys.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c index fa1a392ca9a2..445ded2ea471 100644 --- a/arch/alpha/kernel/osf_sys.c +++ b/arch/alpha/kernel/osf_sys.c @@ -970,7 +970,7 @@ put_tv32(struct timeval32 __user *o, struct timespec64 *i) } static inline long -put_tv_to_tv32(struct timeval32 __user *o, struct timeval *i) +put_tv_to_tv32(struct timeval32 __user *o, struct __kernel_old_timeval *i) { return copy_to_user(o, &(struct timeval32){ .tv_sec = i->tv_sec, diff --git a/include/uapi/linux/resource.h b/include/uapi/linux/resource.h index cc00fd079631..74ef57b38f9f 100644 --- a/include/uapi/linux/resource.h +++ b/include/uapi/linux/resource.h @@ -22,8 +22,8 @@ #define RUSAGE_THREAD 1 /* only the calling thread */ struct rusage { - struct timeval ru_utime; /* user time used */ - struct timeval ru_stime; /* system time used */ + struct __kernel_old_timeval ru_utime; /* user time used */ + struct __kernel_old_timeval ru_stime; /* system time used */ __kernel_long_t ru_maxrss; /* maximum resident set size */ __kernel_long_t ru_ixrss; /* integral shared memory size */ __kernel_long_t ru_idrss; /* integral unshared data size */ diff --git a/kernel/sys.c b/kernel/sys.c index 83ffd7dccf23..c459e294aa9e 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -1717,8 +1717,8 @@ void getrusage(struct task_struct *p, int who, struct rusage *r) unlock_task_sighand(p, &flags); out: - r->ru_utime = ns_to_timeval(utime); - r->ru_stime = ns_to_timeval(stime); + r->ru_utime = ns_to_kernel_old_timeval(utime); + r->ru_stime = ns_to_kernel_old_timeval(stime); if (who != RUSAGE_CHILDREN) { struct mm_struct *mm = get_task_mm(p);