unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella Netto via Libc-alpha <libc-alpha@sourceware.org>
To: Arnd Bergmann <arnd@arndb.de>,
	YunQiang Su <yunqiang.su@cipunited.com>,
	Xi Ruoyao <libc-alpha@sourceware.org>
Cc: syq@debian.org, aurelien@aurel32.net,
	Jiaxun Yang <jiaxun.yang@flygoat.com>,
	"Maciej W. Rozycki" <macro@orcam.me.uk>
Subject: Re: [PATCH] Rename STAT_HAS_TIME32 to KERNEL_STAT64_HAS_TIME32
Date: Mon, 7 Nov 2022 15:08:22 -0300	[thread overview]
Message-ID: <a2ceea5d-27a9-6efd-2414-37c807420630@linaro.org> (raw)
In-Reply-To: <50e745fa-0508-43f1-bd0a-cfa789239f7e@app.fastmail.com>



On 04/11/22 07:02, Arnd Bergmann wrote:
> On Fri, Nov 4, 2022, at 02:54, YunQiang Su wrote:
>> The macro name STAT_HAS_TIME32 is not so clear.
>>
>> This macro is used for some arch like MIPSn64.
>> The kernel_stat/kernel_stat64 of it has a 32bit unsigned time value.
>> Thus that has y2106 problem.
>> So we should statx to solve this problem.
> 
> I was surprised that you identified this as a y2106 problem
> rather than a y2038 problem, so I took a closer look at how this
> is handled in the kernel. I found a few interesting bits, in
> no particular order:
> 
> - mips-n64 does not have a 'stat64' interface, the kernel
>   only provides the 'stat', which has the same layout as
>   the n32 and o32 'stat64'. From the kernel perspective,
>   using KERNEL_STAT64_HAS_TIME32 seems like a misnomer,
>   but it's possible that glibc just names things differently
>   here.
> 
> - parisc64 has the same problem by only exposing a 32-bit
>   timestamp in stat, but unlike mips, it has both 'stat'
>   and 'stat64' interfaces, with both using the same layout
>   as the corresponding parisc32 syscalls. All other 64-bit
>   architectures have a 'stat' interface with 64-bit
>   timestamps, on alpha and sparc64 there is also a stat64
>   interface because the 'stat' version is limited in
>   other ways.
> 
> - There is a mix of signed and unsigned types in the
>   asm/stat.h headers, and you correctly identified mips64
>   as using an unsigned type (hence the y2106 limit),
>   however mips32 is one of the ones using a signed field,
>   and the kernel does not behave any different and
>   just relies on gcc's -fno-strict-overflow to truncate
>   a 64-bit time64_t into a 32-bit signed or unsigned
>   type either way.
> 
> - When I worked on the original time64 support for the
>   kernel, I'm sure we had discussed truncating the values
>   to the correct range on the stat interfaces, but this
>   has evidently never happened. We should probably add
>   such truncation, but we would have to decide whether to
>   truncate this to range of the declared type or more
>   sensibly to the range of the traditional time_t type.
> 
> - Note that common file systems like xfs and ext3
>   intentionally store filesystem timestamps as 'signed'
>   for compatibility with 32-bit user space, so there
>   is precedent for interpreting the values as signed
>   on 64-bit architectures when the range is limited.
> 
>         Arnd

In fact it was reported as an y2106 problem some time ago [1] and we
fixed on 2.34 [2].  And I give that STAT_HAS_TIME32 is not entirely
clear, since for glibc perspective is has multiple stat definitions.

And I agree with Arnd here, KERNEL_STAT_HAS_TIME32 would be more clear
(and glibc side it does have the kernel stat as kernel_stat).

It is good to have some confirmation that only mips has this issue,
for hppa we follow the current legacy 32 bit to use statx and ony
fallback if kernel is not present.

[1] https://sourceware.org/pipermail/libc-alpha/2021-March/123753.html
[2] https://sourceware.org/git/?p=glibc.git;a=commit;h=5b980d4809913088729982865188b754939bcd39

  reply	other threads:[~2022-11-07 18:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-04  1:54 [PATCH] Rename STAT_HAS_TIME32 to KERNEL_STAT64_HAS_TIME32 YunQiang Su
2022-11-04 10:02 ` Arnd Bergmann
2022-11-07 18:08   ` Adhemerval Zanella Netto via Libc-alpha [this message]
2022-11-07 18:24     ` Arnd Bergmann
2022-11-07 18:45       ` Adhemerval Zanella Netto via Libc-alpha
2022-11-08 11:21         ` Arnd Bergmann
2022-11-08 12:04           ` Adhemerval Zanella Netto via Libc-alpha
2022-11-17 16:47 ` Adhemerval Zanella Netto via Libc-alpha

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

  List information: https://www.gnu.org/software/libc/involved.html

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

  git send-email \
    --in-reply-to=a2ceea5d-27a9-6efd-2414-37c807420630@linaro.org \
    --to=libc-alpha@sourceware.org \
    --cc=adhemerval.zanella@linaro.org \
    --cc=arnd@arndb.de \
    --cc=aurelien@aurel32.net \
    --cc=jiaxun.yang@flygoat.com \
    --cc=macro@orcam.me.uk \
    --cc=syq@debian.org \
    --cc=yunqiang.su@cipunited.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).