public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: Stafford Horne <shorne@gmail.com>,
	GLIBC patches <libc-alpha@sourceware.org>
Subject: Re: [PATCH] timex: Use 64-bit fields on 32-bit TIMESIZE=64 systems
Date: Mon, 18 Oct 2021 14:29:53 -0300	[thread overview]
Message-ID: <b0e156ed-7197-95e9-d15e-c97294bbdc90@linaro.org> (raw)
In-Reply-To: <20211014211741.2615945-1-shorne@gmail.com>



On 14/10/2021 18:17, Stafford Horne via Libc-alpha wrote:
> This was found when testing the OpenRISC port I am working on.  These
> two tests fail with SIGSEGV:
> 
>   FAIL: misc/tst-ntp_gettime
>   FAIL: misc/tst-ntp_gettimex
> 
> This was found to be due to the kernel overwriting the stack space
> allocated by the timex structure.  The reason for the overwrite being
> that the kernel timex has 64-bit fields and user space code only
> allocates enough stack space for timex with 32-bit fields.
> 
> On 32-bit systems with TIMESIZE=64 __USE_TIME_BITS64 is not defined.
> This causes the timex structure to use 32-bit fields with type
> __syscall_slong_t.> 
> This patch adjusts the ifdef condition to allow 32-bit systems with
> TIMESIZE=64 to use the 64-bit long long timex definition.

Why is this not an issue for arc or riscv32? Both are 32-bit architectures
have default 64-bit time_t.

This changes all current 32-bit architectures with default 64-bit time_t
and I not sure if this break something (or if the interface is already
broken).  I will try to check on riscv32.


> ---
>  sysdeps/unix/sysv/linux/bits/timex.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sysdeps/unix/sysv/linux/bits/timex.h b/sysdeps/unix/sysv/linux/bits/timex.h
> index ee37694e8f..4a5db6deca 100644
> --- a/sysdeps/unix/sysv/linux/bits/timex.h
> +++ b/sysdeps/unix/sysv/linux/bits/timex.h
> @@ -25,7 +25,7 @@
>  
>  struct timex
>  {
> -# ifdef __USE_TIME_BITS64
> +# if defined __USE_TIME_BITS64 || (__TIMESIZE == 64 && __WORDSIZE == 32)
>    unsigned int modes;          /* mode selector */
>    int :32;                     /* pad */
>    long long offset;            /* time offset (usec) */
> 

  reply	other threads:[~2021-10-18 17:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-14 21:17 Stafford Horne
2021-10-18 17:29 ` Adhemerval Zanella [this message]
2021-10-18 18:55   ` Adhemerval Zanella
2021-10-18 19:35     ` Joseph Myers
2021-10-18 20:01       ` Adhemerval Zanella

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b0e156ed-7197-95e9-d15e-c97294bbdc90@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=libc-alpha@sourceware.org \
    --cc=shorne@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).