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 EAmBFXipbF+ZQQAA0tVLHw (envelope-from ) for ; Thu, 24 Sep 2020 14:13:12 +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 YHc/EXipbF+rOwAAB5/wlQ (envelope-from ) for ; Thu, 24 Sep 2020 14:13:12 +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 D29F29406A2 for ; Thu, 24 Sep 2020 14:13:11 +0000 (UTC) Received: from localhost ([::1]:51752 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLRzi-00018S-9j for larch@yhetil.org; Thu, 24 Sep 2020 10:13:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54592) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLRza-00018G-UC for guix-patches@gnu.org; Thu, 24 Sep 2020 10:13:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:57807) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kLRza-0001kL-L4 for guix-patches@gnu.org; Thu, 24 Sep 2020 10:13:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kLRza-0001eW-FE for guix-patches@gnu.org; Thu, 24 Sep 2020 10:13:02 -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: Danny Milosavljevic Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 24 Sep 2020 14:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 43591 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 43591@debbugs.gnu.org Cc: Danny Milosavljevic X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16009567626322 (code B ref -1); Thu, 24 Sep 2020 14:13:02 +0000 Received: (at submit) by debbugs.gnu.org; 24 Sep 2020 14:12:42 +0000 Received: from localhost ([127.0.0.1]:41120 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLRzF-0001dt-L1 for submit@debbugs.gnu.org; Thu, 24 Sep 2020 10:12:41 -0400 Received: from lists.gnu.org ([209.51.188.17]:45812) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLRzD-0001dj-8g for submit@debbugs.gnu.org; Thu, 24 Sep 2020 10:12:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54508) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLRzD-0000qw-1H for guix-patches@gnu.org; Thu, 24 Sep 2020 10:12:39 -0400 Received: from dd26836.kasserver.com ([85.13.145.193]:58664) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLRzA-0001i1-F6 for guix-patches@gnu.org; Thu, 24 Sep 2020 10:12:38 -0400 Received: from dayas.lan (80-110-126-103.cgn.dynamic.surfer.at [80.110.126.103]) by dd26836.kasserver.com (Postfix) with ESMTPSA id 062F3336819A; Thu, 24 Sep 2020 16:12:33 +0200 (CEST) From: Danny Milosavljevic Date: Thu, 24 Sep 2020 16:12:11 +0200 Message-Id: <20200924141211.21649-1-dannym@scratchpost.org> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Tags: patch Content-Transfer-Encoding: 8bit Received-SPF: none client-ip=85.13.145.193; envelope-from=dannym@scratchpost.org; helo=dd26836.kasserver.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/24 09:45:53 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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=none; 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.99 X-TUID: uZIvu16EcoQ1 * gnu/packages/commencement.scm (glibc-final): Catch all cases of a glibc user not requesting 64-bit offsets and then using readdir. --- gnu/packages/commencement.scm | 52 ++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/gnu/packages/commencement.scm b/gnu/packages/commencement.scm index e5a4caa95c..5a62c9df3a 100644 --- a/gnu/packages/commencement.scm +++ b/gnu/packages/commencement.scm @@ -3462,7 +3462,57 @@ exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~a/~a \"$@\"~%" ,hurd-headers-boot0) '()) ,@(package-outputs glibc-final-with-bootstrap-bash)) - ,@(package-arguments glibc-final-with-bootstrap-bash))))) + ,@(substitute-keyword-arguments + (package-arguments glibc-final-with-bootstrap-bash) + ((#:phases phases) + `(modify-phases ,phases + (add-after 'unpack 'patch-dirent + (lambda* (#:key outputs #:allow-other-keys) + ;; 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. + ;; + ;; 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@ +#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")) + #t))))))))) (define/system-dependent gcc-boot0-wrapped ;; Make the cross-tools GCC-BOOT0 and BINUTILS-BOOT0 available under the