From patchwork Thu Aug 3 02:51:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 9878053 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 A8394603B4 for ; Thu, 3 Aug 2017 02:53:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9923E2874E for ; Thu, 3 Aug 2017 02:53:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8DF6A28769; Thu, 3 Aug 2017 02:53:04 +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 33A502874E for ; Thu, 3 Aug 2017 02:53:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752207AbdHCCwT (ORCPT ); Wed, 2 Aug 2017 22:52:19 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:35038 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752202AbdHCCwR (ORCPT ); Wed, 2 Aug 2017 22:52:17 -0400 Received: by mail-pg0-f67.google.com with SMTP id l64so182786pge.2; Wed, 02 Aug 2017 19:52:17 -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=5vpNCG4PofDZzirUtpa3quee/oP8hzGjMMZQmDOFm/A=; b=f+VOCkOgUvkqdUZg1TWhtsCQj7hs0FXBpRj2uuPWMjr6cS+HbuTHGMdd7AxrXbqvoT Iy5MjjFAmRlcLAu/QAisLNVSQvTlrwa8lbbVd4VD/ogYlsNBASZypCqzAxhGB9M3ugrp uEx4sx78nZEgoAK4jnLDDJ57kwVGzfLBRgdziQZ6pHfYmfMWrZhzDjTKHuQoaFEQR7ln hWJLFyN75uwXK6VvZm+31aUwrUoRav1SLi0GVi0P1WfsxqfEvD2rozSVnE624gXTBAbZ Xd2BkdlW9zKW33hw9PzWYmUPxchdP17bni6djm9qg8cY4XHcPyZREkXJmKHAMfZrylH0 i5Gw== 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=5vpNCG4PofDZzirUtpa3quee/oP8hzGjMMZQmDOFm/A=; b=IFjJXjpOLr6QMryLm7RT2uWO0epsAEAFO3oVrdhuC2d3BL+DMIaHifjpcrAXXW5UAL gnoxoOj99qORnrgi3/58UUW7eJi37S632KQtP1Z76bjLEIIMqsp25z9HwKhFnU5Ozvci mNbWskxiZ69GpnLTLeCMpJjJ7wSIkT7Hd6bnf89TNNg0Xk2fkjtjLP18uLJF6FCKMNnW 1fYV54TPre6DPWtNdvp1FlVflZC6xnl/I07vhPjWzestx7FfImrXxWyXZ2snjPtqjvPp 4joBz+OiJmmZQ0+4xMI3E7u/O/fMFVaEnNggv8l3DhIqJXpkAwt6lSsvUno0DJqVkdrH ycCg== X-Gm-Message-State: AIVw111JQJK6plky0w0XL4eu7tHV/Lp2jRcSLEloeXFgKJDenkKSUEpG NV7XV9wm2E0N8g== X-Received: by 10.98.213.196 with SMTP id d187mr189395pfg.146.1501728736572; Wed, 02 Aug 2017 19:52:16 -0700 (PDT) Received: from localhost.localdomain ([2601:647:5000:6620:ec84:96b1:7dd3:7554]) by smtp.gmail.com with ESMTPSA id s11sm43489784pfi.24.2017.08.02.19.52.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Aug 2017 19:52:16 -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: [PATCH v3 4/6] ipc: sem: Make sem_array timestamps y2038 safe Date: Wed, 2 Aug 2017 19:51:13 -0700 Message-Id: <20170803025115.24678-5-deepa.kernel@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170803025115.24678-1-deepa.kernel@gmail.com> References: <20170803025115.24678-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 interface themselves are not changed as part of the patch. They will be part of a different series. Signed-off-by: Deepa Dinamani Reviewed-by: Arnd Bergmann --- include/linux/sem.h | 3 ++- ipc/sem.c | 18 +++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/include/linux/sem.h b/include/linux/sem.h index 9edec926e9d9..8012ce99f72f 100644 --- a/include/linux/sem.h +++ b/include/linux/sem.h @@ -4,6 +4,7 @@ #include #include #include +#include #include struct task_struct; @@ -11,7 +12,7 @@ struct task_struct; /* One sem_array data structure for each set of semaphores in the system. */ struct sem_array { struct kern_ipc_perm sem_perm; /* permissions .. see ipc.h */ - time_t sem_ctime; /* last change time */ + time64_t sem_ctime; /* last change time */ struct sem *sem_base; /* ptr to first semaphore in array */ struct list_head pending_alter; /* pending operations */ /* that alter the array */ diff --git a/ipc/sem.c b/ipc/sem.c index b41cd00d104c..48e7babdb869 100644 --- a/ipc/sem.c +++ b/ipc/sem.c @@ -518,7 +518,7 @@ static int newary(struct ipc_namespace *ns, struct ipc_params *params) INIT_LIST_HEAD(&sma->pending_const); INIT_LIST_HEAD(&sma->list_id); sma->sem_nsems = nsems; - sma->sem_ctime = get_seconds(); + sma->sem_ctime = ktime_get_real_seconds(); id = ipc_addid(&sem_ids(ns), &sma->sem_perm, ns->sc_semmni); if (id < 0) { @@ -1169,14 +1169,14 @@ static unsigned long copy_semid_to_user(void __user *buf, struct semid64_ds *in, } } -static time_t get_semotime(struct sem_array *sma) +static time64_t get_semotime(struct sem_array *sma) { int i; - time_t res; + time64_t res; res = sma->sem_base[0].sem_otime; for (i = 1; i < sma->sem_nsems; i++) { - time_t to = sma->sem_base[i].sem_otime; + time64_t to = sma->sem_base[i].sem_otime; if (to > res) res = to; @@ -1316,7 +1316,7 @@ static int semctl_setval(struct ipc_namespace *ns, int semid, int semnum, curr->semval = val; curr->sempid = task_tgid_vnr(current); - sma->sem_ctime = get_seconds(); + sma->sem_ctime = ktime_get_real_seconds(); /* maybe some queued-up processes were waiting for this */ do_smart_update(sma, NULL, 0, 0, &wake_q); sem_unlock(sma, -1); @@ -1442,7 +1442,7 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum, for (i = 0; i < nsems; i++) un->semadj[i] = 0; } - sma->sem_ctime = get_seconds(); + sma->sem_ctime = ktime_get_real_seconds(); /* maybe some queued-up processes were waiting for this */ do_smart_update(sma, NULL, 0, 0, &wake_q); err = 0; @@ -1552,7 +1552,7 @@ static int semctl_down(struct ipc_namespace *ns, int semid, err = ipc_update_perm(&semid64->sem_perm, ipcp); if (err) goto out_unlock0; - sma->sem_ctime = get_seconds(); + sma->sem_ctime = ktime_get_real_seconds(); break; default: err = -EINVAL; @@ -2297,7 +2297,7 @@ static int sysvipc_sem_proc_show(struct seq_file *s, void *it) { struct user_namespace *user_ns = seq_user_ns(s); struct sem_array *sma = it; - time_t sem_otime; + time64_t sem_otime; /* * The proc interface isn't aware of sem_lock(), it calls @@ -2310,7 +2310,7 @@ static int sysvipc_sem_proc_show(struct seq_file *s, void *it) sem_otime = get_semotime(sma); seq_printf(s, - "%10d %10d %4o %10u %5u %5u %5u %5u %10lu %10lu\n", + "%10d %10d %4o %10u %5u %5u %5u %5u %10llu %10llu\n", sma->sem_perm.key, sma->sem_perm.id, sma->sem_perm.mode,