From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/14533 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: [RFC] final time64 switch-over patch series Date: Fri, 9 Aug 2019 10:48:18 -0400 Message-ID: <20190809144818.GH9017@brightrain.aerifal.cx> References: <20190802214433.GA25193@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="250822"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-14549-gllmg-musl=m.gmane.org@lists.openwall.com Fri Aug 09 16:48:41 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1hw6C6-0012vM-8B for gllmg-musl@m.gmane.org; Fri, 09 Aug 2019 16:48:38 +0200 Original-Received: (qmail 22522 invoked by uid 550); 9 Aug 2019 14:48:30 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 22503 invoked from network); 9 Aug 2019 14:48:30 -0000 Content-Disposition: inline In-Reply-To: <20190802214433.GA25193@brightrain.aerifal.cx> Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:14533 Archived-At: On Fri, Aug 02, 2019 at 05:44:33PM -0400, Rich Felker wrote: > 2. the rusage, utmpx, and timex structs are not correct with regard to > ABI or functionality. they need to be fixed before this is safe to > use. There's also struct sched_param, which contains gratuitous timespecs for functionality we don't (and probably won't ever) support. This will gratuitously change size when we change time_t unless action is taken to prevent it. My leaning here is to just remove all the sched_ss_* stuff and replace it with same-sized reserved space. But nothing in libc accesses (read or write) anything but a single int (sched_prio) via the sched_param pointer, so we could just leave it and let the size change; this would not affect any ABI between libc and the libc-consumer, but it would affect ABI between pairs of libc-consumers using the type (which seems pretty far-fetched. Also, we would never be able to access the additional space it's expanded to, because the caller could plausibly be an old binary that allocated less space. So I think just getting rid of it all is best. Note that we lack a proper type (what would essentially be "__old_time_t") to define same-size replacement for the members to be removed and replaced with "reserved" space. This is the same type we need in rusage, timex, and possibly utmpx as well. I could make alltypes.h define __OLD_TIME_T or something, and conditionally use it if it's defined. But I think it may be cleaner to use _REDIR_TIME64 as a proxy for this. If _REDIR_TIME64 is defined, that means there's an old ABI to be matched, and "old time_t" necessarily has type long, which is necessarily 32-bit in such a case. So it could be something like: struct sched_param { int sched_priority; int __reserved1; #if _REDIR_TIME64 long __reserved2[4]; #else long long __reserved2[4]; #endif int __reserved3; }; Note that the only reason this is needed is x32; otherwise, long would always be the right size to match the old time_t. But in the other places, it's more useful: struct rusage { #if _REDIR_TIME64 struct { long tv_sec, tv_usec; } __ru_utime32, __ru_stime32; #else struct timeval ru_utime; struct timeval ru_stime; #endif /* linux extentions, but useful */ long ru_maxrss; long ru_ixrss; long ru_idrss; long ru_isrss; long ru_minflt; long ru_majflt; long ru_nswap; long ru_inblock; long ru_oublock; long ru_msgsnd; long ru_msgrcv; long ru_nsignals; long ru_nvcsw; long ru_nivcsw; #if _REDIR_TIME64 long __reserved[8]; struct timeval ru_utime; struct timeval ru_stime; #else long __reserved[16]; #endif }; Note that using the reserved space to avoid increasing the size here isn't really useful, since the alignment requirement may change too due to introduction of 64-bit members, but it might make things more robust against ABI mismatches (likely SIGBUS instead of OOB load/store). Rich