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: 9184887 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1B8ED6075F for ; Fri, 17 Jun 2016 20:11:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E4B6027E33 for ; Fri, 17 Jun 2016 20:11:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D88E327EED; Fri, 17 Jun 2016 20:11:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C930627E33 for ; Fri, 17 Jun 2016 20:11:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753466AbcFQULE (ORCPT ); Fri, 17 Jun 2016 16:11:04 -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-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP /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(-) 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());