From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id F3E32386F420; Fri, 2 Oct 2020 09:36:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F3E32386F420 From: "danny.milo at gmail dot com" To: glibc-bugs@sourceware.org Subject: [Bug libc/23960] [2.28 Regression]: New getdents{64} implementation breaks qemu-user Date: Fri, 02 Oct 2020 09:36:03 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: libc X-Bugzilla-Version: 2.28 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: danny.milo at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: security- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: glibc-bugs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-bugs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Oct 2020 09:36:04 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D23960 --- Comment #59 from Danny Milosavljevic --- (In reply to Adhemerval Zanella from comment #32) > I am not against in reverting back to use SYS_getdents for getdents64 SYS_getdents has 32 bit slots, including d_off, in the result and thus the kernel cannot tell you the truth in the result. Having the kernel paper ov= er this seems unwise--this would be/is basically the kernel lying to you. As = with all lies, the kernel then has to keep some kind of table which lies it told= to whom and be consistent with them. Why do that? > although it is a subpar resolution for a kernel issue. Newer architectur= es > with mixed 32 and 64 bits support will continue to be broken without a > proper kernel fix since they use SYS_getdents64 for getdents. The kernel is the wrong place to work around this. glibc should be using 64 bit struct dirent so it can actually handle the truth. > What I think we should do is: >=20 > 1. *Deprecate* non-LFS usage in a multi-step way as discussed in > libc-alpha [1]. We will need to take care of the issue brought by Joseph, > but it will mean eventually the non-LFS interfaces will be just provided = as > compatibility symbols. I agree. > 2. Push to distro on 32-bits to *stop* building packages in non-LFS mode > as default. Some distro already gets this right, but it seems some still > lacking support. For that to happen, please make glibc at least emit a warning--although wit= h a problem this bad, I'd prefer an error--if _FILE_OFFSET_BITS !=3D 64 and SIZEOF_LONG < 8 and readdir is used. I use this in dirent.h: #ifndef _LIBC #if __SIZEOF_LONG__ < 8 #ifndef __USE_FILE_OFFSET64 #if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS =3D=3D 32 #warning \"Using -D_FILE_OFFSET_BITS=3D32 and using readdir is a bad idea, = see \" #else #undef readdir #define readdir @READDIR_WITHOUT_FILE_OFFSET64_IS_A_REALLY_BAD_IDEA@ #endif #endif #endif #endif It's much better to find problems this way than to have programs fail at ra= ndom times at runtime depending on file system internals. Or use gcc's "deprecated" attribute on readdir, with a message, in order to= at least warn. But, really, does this sound like something harmless enough to only warn? It does not to me. > 3. Continue to push kernel developers to provide a correct fix for this > issue.=20 We shouldn't do that in the kernel (see beginning of this text). It's impossible to store a 64 bit result into a 32 bit slot. Also, if you call SYS_getdents64, you should expect a 64 bit result. It's = in the name. Please don't use SYS_getdents. Just please mandate LFS instead. This shou= ld have been done long (decades) ago. --=20 You are receiving this mail because: You are on the CC list for the bug.=