From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id eENMJe7ibF9AMQAA0tVLHw (envelope-from ) for ; Thu, 24 Sep 2020 18:18:22 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id iCYcIe7ibF8hawAAB5/wlQ (envelope-from ) for ; Thu, 24 Sep 2020 18:18:22 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 013A1940224 for ; Thu, 24 Sep 2020 18:18:21 +0000 (UTC) Received: from localhost ([::1]:33050 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLVoy-0005LN-S5 for larch@yhetil.org; Thu, 24 Sep 2020 14:18:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35286) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLVog-0005K2-0g for guix-patches@gnu.org; Thu, 24 Sep 2020 14:18:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:58364) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kLVof-00061I-NI for guix-patches@gnu.org; Thu, 24 Sep 2020 14:18:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kLVof-0003mr-IA for guix-patches@gnu.org; Thu, 24 Sep 2020 14:18:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#43591] [PATCH core-updates] gnu: glibc-final: Catch all cases of a glibc user not requesting 64-bit offsets and then using readdir. Resent-From: Marius Bakke Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 24 Sep 2020 18:18:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43591 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Danny Milosavljevic , 43591@debbugs.gnu.org Cc: Danny Milosavljevic Received: via spool by 43591-submit@debbugs.gnu.org id=B43591.160097144814520 (code B ref 43591); Thu, 24 Sep 2020 18:18:01 +0000 Received: (at 43591) by debbugs.gnu.org; 24 Sep 2020 18:17:28 +0000 Received: from localhost ([127.0.0.1]:41677 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLVo7-0003m8-Sq for submit@debbugs.gnu.org; Thu, 24 Sep 2020 14:17:28 -0400 Received: from eggs.gnu.org ([209.51.188.92]:56592) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLVo6-0003lw-IU for 43591@debbugs.gnu.org; Thu, 24 Sep 2020 14:17:27 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:38398) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLVnz-0005yO-6U; Thu, 24 Sep 2020 14:17:19 -0400 Received: from [195.18.146.5] (port=49622 helo=localhost) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kLVnw-00005K-Hi; Thu, 24 Sep 2020 14:17:17 -0400 From: Marius Bakke In-Reply-To: <20200924141211.21649-1-dannym@scratchpost.org> References: <20200924141211.21649-1-dannym@scratchpost.org> Date: Thu, 24 Sep 2020 20:17:14 +0200 Message-ID: <87363759at.fsf@gnu.org> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -3.3 (---) X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Spam-Score: -3.61 X-TUID: 6mT1Jqi8loql --=-=-= Content-Type: text/plain Danny Milosavljevic writes: > + ;; QEMU transparent emulation is in somewhat of a pickle sometimes. > + ;; There is no support in the kernel syscalls of specifying what > + ;; kind of userspace you are emulating. Some parts of the > + ;; structures passed back-and-forth between kernel and guest > + ;; userspace can change size (including size of individual fields). > + ;; > + ;; One of the affected structures is "struct dirent". The ext4 > + ;; file system puts a 64 bit hash into "d_off" on the kernel side. > + ;; If the guest system's glibc is 32 bit it is going to be very > + ;; confused (it does check whether d_off fits into the structure > + ;; it gives back to the user--and it doesn't fit. Hence readdir > + ;; fails). > + ;; This manifests itself in simple directory reads not working > + ;; anymore in parts of cmake, for example. Note that for CMake in particular, this problem will be fixed in 3.19: https://gitlab.kitware.com/cmake/cmake/-/issues/20568 As mentioned in that issue, and which this patch states on no uncertain terms, a workaround is to use -D_FILE_OFFSET_BITS=64 on 32-bit platforms. > + ;; > + ;; There is a very simple and complete way to avoid this problem: > + ;; Just always use 64 bit offsets in user space programs (also > + ;; on 32 bit machines). > + ;; > + ;; Note: We might want to avoid using 64 bit when bootstrapping > + ;; using mescc (since mescc doesn't directly support 64 bit > + ;; values)--but then bootstrapping has to be done on a > + ;; file system other than ext4, or on ext4 with the feature > + ;; "dir_index" disabled. > + ;; > + ;; The change below does not affect 64 bit users. > + ;; > + ;; See . > + (let ((port (open-file "include/dirent.h" "a"))) > + (display " > +#if __SIZEOF_LONG__ < 8 > +#ifndef __USE_FILE_OFFSET64 > +#undef readdir > +#define readdir @READDIR_WITHOUT_FILE_OFFSET64_IS_A_REALLY_BAD_IDEA@ Won't this break _everything_ that uses readdir() without 64-bit offsets? Or does that @@ string get substituted by the glibc build system somehow. > +#endif > +#endif > +" port) > + (close-port port)) > + ;; This file includes and thus checks sanity already. > + ;; TODO: Check dirent/scandir-tail.c, dirent/scandir64-tail.c. > + (substitute* "posix/glob.c" > + (("(#[ ]*define[ ][ ]*readdir)") " > +#undef readdir > +#define readdir")) Can you file a bug report upstream about the duplicate definition(s)? Enforcing this restriction in glibc feels rather sledgehammer-y. Would it make sense to introduce a GCC warning instead? I'm sure there are legitimate uses of smaller file offsets (i.e. embedded). A GCC warning will still break -Werror, but that's a lot more manageable than breaking almost every use of readdir() on 32-bit platforms. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEu7At3yzq9qgNHeZDoqBt8qM6VPoFAl9s4qoACgkQoqBt8qM6 VPov8QgA0GUVhmZGcGVhQFYtqMUxfLovkbh6OJXKx8eoByy+lNBK1x3cxsukQoob wRA012R82QMpfOpDTSuKh3WSJDnj2c8x1ZRMKNNjQ3uVd1wvahgeuySdU9zSJTm8 WkM9TVVnhEj80OL94Zqzx7R5guXW/GjMZCmMuS3WiflEwsRf25mtifTIP0QcXoKf /6NkM2oHQSBmMMimRFmRBcRhW8r+sVK9Mkrbz4OWxiiwRKe7LZoFLRszRkRGtCux 6hWkhxQeqizCuUoXdRDHTXT7kp6xSOEYBK1trMNGLNf+92UUjrhntgyNE573cmEy nKWxW7qJJkx8AOjqubL5NAqf60TW7w== =Joa2 -----END PGP SIGNATURE----- --=-=-=--