From patchwork Fri Jun 17 20:12:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102142 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp452175qgy; Fri, 17 Jun 2016 13:11:08 -0700 (PDT) X-Received: by 10.66.27.136 with SMTP id t8mr4278793pag.108.1466194268471; Fri, 17 Jun 2016 13:11:08 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id xj8si27375275pab.203.2016.06.17.13.11.08; Fri, 17 Jun 2016 13:11:08 -0700 (PDT) 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 S932971AbcFQULF (ORCPT + 30 others); Fri, 17 Jun 2016 16:11:05 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:63472 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751134AbcFQULD (ORCPT ); Fri, 17 Jun 2016 16:11:03 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue001) with ESMTPA (Nemesis) id 0LqZik-1bsGrg2h3y-00eLd2; Fri, 17 Jun 2016 22:10:58 +0200 From: Arnd Bergmann To: Andrew Morton Cc: y2038@lists.linaro.org, linux-fsdevel@vger.kernel.org, Arnd Bergmann , linux-kernel@vger.kernel.org Subject: [PATCH] procfs: avoid 32-bit time_t in /proc/*/stat Date: Fri, 17 Jun 2016 22:12:40 +0200 Message-Id: <20160617201247.2292101-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:0vHuFuM/hGz2GJjq/9/hPVBYihGYgCsuAPVjeevCvhrmq5IGPEk X1abX34AsBLxBROE6FEucRA4Wodg0SetSWn9XYIBcnRLCYpvnfW/rPQEfum6Yp12BijxZYL nU7LWTjRnwpi9ldtLD4Lv0vcDYwZq1juhaSz5YraOrHhtlZikxJf4i1g/Tbb6GqdPVGs3uw ZWFpKgDmU62QA5cu6KSog== X-UI-Out-Filterresults: notjunk:1; V01:K0:Zd5AwN3URSo=:FYD0BJeE2EcT4ohZVZ0qvs GfTtucPd0SLiPE+eqpuHDK/cAYRDjOm0dbhQc3r5LWHbwHDYZcEC9+JQA/+gBtQP2MvL0h3Xs UbyathAE2bFY4XI3s2R7hhQVDYX8sx0Zdhc6+NgJ+lpc6quSUR+3y3eDEIeLygPwbFWWNLiNo aI5xvfordY1tvDnTbLG/BdGG+GqSRiJtWSZ3jJH/RT9PUGxwgrPZSbuY1oCDSn7d8gd67nVkM RkUWv7LZj+7qETeHj5eRAlwo/NrJ2VZvuugYkY+dr66VYD8MUgbQ4ipUJM0Z8AUqa/Yj4MTey ORZow1rS14L7SanzHI04+1clRIsHWbxaZ9p2YxKV0nhzWYGpcpU9oEqSE+lxIHf2kaej+bHvG wkYFgUUnfrTK+1pooNBC5OAHswc47DjGHmKUjXFXGoL3JSYIDC8IubqNVXhF+56agIUDbAse4 PA2cGvNvJWp43Oc7M/Hkt2zUS7wDBbA9oBoy7WtlaC8nu72Tnf3JlYfZJnlfni9cCnSkRjBhn 60W1P+HTcbKZXwO0WoeJkkH1eiGwtRjS2TWDSDTft4vr0AO/9yWquxePgFyWQEZq6m1Iu0Hv9 iMKhdn3VurFnVZ9ELGPrckj+p78Vd+S7yqd8gRFHKmVm1df9HHFH4i5GS1Qff+zUDbEiHlPtu B9WJzPCZLV73dB2xfYwQmYuvOkQvOw18FRZXBIbqVX69Nhm35E7iApnv14Z1ctWSf9nA= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org /proc/stat shows (among lots of other things) the current boottime (i.e. number of seconds since boot). While a 32-bit number is sufficient for this particular case, we want to get rid of the 'struct timespec' suffers from a 32-bit overflow in 2038. This changes the code to use a struct timespec64, which is known to be safe in all cases. Signed-off-by: Arnd Bergmann --- fs/proc/stat.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) -- 2.9.0 diff --git a/fs/proc/stat.c b/fs/proc/stat.c index 510413eb25b8..7907e456ac4f 100644 --- a/fs/proc/stat.c +++ b/fs/proc/stat.c @@ -80,19 +80,17 @@ static u64 get_iowait_time(int cpu) static int show_stat(struct seq_file *p, void *v) { int i, j; - unsigned long jif; u64 user, nice, system, idle, iowait, irq, softirq, steal; u64 guest, guest_nice; u64 sum = 0; u64 sum_softirq = 0; unsigned int per_softirq_sums[NR_SOFTIRQS] = {0}; - struct timespec boottime; + struct timespec64 boottime; user = nice = system = idle = iowait = irq = softirq = steal = 0; guest = guest_nice = 0; - getboottime(&boottime); - jif = boottime.tv_sec; + getboottime64(&boottime); for_each_possible_cpu(i) { user += kcpustat_cpu(i).cpustat[CPUTIME_USER]; @@ -163,12 +161,12 @@ static int show_stat(struct seq_file *p, void *v) seq_printf(p, "\nctxt %llu\n" - "btime %lu\n" + "btime %llu\n" "processes %lu\n" "procs_running %lu\n" "procs_blocked %lu\n", nr_context_switches(), - (unsigned long)jif, + (unsigned long long)boottime.tv_sec, total_forks, nr_running(), nr_iowait());