On Fri, Jul 12, 2019 at 3:50 PM Laurent Vivier <laur...@vivier.eu> wrote: > Le 12/07/2019 à 15:36, Arnd Bergmann a écrit : > >> We don't do memcopy() but we set each field one by one, so the padding > >> doesn't > >> seem needed if we define correctly the user structure: > >> > >> struct target_timeval64 { > >> abi_llong tv_sec; > >> abi_long tv_usec; > >> }; > >> > >> and do something like: > >> > >> struct target_timeval64 *target_tv; > >> struct timeval *host_tv; > >> ... > >> __put_user(host_tv->tv_sec, &target_tv->tv_sec); > >> __put_user(host_tv->tv_usec, &target_tv->tv_usec); > >> ... > > > > That still seems wrong. The user application has a definition > > of 'timeval' that contains the padding, so your definition has > > to match that. > > I don't find this definition with the padding. Where it is defined? > > We are at the syscall level, so structures are the ones provided by the > target to the syscall, and they can be converted by the libc if the one > from the user space differs.
glibc will have to create a definition that matches the kernel, which uses struct __kernel_timespec { __s64 tv_sec; __s64 tv_nsec; }; As posix requires tv_nsec to be 'long', you need padding between tv_sec and tv_nsec to have a libc definition matching the kernel's binary layout. Arnd