From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 48EE51F8C6 for ; Sat, 14 Aug 2021 22:25:07 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 20195388B82F for ; Sat, 14 Aug 2021 22:25:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 20195388B82F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1628979904; bh=8WtPm9NI5GdaHRgA7s2MZNqj0fqOuPG+X6x+Vpot22E=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=ChZ03Hp3rCu3r7GePJ9ylQXMfs0uI1fVNEoYcHsILq2DeAFTrx22FTQr+T6JGZifI pGcr9pTMP2TnN5SBGL/Nk7ePAsq31HkN03DUX8aixeHW2OlglELYbaoGBVMAa+JQBc htv3nycl7/XfJdbz6lIH6moUkaQbj48vMo+o4tlU= Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by sourceware.org (Postfix) with ESMTPS id 96E8D3839424 for ; Sat, 14 Aug 2021 22:24:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 96E8D3839424 Received: by mail-pj1-x102a.google.com with SMTP id u21-20020a17090a8915b02901782c36f543so26347451pjn.4 for ; Sat, 14 Aug 2021 15:24:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=8WtPm9NI5GdaHRgA7s2MZNqj0fqOuPG+X6x+Vpot22E=; b=K3Gd4erbZmZkl0d4MxghiZ8Nl/8fEcf+K+Qap6uRRHeie+xB8xNPiQOBnpjYG5q+Lr sDbKBZP3x3osnyggHAt0g3JdC+CiwcjCYhenBwtBB2/hp3FomNCJ890ynTJ6fT9D2Zby BayGfpks7SH3Omd5PYDxCEZC9ul8KkU2qjueEk0mUCqRNOpD9IYdMwLlcM8+/cl3CXbU YocjX4Kj1KzV8fsfHoZts23/enFIDy+AKgdbpx6bgjIE1/ZCLiM4HcNjmbZkmd8xKQa8 Mx/bd4gmNdaK25eO307RJUVUOEEDF2sH7/yuqRTIANTf98hXGkiDvbMdO/kPGiSNuDcG 3VoA== X-Gm-Message-State: AOAM5339BUIuhfT60/ZOvj7OAUm/GnylqI2m60bm2HR/xABpHNFoGaVK Zje+GgDutuCZCTq3AwlEMmM= X-Google-Smtp-Source: ABdhPJxxk0En9CSxotCwKpvncGUc5VJBHXFWsCsPfOS8TegmqOT3FotqFTvywexe5W9eaOpGXcvoeA== X-Received: by 2002:a17:902:7c87:b029:12c:8f2d:4238 with SMTP id y7-20020a1709027c87b029012c8f2d4238mr7292676pll.50.1628979883659; Sat, 14 Aug 2021 15:24:43 -0700 (PDT) Received: from localhost (g195.61-45-49.ppp.wakwak.ne.jp. [61.45.49.195]) by smtp.gmail.com with ESMTPSA id b6sm7235523pgs.94.2021.08.14.15.24.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Aug 2021 15:24:42 -0700 (PDT) Date: Sun, 15 Aug 2021 07:24:40 +0900 To: Adhemerval Zanella Subject: Re: [PATCH v2] time: Fix overflow itimer tests on 32-bit systems Message-ID: References: <20210806094217.3227877-1-shorne@gmail.com> <0f577bc8-bef8-6c06-aaa9-57bf16d8443b@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0f577bc8-bef8-6c06-aaa9-57bf16d8443b@linaro.org> X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Stafford Horne via Libc-alpha Reply-To: Stafford Horne Cc: Openrisc , GLIBC patches Errors-To: libc-alpha-bounces+e=80x24.org@sourceware.org Sender: "Libc-alpha" On Wed, Aug 11, 2021 at 05:30:40PM -0300, Adhemerval Zanella wrote: > > > On 06/08/2021 06:42, Stafford Horne wrote: > > On the port of OpenRISC I am working on and it appears the rv32 port > > we have sets __TIMESIZE == 64 && __WORDSIZE == 32. This causes the > > size of time_t to be 8 bytes, but the tv_sec in the kernel is still 32-bit > > causing truncation. > > > > The truncations are unavoidable on these systems so skip the > > testing/failures by guarding with __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64. > > > > Also, futher in the tests and in other parts of code checking for time_t > > overflow does not work on 32-bit systems when time_t is 64-bit. As > > suggested by Adhemerval, update the in_time_t_range function to assume > > 32-bits by using int32_t. > > > > This also brings in the header for stdint.h so we can update other > > usages of __int32_t to int32_t as suggested by Adhemerval. > > --- > > > > Hello, > > > > Sorry for the delay to get this out I have been busy on the hardware side of > > openrisc the last month so I haven't been able to spend time on getting this > > out. > > > > The patch ends up doing a test fix and some lib code fixes, I can split it to > > separate small patches. But since as a whole it's small I feel leaving it > > together is best. > > LGTM, thanks. > > Reviewed-by: Adhemerval Zanella Thanks for the review. > > > > -Stafford > > > > include/time.h | 10 ++++++---- > > time/tst-itimer.c | 4 ++-- > > 2 files changed, 8 insertions(+), 6 deletions(-) > > > > diff --git a/include/time.h b/include/time.h > > index 4372bfbd96..ba3c5116cf 100644 > > --- a/include/time.h > > +++ b/include/time.h > > @@ -11,6 +11,7 @@ > > # include > > # include > > # include > > +# include > > > > extern __typeof (strftime_l) __strftime_l; > > libc_hidden_proto (__strftime_l) > > @@ -334,11 +335,12 @@ libc_hidden_proto (__time64) > > actual clock ID. */ > > #define CLOCK_IDFIELD_SIZE 3 > > > > -/* Check whether T fits in time_t. */ > > +/* Check whether T fits in int32_t, assume all usages are for > > + sizeof(time_t) == 32. */ > > static inline bool > > in_time_t_range (__time64_t t) > > { > > - time_t s = t; > > + int32_t s = t; > > return s == t; > > } > > > > @@ -445,8 +447,8 @@ timespec64_to_timeval64 (const struct __timespec64 ts64) > > and suseconds_t. */ > > struct __timeval32 > > { > > - __int32_t tv_sec; /* Seconds. */ > > - __int32_t tv_usec; /* Microseconds. */ > > + int32_t tv_sec; /* Seconds. */ > > + int32_t tv_usec; /* Microseconds. */ > > }; > > > > /* Conversion functions for converting to/from __timeval32 */ > > diff --git a/time/tst-itimer.c b/time/tst-itimer.c > > index 929c2b74c7..bd7d7afe83 100644 > > --- a/time/tst-itimer.c > > +++ b/time/tst-itimer.c > > @@ -100,7 +100,7 @@ do_test (void) > > > > /* Linux does not provide 64 bit time_t support for getitimer and > > setitimer on architectures with 32 bit time_t support. */ > > - if (sizeof (__time_t) == 8) > > + if (__KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64) > > { > > TEST_COMPARE (setitimer (timers[i], &it, NULL), 0); > > TEST_COMPARE (setitimer (timers[i], &(struct itimerval) { 0 }, > > @@ -131,7 +131,7 @@ do_test (void) > > it.it_interval.tv_usec = 20; > > it.it_value.tv_sec = 30; > > it.it_value.tv_usec = 40; > > - if (sizeof (__time_t) == 8) > > + if (__KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64) > > { > > TEST_COMPARE (setitimer (timers[i], &it, NULL), 0); > > > >