From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id C468A1F4B4 for ; Wed, 14 Oct 2020 13:15:51 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0E0D33943407; Wed, 14 Oct 2020 13:15:51 +0000 (GMT) Received: from mail-out.m-online.net (mail-out.m-online.net [IPv6:2001:a60:0:28:0:1:25:1]) by sourceware.org (Postfix) with ESMTPS id B656F38708B7 for ; Wed, 14 Oct 2020 13:15:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B656F38708B7 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: sourceware.org; spf=none smtp.mailfrom=lukma@denx.de Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4CBCb72jwrz1sKJY; Wed, 14 Oct 2020 15:15:47 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4CBCb72DzZz1qsnT; Wed, 14 Oct 2020 15:15:47 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id Vm5OU5QdO9O1; Wed, 14 Oct 2020 15:15:45 +0200 (CEST) X-Auth-Info: A1gzjBbYEaw0a8tLPqOFa7Ypgz4bMRzFXsvYidrnjGk= Received: from jawa (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Wed, 14 Oct 2020 15:15:45 +0200 (CEST) Date: Wed, 14 Oct 2020 15:15:30 +0200 From: Lukasz Majewski To: Adhemerval Zanella Subject: Re: [PATCH 15/16] linux: Add {f}stat{at} y2038 support Message-ID: <20201014151530.3a033362@jawa> In-Reply-To: <20201013234037.40ae39da@jawa> References: <20200723194641.1949404-1-adhemerval.zanella@linaro.org> <20200723194641.1949404-16-adhemerval.zanella@linaro.org> <20201006114802.1450d29b@jawa> <99a35800-d0ed-5561-b36b-4416f041ab5d@linaro.org> <331ab260-ef82-8e94-7148-5522fdb6e195@linaro.org> <20201013155838.0e61252b@jawa> <250a2b16-f06a-7215-bb8a-445511a4976f@linaro.org> <20201013234037.40ae39da@jawa> Organization: denx.de X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; boundary="Sig_/zd3vLO.oZAvk/_uQfsFPfO4"; protocol="application/pgp-signature" X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: libc-alpha@sourceware.org, Alistair Francis Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" --Sig_/zd3vLO.oZAvk/_uQfsFPfO4 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Dear Community, > Hi Adhemerval, >=20 > > On 13/10/2020 10:58, Lukasz Majewski wrote: =20 > > > Hi Adhemerval, > > > =20 > > >> On 07/10/2020 09:52, Adhemerval Zanella wrote: =20 > > >>> > > >>> > > >>> On 06/10/2020 06:48, Lukasz Majewski wrote: =20 > > >>>> Hi Adhemerval, > > >>>> =20 > > >>>>> A new struct __stat{64}_t64 type is added with the required > > >>>>> __timespec64 time definition. Both non-LFS and LFS support > > >>>>> were done with an extra __NR_statx call plus a conversion to > > >>>>> the new __stat{64}_t64 type. The statx call is done only for > > >>>>> architectures with support for 32-bit time_t ABI. > > >>>>> > > >>>>> Internally some extra routines to copy from/to struct stat{64} > > >>>>> to struct __stat{64} used on multiple implementations (stat, > > >>>>> fstat, lstat, and fstatat) are added on a extra file > > >>>>> (stat_t64_cp.c). Aslo some extra routines to copy from statx > > >>>>> to __stat{64} is added on statx_cp.c. > > >>>>> > > >>>>> Checked with a build for all affected ABIs. I also checked on > > >>>>> x86_64, i686, powerpc, powerpc64le, sparcv9, sparc64, s390, > > >>>>> and s390x. =20 > > >>>> > > >>>> When do you plan to pull this patch set to -master? > > >>>> Those patches have been available for review on the mailing > > >>>> list for more than two months now. =20 > > >>> > > >>> Hi Lukasz, thanks to remind me. I will rebase against master and > > >>> run some regressions tests against some platforms and push it. > > >>> =20 > > >> > > >> One required change with the rebase is adapt the riscv32 ABI to > > >> exclude the __{f,l}xstat{at} symbol and replace with proper > > >> {f,l}stat ones. It is possible because the new ABI was added on > > >> current development branch, however one minor inconvenient is the > > >> toolchain need to be rebuild with a updated glibc branch to avoid > > >> linking failures with libstd++ (which uses __{f,l}xstat{at}). > > >> =20 > > >=20 > > > I'm not sure if this is related, but on my ARMv7 (32 bit) sandbox > > > there is an issue with fstat accesses to files. > > >=20 > > > When I try to run a program build against newest glibc (installed > > > in /opt/lib) I do see issues with {f}stat on other libraries (e.g. > > > /opt/lib/librt.so). To be more specific I do experience the > > > EOVERFLOW error: > > >=20 > > > error while loading shared libraries: librt.so.1: cannot stat > > > shared object: Error 75 > > >=20 > > > The "base" glibc is 2.28 (installed in /lib). The glibc under test > > > is the newest master installed in /opt/lib. > > >=20 > > > I'm now investigating this issue. =20 > >=20 > > I am not sure what it might be based on these information, could you > > provide a strace so we can pinpoint what might the issue? =20 >=20 > Things are getting more and more interesting. >=20 > Let's consider the /opt/lib/librt.so.1 >=20 > After qemu boot: >=20 > root@y2038arm:~# stat /opt/lib/librt.so.1 > File: /opt/lib/librt.so.1 -> librt-2.32.9000.so > Size: 18 Blocks: 0 IO Block: 4096 symbolic > link Device: b300h/45824d Inode: 17490 Links: 1 > Access: (0777/lrwxrwxrwx) Uid: ( 0/ root) Gid: ( 0/ > root) Access: 2020-10-13 23:14:56.800000000 +0000 ----> OK > Modify: 2020-10-13 23:14:52.770000000 +0000 > Change: 2020-10-13 23:14:52.770000000 +0000 >=20 > Then I do run gdb (which was build with 2.28 glibc as a base and gcc > 8.1, which uses the same library): >=20 > gdb test_y2038: > ... > (gdb) run > Starting program: /usr/bin/test_y2038 > /usr/bin/test_y2038: error while loading shared libraries: librt.so.1: > cannot stat shared object: Error 75 [Inferior 1 (process 1045) exited > with code 0177] >=20 > So I've accessed the librt.so.1 with some old - i.e. 2.28 ABI - now: >=20 > root@y2038arm:~# stat /opt/lib/librt.so.1 > File: /opt/lib/librt.so.1 -> librt-2.32.9000.so > Size: 18 Blocks: 0 IO Block: 4096 symbolic > link Device: b300h/45824d Inode: 17490 Links: 1 > Access: (0777/lrwxrwxrwx) Uid: ( 0/ root) Gid: ( 0/ > root) Access: 1901-12-13 20:46:33.625721000 +0000 ----> Overflow > Modify: 2020-10-13 23:14:52.770000000 +0000 > Change: 2020-10-13 23:14:52.770000000 +0000 >=20 > root@y2038arm:~# strace -v -Tf -e trace=3Dfile test_y2038 >=20 > openat(AT_FDCWD, "/opt/lib/librt.so.1", > O_RDONLY|O_LARGEFILE|O_CLOEXEC) =3D 3 <0.000409> statx(3, "", > AT_STATX_SYNC_AS_STAT|AT_NO_AUTOMOUNT|AT_EMPTY_PATH, > STATX_BASIC_STATS, {stx_mask=3DSTATX_ALL, stx_blksize=3D4096, > stx_attributes=3D0, stx_nlink=3D1, stx_uid=3D0, stx_gid=3D0, > stx_mode=3DS_IFREG|0755, stx_ino=3D17487, stx_size=3D425008, stx_blocks= =3D832, > stx_attributes_mask=3DSTATX_ATTR_COMPRESSED|STATX_ATTR_IMMUTABLE|STATX_AT= TR_APPEND|STATX_ATTR_NODUMP|STATX_ATTR_ENCRYPTED, > stx_atime=3D{tv_sec=3D1602625090, tv_nsec=3D600000000} /* > 2020-10-13T21:38:10.600000000+0000 */, stx_btime=3D{tv_sec=3D1602622592, > tv_nsec=3D0} /* 2020-10-13T20:56:32+0000 */, > stx_ctime=3D{tv_sec=3D2147484284, tv_nsec=3D335721000}, > stx_mtime=3D{tv_sec=3D2147484263, tv_nsec=3D545721000}, stx_rdev_major=3D= 0, > stx_rdev_minor=3D0, stx_dev_major=3D179, stx_dev_minor=3D0}) =3D 0 <0.000= 494> > test_y2038: error while loading shared libraries: librt.so.1: cannot > stat shared object: Error 75 +++ exited with 127 +++ >=20 >=20 > Here the ctime and mtime are wrong - i.e. overflowed. >=20 > The system date is not changed: > root@y2038arm:~# date > Tue Oct 13 21:40:02 UTC 2020 > root@y2038arm:~# date +%s > 1602625224 >=20 > I will continue investigation tomorrow... And now the penny has dropped... The issue was that: 1. Adhemerval has added extra checks for overflowing the time in {f}stat{at} patches - this is obviously good :-) 2. In my test system - I've been using "time" syscall (glibc function) to get the seconds after epoch. This was not yet [*] converted to support 64 bit time. 3. Some tests (like clock_gettime / clock_settime) require time modifications after Y2038. Broken time() caused wrong data after casting from __time_t to __time64_t and the proper time couldn't be restored. 4. As a result - the date was wrong during the following tests execution and {mac}time for external files (like librt.so.1, libgcc_s.so) was set to wrong value. 5. Each subsequent call of {fl}stat{64} returned error due to date overflow check. Fix: Convert time to support 64 bit time. [*] I will send patches after build-many-glibcs.py and xcheck finish. >=20 > >=20 > > The arm-linux-gnueabihf testing I did was on a aarch64 kernel > > (4.12.13). Besides the make check without regression, I could run > > system binaries with ./testrun.sh. > >=20 > > I will check on a different kernel/system with a 32-bit kernel. > > =20 >=20 >=20 >=20 >=20 > Best regards, >=20 > Lukasz Majewski >=20 > -- >=20 > DENX Software Engineering GmbH, Managing Director: Wolfgang Denk > HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany > Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: > lukma@denx.de Best regards, Lukasz Majewski -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de --Sig_/zd3vLO.oZAvk/_uQfsFPfO4 Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEgAyFJ+N6uu6+XupJAR8vZIA0zr0FAl+G+fIACgkQAR8vZIA0 zr2NuQf/cYP7ScISwDGHIEJ/MfRlgZDsyDl2G51m5a+kOpicqKCyOltoARnnaAPe 3lwrmnorKvMXb2HRM6CTqAbCy83Vl8aBE9Go0N82jFMDd9CvEjPBV/m9J0M2YSU9 hAn6Che2P3IqQ509kPbie1i6A6fCubiuHv/tFaHEDiN9MeEGhdTp9P3TOBWUxCPc g/pSo5JTO++s4O6y/huAdNHU9AufutVtf/PBQfwzoZj/Ddp4ScY90Hh7reGZSfSz hzH7bhrs9L1o3F4Y5JAgW9LDL+Of3c0sUw41aZNTSbpUG5ro4KVA1YIIAtlyuP2+ IzEcshUlcN4iRH4jWXSd61Vyl852TA== =txEJ -----END PGP SIGNATURE----- --Sig_/zd3vLO.oZAvk/_uQfsFPfO4--