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: 119761 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp544140qgn; Mon, 27 Nov 2017 09:04:37 -0800 (PST) X-Google-Smtp-Source: AGs4zMYdaBwcIUUpfSM3ZjORTQyHT+2CEvXfevto49JQLTM9MWNvl+FIQ/0RnEua8xVEk3ai8FF6 X-Received: by 10.101.93.132 with SMTP id f4mr17730427pgt.152.1511802276943; Mon, 27 Nov 2017 09:04:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511802276; cv=none; d=google.com; s=arc-20160816; b=zT7XnU8YspzDeoLxxkjlsopJtx/9dHw8olwEGjV8IOxVmYyK7tQQUTnwUe9tR5EvFw l2CUxLm6pcjjvolOF2yyETD1+io5bxV7LMGTXIAo+X0rJuRAp+whYiTz31IopS8aNhbs sEkeqqaGC+yNzoepn764//rVXFnl9eOZc8YuJB41Li7dOkOG9wySmJdV1qoI7P/jQH5c xtIfD+f68Um58X19UqpoEgSox1bzLgHQkzSdomfJFfasb1suuSVwZsvuqKDd+iy9DSHZ 5blotpalay07KEqL1XO0yipesXynP5QIhH0u65JllETfwCir+6KP6l9h6F0gYA2LthfU ELzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=tXLs6TtQYodGTUiQSEa8PxQuQ86XlPcB0PDAaw+8WLc=; b=gPszk+sRDHvBGQbhjf3yXO8b0BHFf0ELRnjzqnkQM/HzhW4vXuECuy64avTlm4mSXt yd1pmCY4KgLiFZ048aWtInMyM3LEIpVjGMWrxRuYjpRba3s2lsnawTNd9I7mH3Sa5U6X G8gsOdtXDFOwd04E2P4GhuIXpp281JBWslBY1Zqb/FsrTZNbPZpH6inMk4e09tmO9NAS oKb5RWor1kQcQg7/V+kh208P2yQl999TM3IbLWuShUkmGwAp20QIVTLOdFFtYZfRTGVv A6HpsUJFONw0vyBl9Z5GNXKMXCIVWtu+aFCJfv580/hqF9XJPd6PxUZdzIXGumxQeGJ/ r7oQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m15si4897925pgs.790.2017.11.27.09.04.36; Mon, 27 Nov 2017 09:04:36 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932372AbdK0REf (ORCPT + 28 others); Mon, 27 Nov 2017 12:04:35 -0500 Received: from mout.kundenserver.de ([217.72.192.75]:53303 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932256AbdK0REa (ORCPT ); Mon, 27 Nov 2017 12:04:30 -0500 Received: from wuerfel.lan ([109.193.157.232]) by mrelayeu.kundenserver.de (mreue105 [212.227.15.145]) with ESMTPA (Nemesis) id 0Mdund-1eTUcB2hW1-00PfEd; Mon, 27 Nov 2017 18:03:46 +0100 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> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20171127170121.634826-1-arnd@arndb.de> References: <20171127170121.634826-1-arnd@arndb.de> X-Provags-ID: V03:K0:jyBN2A6NDwPh/DEGRvt0YaZPAd1lG3rP7n1U2VkWIVM4VIeGKiq YvO4xRGBzZamAGmPfYfAkLcA4QmVyAn+23Qtjx2QauvZZoJLpKdM1cJwuWZwOco/fzt8tWZ xRmhI1hFPVEVa475NoeqJ4a5WdoTSVkQLUWLdtV0jX9A5jVMTpeT2K9ORV2htFH+miTMXuo 9cZs901A4UuNhH1ijfRJg== 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== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org '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(-) -- 2.9.0 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);