From patchwork Sun Jul 30 22:30:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 9870717 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 07CC260353 for ; Sun, 30 Jul 2017 22:32:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ECF6D28575 for ; Sun, 30 Jul 2017 22:32:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E04F62857B; Sun, 30 Jul 2017 22:32:01 +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 A006728575 for ; Sun, 30 Jul 2017 22:32:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751911AbdG3Wbr (ORCPT ); Sun, 30 Jul 2017 18:31:47 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:34488 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751126AbdG3WaP (ORCPT ); Sun, 30 Jul 2017 18:30:15 -0400 Received: by mail-pf0-f193.google.com with SMTP id t86so2588788pfe.1; Sun, 30 Jul 2017 15:30:15 -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=YAgh+MO2GAsFnh2cVzrOYL+2K9X6BE+mPokS3I00tVk=; b=Ppmgablpi5FhVOeCS12Qtkltis2+6a7wDTope8nPLYDhTzZgOJfi9ejOg5x6Rjo1mW m3ZRstecVWJinDcRsoJNCO09oCHeXxoqDX8oauFFlEEdIugzvkpxX/5tuGLPT5P06PjG ebpX+GLMtseJRyF4Y1qskx3pWwIJvhVJ+I7znhc9+v99JorzYyE9AnLNiwDqzxUE4SnK LuRofzkR/h2l1lV/OpNT8156xe2yuaH7p6QlKanNBGlGfOThePo5fIUyosG9hP+jLlje K/5eGCnPelSK3CvuY29j6rqCWZ/j9akJtffn3dOa8X/M5iS8Ile6i6wTDn1vtCBg28Ib 7oKw== 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=YAgh+MO2GAsFnh2cVzrOYL+2K9X6BE+mPokS3I00tVk=; b=VR1MGZds1MY1GNC7RmoOP8ReoHfzQy1P2S3KbzMNz1mT8Q2R0aF2HZOu8HjXLAN56P U6kbii2zqNClHdVvd14GXmBGYHGFDZjYgnl5a9EG/8i36T2oBpgQw2DYDxBtgJcvd6JF 8r8FeIN/Zo1pzpdhFb+RYnoMhCZ83y7OPLKpW/jibI9u9jT82qXNMJF1KvKreMo2voFf kfRTnbgDE/0qGWEoHytWXCdAc41x/tt+prKMcBFm8mBdY9io7yAu+QK9ZWI3ITNRFSTr U6RwsBQ0Z7HqYeliMtqsgI0gXd1E9jHFUGBTGAIUS83f3+FJ476Qr95q1L/j8w8n6Qwc DrVg== X-Gm-Message-State: AIVw112pgVk+J5eOvtUkzhv88N58ASArC21Sg53hPqxQiy+RohrhG5/V JUjpwLRwg1P43eHn X-Received: by 10.98.44.140 with SMTP id s134mr13725556pfs.251.1501453814984; Sun, 30 Jul 2017 15:30:14 -0700 (PDT) Received: from localhost.localdomain ([2601:647:5000:6620:b1bb:905a:190e:8c7e]) by smtp.gmail.com with ESMTPSA id b24sm47763365pfh.53.2017.07.30.15.30.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 30 Jul 2017 15:30:14 -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 v2 1/6] ipc: Make sys_semtimedop() y2038 safe Date: Sun, 30 Jul 2017 15:30:01 -0700 Message-Id: <20170730223006.32661-2-deepa.kernel@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170730223006.32661-1-deepa.kernel@gmail.com> References: <20170730223006.32661-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 struct timespec is not y2038 safe on 32 bit machines. Replace timespec with y2038 safe struct timespec64. Note that the patch only changes the internals without modifying the syscall interface. This will be part of a separate series. Signed-off-by: Deepa Dinamani --- ipc/sem.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ipc/sem.c b/ipc/sem.c index 8b3b40c54a58..b41cd00d104c 100644 --- a/ipc/sem.c +++ b/ipc/sem.c @@ -1861,7 +1861,7 @@ static struct sem_undo *find_alloc_undo(struct ipc_namespace *ns, int semid) } static long do_semtimedop(int semid, struct sembuf __user *tsops, - unsigned nsops, const struct timespec *timeout) + unsigned nsops, const struct timespec64 *timeout) { int error = -EINVAL; struct sem_array *sma; @@ -1897,7 +1897,7 @@ static long do_semtimedop(int semid, struct sembuf __user *tsops, error = -EINVAL; goto out_free; } - jiffies_left = timespec_to_jiffies(timeout); + jiffies_left = timespec64_to_jiffies(timeout); } max = 0; @@ -2116,8 +2116,8 @@ SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops, unsigned, nsops, const struct timespec __user *, timeout) { if (timeout) { - struct timespec ts; - if (copy_from_user(&ts, timeout, sizeof(*timeout))) + struct timespec64 ts; + if (get_timespec64(&ts, timeout)) return -EFAULT; return do_semtimedop(semid, tsops, nsops, &ts); } @@ -2130,8 +2130,8 @@ COMPAT_SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsems, const struct compat_timespec __user *, timeout) { if (timeout) { - struct timespec ts; - if (compat_get_timespec(&ts, timeout)) + struct timespec64 ts; + if (compat_get_timespec64(&ts, timeout)) return -EFAULT; return do_semtimedop(semid, tsems, nsops, &ts); }