mailing list of musl libc
 help / color / mirror / code / Atom feed
* libc-test regression/syscall-sign-extend.c
@ 2019-08-15 16:08 Rich Felker
  2019-10-31  1:48 ` Szabolcs Nagy
  0 siblings, 1 reply; 2+ messages in thread
From: Rich Felker @ 2019-08-15 16:08 UTC (permalink / raw)
  To: musl

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: libc-test regression/syscall-sign-extend.c
  2019-08-15 16:08 libc-test regression/syscall-sign-extend.c Rich Felker
@ 2019-10-31  1:48 ` Szabolcs Nagy
  0 siblings, 0 replies; 2+ messages in thread
From: Szabolcs Nagy @ 2019-10-31  1:48 UTC (permalink / raw)
  To: musl

* Rich Felker <dalias@libc.org> [2019-08-15 12:08:13 -0400]:
> 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.

ok changed the test to use SYS_read.
thanks.

> 
> 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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-10-31  1:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-15 16:08 libc-test regression/syscall-sign-extend.c Rich Felker
2019-10-31  1:48 ` Szabolcs Nagy

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).