From patchwork Fri Jul 28 18:52:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 9869261 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 2035260382 for ; Fri, 28 Jul 2017 18:53:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E756F288D2 for ; Fri, 28 Jul 2017 18:53:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DAD78288E6; Fri, 28 Jul 2017 18:53:49 +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.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable 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 8D9D2288D2 for ; Fri, 28 Jul 2017 18:53:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752612AbdG1SxX (ORCPT ); Fri, 28 Jul 2017 14:53:23 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:33552 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752715AbdG1Sw4 (ORCPT ); Fri, 28 Jul 2017 14:52:56 -0400 Received: by mail-pg0-f67.google.com with SMTP id u185so2023330pgb.0; Fri, 28 Jul 2017 11:52:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lEr7xUqSQhHM2+2iNHCCE1irkMYEtDrYv7WKu3Uf5Kc=; b=AjNIUxJrpsBqbqeY5ksPY/zIj7CZuNE+PtGayL+n2WHNZ6y/fznCiDnqQtmvywc281 VwGvlRl3tcgnfyQkki7qsXQk9ESLxlCj+VRihrzPr1dkYbv+HJPmQpe9OucrDm/AhZRa pK9tOqZW9OUJA9tpn/aMzxWCO810csejlDThF45E7cfaLWJ4j4xgEyajxErncLe73wiD MK2XobTLsmzp3uTFHc8Fgzn50jQPT55kSI1FTYVdm2KwygkrhIn3uwtG6u7EDSjm0flE dUpNezOwVd1MFOFuXpTq27Mh/Pd546ilIEF4C+fL4Xp/8oiebp4RWLR9JVvx4YVleE/R S4CQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=lEr7xUqSQhHM2+2iNHCCE1irkMYEtDrYv7WKu3Uf5Kc=; b=taoSuGzu1DUiR8l4LZqvyNIaynImD9/zWWHoAK8mqo6cTZTr64eKadxuHaKVElZ5Yy egRoAVeH0Mpuin1K8Wrf/Jp9xHG2C3DEcnneFq0kgQGXX3M17FiFadOjBgakIR1eGiNn eVrBFKlSNXmkb4I+ouBoTSYYSar5QAgJ2pT1hb6xBbWi/+m/dl5GSYRT8GnheD4G7egi H+9GKRAVyGxw0ClyL/wjqme0/I+d/OlbFLJgKwu/tWwlgXOUMHfLy+gSawaRPALEwxkO WODQ6LpCu9RXA1aE0xPxHN40+v6ldHr//nUaA1rEN2McfXOgjm7PRyib30suYHXEoV3/ Odcg== X-Gm-Message-State: AIVw111cDM1mf/W0MDu2um/gyw32jK0wZxKTgQuu7V4ilGZDJgpjCPzc Zs0q8ZcSjYc2eAKl X-Received: by 10.98.69.207 with SMTP id n76mr906654pfi.28.1501267975995; Fri, 28 Jul 2017 11:52:55 -0700 (PDT) Received: from localhost.localdomain ([2601:647:5000:6620:39fd:1b9c:c45:e526]) by smtp.gmail.com with ESMTPSA id x5sm38485095pgq.18.2017.07.28.11.52.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Jul 2017 11:52:55 -0700 (PDT) From: Deepa Dinamani To: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, arnd@arndb.de, y2038@lists.linaro.org Subject: [RESEND PATCH 5/6] ipc: shm: Make shmid_kernel timestamps y2038 safe Date: Fri, 28 Jul 2017 11:52:06 -0700 Message-Id: <20170728185207.12480-6-deepa.kernel@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170728185207.12480-1-deepa.kernel@gmail.com> References: <20170728185207.12480-1-deepa.kernel@gmail.com> 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 time_t is not y2038 safe. Replace all uses of time_t by y2038 safe time64_t. Similarly, replace the calls to get_seconds() with y2038 safe ktime_get_real_seconds(). Note that this preserves fast access on 64 bit systems, but 32 bit systems need sequence counters. The syscall interfaces themselves are not changed as part of the patch. They will be part of a different series. Signed-off-by: Deepa Dinamani --- include/linux/shm.h | 6 +++--- ipc/shm.c | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/linux/shm.h b/include/linux/shm.h index 04e881829625..7bb897b25309 100644 --- a/include/linux/shm.h +++ b/include/linux/shm.h @@ -12,9 +12,9 @@ struct shmid_kernel /* private to the kernel */ struct file *shm_file; unsigned long shm_nattch; unsigned long shm_segsz; - time_t shm_atim; - time_t shm_dtim; - time_t shm_ctim; + time64_t shm_atim; + time64_t shm_dtim; + time64_t shm_ctim; pid_t shm_cprid; pid_t shm_lprid; struct user_struct *mlock_user; diff --git a/ipc/shm.c b/ipc/shm.c index c547388487c1..f4ed20199eb4 100644 --- a/ipc/shm.c +++ b/ipc/shm.c @@ -199,7 +199,7 @@ static int __shm_open(struct vm_area_struct *vma) if (IS_ERR(shp)) return PTR_ERR(shp); - shp->shm_atim = get_seconds(); + shp->shm_atim = ktime_get_real_seconds(); shp->shm_lprid = task_tgid_vnr(current); shp->shm_nattch++; shm_unlock(shp); @@ -286,7 +286,7 @@ static void shm_close(struct vm_area_struct *vma) goto done; /* no-op */ shp->shm_lprid = task_tgid_vnr(current); - shp->shm_dtim = get_seconds(); + shp->shm_dtim = ktime_get_real_seconds(); shp->shm_nattch--; if (shm_may_destroy(ns, shp)) shm_destroy(ns, shp); @@ -592,7 +592,7 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params) shp->shm_cprid = task_tgid_vnr(current); shp->shm_lprid = 0; shp->shm_atim = shp->shm_dtim = 0; - shp->shm_ctim = get_seconds(); + shp->shm_ctim = ktime_get_real_seconds(); shp->shm_segsz = size; shp->shm_nattch = 0; shp->shm_file = file; @@ -848,7 +848,7 @@ static int shmctl_down(struct ipc_namespace *ns, int shmid, int cmd, err = ipc_update_perm(&shmid64->shm_perm, ipcp); if (err) goto out_unlock0; - shp->shm_ctim = get_seconds(); + shp->shm_ctim = ktime_get_real_seconds(); break; default: err = -EINVAL; @@ -1588,7 +1588,7 @@ static int sysvipc_shm_proc_show(struct seq_file *s, void *it) seq_printf(s, "%10d %10d %4o " SIZE_SPEC " %5u %5u " - "%5lu %5u %5u %5u %5u %10lu %10lu %10lu " + "%5lu %5u %5u %5u %5u %10llu %10llu %10llu " SIZE_SPEC " " SIZE_SPEC "\n", shp->shm_perm.key, shp->shm_perm.id, @@ -1601,9 +1601,9 @@ static int sysvipc_shm_proc_show(struct seq_file *s, void *it) from_kgid_munged(user_ns, shp->shm_perm.gid), from_kuid_munged(user_ns, shp->shm_perm.cuid), from_kgid_munged(user_ns, shp->shm_perm.cgid), - shp->shm_atim, - shp->shm_dtim, - shp->shm_ctim, + (unsigned long long) shp->shm_atim, + (unsigned long long) shp->shm_dtim, + (unsigned long long) shp->shm_ctim, rss * PAGE_SIZE, swp * PAGE_SIZE);