mailing list of musl libc
 help / color / mirror / code / Atom feed
* Deficiencies in kernel/compat.c for x32 timespec
@ 2014-01-12  1:42 Rich Felker
  0 siblings, 0 replies; only message in thread
From: Rich Felker @ 2014-01-12  1:42 UTC (permalink / raw)
  To: linux-api; +Cc: musl

Hi,

We're working on adding x32 support in musl libc, and ran into a
pretty major obstacle that the glibc folks seem to have glossed over:
when the kernel reads timespec structures from x32 userspace, it
treats both tv_sec and tv_nsec as 64-bit values. This requires
userspace either to be non-conforming to ISO C11 and POSIX (both of
which require tv_nsec to have type long, not an implementation-defined
signed integer type) or to wrap syscalls with ugly x32-specific
wrappers to copy the input timespec to a temporary location where it
can be sign-extended to 64-bit for passing to the kernel.

glibc has (so far) taken the former approach, documented in this bug
report: https://sourceware.org/bugzilla/show_bug.cgi?id=16437

I'd like to see this fixed on the kernel side by having
kernel/compat.c modified to copy tv_sec and tv_nsec copied separately
as 64-bit and 32-bit values, respectively, rather than using
copy_from_user for the whole structure, when COMPAT_USE_64BIT_TIME is
true.

Note that copy_to_user still works for writing timespec results back
to userspace; the excess data just goes into padding bits, and it's
always necessarily zero because output tv_nsec values are never
outside the range [0,999999999].

Rich


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-01-12  1:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-12  1:42 Deficiencies in kernel/compat.c for x32 timespec Rich Felker

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