From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/14580 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: libc-test regression/syscall-sign-extend.c Date: Thu, 15 Aug 2019 12:08:13 -0400 Message-ID: <20190815160813.GU9017@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="244381"; 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-14596-gllmg-musl=m.gmane.org@lists.openwall.com Thu Aug 15 18:08:30 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 1hyIIg-0011KZ-MN for gllmg-musl@m.gmane.org; Thu, 15 Aug 2019 18:08:30 +0200 Original-Received: (qmail 7227 invoked by uid 550); 15 Aug 2019 16:08:27 -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 7193 invoked from network); 15 Aug 2019 16:08:26 -0000 Content-Disposition: inline Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:14580 Archived-At: libc-test has one test regression/syscall-sign-extend.c whose purpose is testing an x32 bug whereby pointers passed to syscall() got sign-extended, fixed by 5f95f965e933c5b155db75520ac27c92ddbcf400 (albeit with a nasty hack). However it's using SYS_clock_gettime as the test, which means it will break on 32-bit archs when time_t changes to 64-bit and the old syscall no longer matches the libc ABI types. (It also doesn't seem to be doing anything to ensure that the pointer is "negative" in a sign-extension case; it just assumes the stack is at the top of memory. But this probably doesn't matter in practice.) I think we should find a different syscall to test that's immune to kernel/libc disagreements over types or macro values. The simplest example might be SYS_read - opening a pipe, writing a byte to it with write(), and confirming that syscall(SYS_read, ...) reads it back. Alternatively clock_gettime could be tested just to modify the pointed-to memory (e.g. by pre-filling it with 0xff) without assuming it matches struct timespec layout, but that also assumes the CLOCK_* macros map directly to syscall API. Rich