From patchwork Wed Apr 3 18:39:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 87991 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C99AB384640D for ; Wed, 3 Apr 2024 18:40:20 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id E72B93847718 for ; Wed, 3 Apr 2024 18:39:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E72B93847718 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E72B93847718 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712169598; cv=none; b=Q1ALrYZJ+pnAIB4tS0lJNyLgDDLZp+fuEQeMNpRIl2VFOUxJHczDq4HC41Oa0VWU/Rb1DCAxvMzI9xdE5p4eW4/wtGZref5m3ypTyESiqdDpa8iaNDSzZQ4uCPEFPUYsJ8IdYvfDGVjpLhIc341J4Ryy8ol0qb48qtzfOS6mWgg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712169598; c=relaxed/simple; bh=iqul6PR8clicZGDCCo4inG8VhCk2UoqP4dW8eJSPbRI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=CisD6NFnXXpgn5QbRGE1nwGiN3JZSW7YSySM22OjzOPuzRwZtr3GHLssbneHC9TNGQfpTfZ8B7pPPghPBfria2gnQQ3iduw4WlaEHsuRTXtjIV2UPs4xJy5N/F+JYVEtTF+XpPpyStzOwneNJAK9JuXpy1YTZfwy6L8J6JbX8xw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712169596; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=mAZwEthLBuDZdBVyJTqgHtCn20Jwb76GF451HkEPPVE=; b=XkJJTFGnraXNqyfXxhHf6qsnm9BIkZ9paDy/dUiPB4F2+iWSj24bYRDdinYc63558nK5B3 V2f0TICsIUFcQtRydDdYt3KZCYFnwru2wC7ZiLpLqyvgZ5bmXKKjEbtflMXJqybwrY5Utn EBltnRgbfQ9LBreFYy5mG09/BInRkW0= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-41-cvjZ76NlO92_zJ_vK3Zzvg-1; Wed, 03 Apr 2024 14:39:55 -0400 X-MC-Unique: cvjZ76NlO92_zJ_vK3Zzvg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 126FB1C54032 for ; Wed, 3 Apr 2024 18:39:55 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.193.76]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 52C272166B31 for ; Wed, 3 Apr 2024 18:39:54 +0000 (UTC) From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH] login: Use unsigned 32-bit types for seconds-since-epoch Date: Wed, 03 Apr 2024 20:39:48 +0200 Message-ID: <87sf02guiz.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org These fields store timestamps when the system was running. No Linux systems existed before 1970, so these values are unused. Switching to unsigned types allows continued use of the existing struct layouts beyond the year 2038. This change is relevant to some 64-bit architectures which opted to use 32-bit timestamps, for compatibility with co-installed 32-bit binaries (__WORDSIZE_TIME64_COMPAT32). For consistency, if there is a 64-bit architecture that is coinstallable, define __WORDSIZE_TIME64_COMPAT32 to 1 on the 32-bit architectyre as well. The intent is to give distributions more time to switch to improved interfaces that also avoid locking/data corruption issues. Tested on aarch64-linux-gnu, i686-linux-gnu, powerpc-linux-gnu, powerpc64-linux-gnu, powerpc64le-linux-gnu, s390-linux-gnu, s390x-linux-gnu, x86_64-linux-gnu. --- NEWS | 6 +++++- bits/utmp.h | 4 ++-- sysdeps/gnu/bits/utmpx.h | 2 +- sysdeps/mips/bits/wordsize.h | 6 +----- sysdeps/powerpc/powerpc32/bits/wordsize.h | 3 +-- sysdeps/sparc/sparc32/bits/wordsize.h | 2 +- sysdeps/sparc/sparc64/bits/wordsize.h | 3 +-- sysdeps/unix/sysv/linux/sparc/bits/wordsize.h | 3 +-- sysdeps/x86/bits/wordsize.h | 5 ++--- 9 files changed, 15 insertions(+), 19 deletions(-) base-commit: a4ed0471d71739928a0d0fa3258b3ff3b158e9b9 diff --git a/NEWS b/NEWS index da4b2223e9..2b2484b983 100644 --- a/NEWS +++ b/NEWS @@ -28,7 +28,11 @@ Major new features: Deprecated and removed features, and other changes affecting compatibility: - [Add deprecations, removals and changes affecting compatibility here] +* Architectures which use a 32-bit seconds-since-epoch field in struct + lastlog, struct utmp, struct utmpx (such as i386, powerpc64le, rv32, + rv64, x86-64) switched from a signed to an unsigned type for that + field. This allows these fields to store timestamps beyond the + year 2038. Changes to build and runtime requirements: diff --git a/bits/utmp.h b/bits/utmp.h index f2d1c13d8c..27cb536800 100644 --- a/bits/utmp.h +++ b/bits/utmp.h @@ -36,7 +36,7 @@ struct lastlog { #if __WORDSIZE_TIME64_COMPAT32 - int32_t ll_time; + __uint32_t ll_time; #else __time_t ll_time; #endif @@ -76,7 +76,7 @@ struct utmp int32_t ut_session; /* Session ID, used for windowing. */ struct { - int32_t tv_sec; /* Seconds. */ + __uint32_t tv_sec; /* Seconds. */ int32_t tv_usec; /* Microseconds. */ } ut_tv; /* Time entry was made. */ #else diff --git a/sysdeps/gnu/bits/utmpx.h b/sysdeps/gnu/bits/utmpx.h index 34b4afbc6a..ed0df9bd81 100644 --- a/sysdeps/gnu/bits/utmpx.h +++ b/sysdeps/gnu/bits/utmpx.h @@ -74,7 +74,7 @@ struct utmpx __int32_t ut_session; /* Session ID, used for windowing. */ struct { - __int32_t tv_sec; /* Seconds. */ + __uint32_t tv_sec; /* Seconds. */ __int32_t tv_usec; /* Microseconds. */ } ut_tv; /* Time entry was made. */ #else diff --git a/sysdeps/mips/bits/wordsize.h b/sysdeps/mips/bits/wordsize.h index 57f0f2a22f..30dd3fd85d 100644 --- a/sysdeps/mips/bits/wordsize.h +++ b/sysdeps/mips/bits/wordsize.h @@ -19,11 +19,7 @@ #define __WORDSIZE _MIPS_SZPTR -#if _MIPS_SIM == _ABI64 -# define __WORDSIZE_TIME64_COMPAT32 1 -#else -# define __WORDSIZE_TIME64_COMPAT32 0 -#endif +#define __WORDSIZE_TIME64_COMPAT32 1 #if __WORDSIZE == 32 #define __WORDSIZE32_SIZE_ULONG 0 diff --git a/sysdeps/powerpc/powerpc32/bits/wordsize.h b/sysdeps/powerpc/powerpc32/bits/wordsize.h index 04ca9debf0..6993fb6b29 100644 --- a/sysdeps/powerpc/powerpc32/bits/wordsize.h +++ b/sysdeps/powerpc/powerpc32/bits/wordsize.h @@ -2,10 +2,9 @@ #if defined __powerpc64__ # define __WORDSIZE 64 -# define __WORDSIZE_TIME64_COMPAT32 1 #else # define __WORDSIZE 32 -# define __WORDSIZE_TIME64_COMPAT32 0 # define __WORDSIZE32_SIZE_ULONG 0 # define __WORDSIZE32_PTRDIFF_LONG 0 #endif +#define __WORDSIZE_TIME64_COMPAT32 1 diff --git a/sysdeps/sparc/sparc32/bits/wordsize.h b/sysdeps/sparc/sparc32/bits/wordsize.h index 4bbd2e63b4..a2e79e0fa9 100644 --- a/sysdeps/sparc/sparc32/bits/wordsize.h +++ b/sysdeps/sparc/sparc32/bits/wordsize.h @@ -1,6 +1,6 @@ /* Determine the wordsize from the preprocessor defines. */ #define __WORDSIZE 32 -#define __WORDSIZE_TIME64_COMPAT32 0 +#define __WORDSIZE_TIME64_COMPAT32 1 #define __WORDSIZE32_SIZE_ULONG 0 #define __WORDSIZE32_PTRDIFF_LONG 0 diff --git a/sysdeps/sparc/sparc64/bits/wordsize.h b/sysdeps/sparc/sparc64/bits/wordsize.h index 2f66f10d72..ea103e5970 100644 --- a/sysdeps/sparc/sparc64/bits/wordsize.h +++ b/sysdeps/sparc/sparc64/bits/wordsize.h @@ -2,10 +2,9 @@ #if defined __arch64__ || defined __sparcv9 # define __WORDSIZE 64 -# define __WORDSIZE_TIME64_COMPAT32 1 #else # define __WORDSIZE 32 -# define __WORDSIZE_TIME64_COMPAT32 0 # define __WORDSIZE32_SIZE_ULONG 0 # define __WORDSIZE32_PTRDIFF_LONG 0 #endif +#define __WORDSIZE_TIME64_COMPAT32 1 diff --git a/sysdeps/unix/sysv/linux/sparc/bits/wordsize.h b/sysdeps/unix/sysv/linux/sparc/bits/wordsize.h index 7562875ee2..ea103e5970 100644 --- a/sysdeps/unix/sysv/linux/sparc/bits/wordsize.h +++ b/sysdeps/unix/sysv/linux/sparc/bits/wordsize.h @@ -2,10 +2,9 @@ #if defined __arch64__ || defined __sparcv9 # define __WORDSIZE 64 -# define __WORDSIZE_TIME64_COMPAT32 1 #else # define __WORDSIZE 32 # define __WORDSIZE32_SIZE_ULONG 0 # define __WORDSIZE32_PTRDIFF_LONG 0 -# define __WORDSIZE_TIME64_COMPAT32 0 #endif +#define __WORDSIZE_TIME64_COMPAT32 1 diff --git a/sysdeps/x86/bits/wordsize.h b/sysdeps/x86/bits/wordsize.h index 70f652bca1..b1442406b4 100644 --- a/sysdeps/x86/bits/wordsize.h +++ b/sysdeps/x86/bits/wordsize.h @@ -8,10 +8,9 @@ #define __WORDSIZE32_PTRDIFF_LONG 0 #endif +#define __WORDSIZE_TIME64_COMPAT32 1 + #ifdef __x86_64__ -# define __WORDSIZE_TIME64_COMPAT32 1 /* Both x86-64 and x32 use the 64-bit system call interface. */ # define __SYSCALL_WORDSIZE 64 -#else -# define __WORDSIZE_TIME64_COMPAT32 0 #endif