Message ID | 20230302145732.2293756-1-adhemerval.zanella@linaro.org |
---|---|
Headers |
Return-Path: <libc-alpha-bounces+patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 11F233858035 for <patchwork@sourceware.org>; Thu, 2 Mar 2023 14:58:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 11F233858035 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1677769083; bh=HxIyg9WvqsEFh+OY06eMGJUPoDvZsvXrlNdimMdJs68=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=qLrk8tikD0VjbDWcLFNOt3eir1UsqWhYyFt98VIbX/N9eE/7HwEsETq2dWtml88/C dItgoFKP5uU/Z6HXVepTVrAg4Q62TSxcLw0vL3dPtxKF2ZXrJkQgLNFoQXJkiwnTvT +XVtsj0SXvviYZOhDQJ95T3NYSXwcX1cckmVipZQ= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oi1-x22b.google.com (mail-oi1-x22b.google.com [IPv6:2607:f8b0:4864:20::22b]) by sourceware.org (Postfix) with ESMTPS id 6A33C385840C for <libc-alpha@sourceware.org>; Thu, 2 Mar 2023 14:57:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6A33C385840C Received: by mail-oi1-x22b.google.com with SMTP id bp19so10985684oib.4 for <libc-alpha@sourceware.org>; Thu, 02 Mar 2023 06:57:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677769057; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=HxIyg9WvqsEFh+OY06eMGJUPoDvZsvXrlNdimMdJs68=; b=FLx2LU93lAHm/bRmV8a4Vjihd5WzLba2KGtqUCKzZUjlvoyLt9fJiKumQyTkXUK2Sg cqEFd6pa32Vx2CC/wrpxeYbRjxL4mCpP8u2qDxMyJgndtV1o/zf9FGqgP0T6lduAvmus AaJ/a1zKhZeiwAW9hyAbBTnTLjkCi4lYBqXgIBpDB1Ul8jsTtcpsL/5nfZD69tx/Gilq eOYlY7PRPtj3j7dXbL0FsYA+hFzc6oWCrrpMvmR4zU3K9ONNptdOHMUOod8bbxP3zuCj NJyNNZwA8LEDNKhnjkRIj9zszatnd1i54mVKYxsodXZAe3gTDyhisFYzWkvXJ/DRGkEn Fmaw== X-Gm-Message-State: AO0yUKWMSXKv/PcTNEEHPwfKER4Uh8WmoxEK5XWKHohPrJyK38f4S8Ca K1Fy93YHxtC1vw+ELOkQKC/n6LH6blCSL6Qtm60= X-Google-Smtp-Source: AK7set9AuTkpHji8bS99q3InIjTYHn3Yj25rTkk110YUyM0RfQt5MkGQ8bKxwFeWyLAIa7f5fqZNNw== X-Received: by 2002:a05:6808:305:b0:37f:acda:9668 with SMTP id i5-20020a056808030500b0037facda9668mr1297681oie.12.1677769057080; Thu, 02 Mar 2023 06:57:37 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c3:d849:953:d4b:62c6:5aa0]) by smtp.gmail.com with ESMTPSA id t26-20020a056808159a00b00383cc29d6b2sm7001652oiw.51.2023.03.02.06.57.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 06:57:36 -0800 (PST) To: libc-alpha@sourceware.org, "Andreas K . Huettel" <dilfridge@gentoo.org>, Paul Eggert <eggert@cs.ucla.edu>, Florian Weimer <fweimer@redhat.com> Subject: [PATCH v6 0/3] Fix opendir regression on some FS Date: Thu, 2 Mar 2023 11:57:29 -0300 Message-Id: <20230302145732.2293756-1-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list <libc-alpha.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/libc-alpha/> List-Post: <mailto:libc-alpha@sourceware.org> List-Help: <mailto:libc-alpha-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=subscribe> From: Adhemerval Zanella via Libc-alpha <libc-alpha@sourceware.org> Reply-To: Adhemerval Zanella <adhemerval.zanella@linaro.org> Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" <libc-alpha-bounces+patchwork=sourceware.org@sourceware.org> |
Series |
Fix opendir regression on some FS
|
|
Message
Adhemerval Zanella Netto
March 2, 2023, 2:57 p.m. UTC
Some filesystem might return a non-representable d_off on getdents call, even if there are few entries in the directories (for instance ext4, which returns an internal FS hash). This trigger issues with non-LFS readdir when it finds the first non representable entry, and also for LFS interface when used along with telldir (which return a 'long int', while d_off is potentially off64_t). For instance, arm32 dirent and io tests running on qemu-user show the following failures: FAIL: dirent/list FAIL: dirent/tst-scandir FAIL: io/tst-fts FAIL: io/tst-fts-lfs FAIL: io/tst-fts-time64 This patch changes non-LFS readdir so it clamps the d_off value if it overflows. It now uses getdents64 and maintains an internal map between d_off that can not be represented by 'long int' (telldir returned value). seekdir will then set the correct offset by using the input argument as a key to the internal list. I have checked on x86_64-linux-gnu, i686-linux-gnu, and arm-linux-gnueabihf. Changes from v5: * Use non-LFS getdents logic on non-LFS readdir. * Clamp overflow d_off values. * Removed unrequired readdir64 refactor. Changes from v4: * Allocate the telldir map an readdir, thus avoid telldir failure. * The translation buffer now uses a fixed size struct. * Fixed the condition to use the long to off64_t map. Changes from v3: * Rebase against master. * Fixed a missing lock unlock on telldir. * Renamed tst-seekdir2 to tst-opendir-nolfs and check the opendir result against getdents64. Adhemerval Zanella (3): linux: Use getdents64 on non-LFS readdir support: Add xreallocarray linux: Set internal DIR filepos as off64_t (BZ #23960, BZ #24050) include/dirent.h | 2 +- support/Makefile | 1 + support/support.h | 2 + support/xreallocarray.c | 29 ++++ sysdeps/unix/sysv/linux/Makefile | 2 + sysdeps/unix/sysv/linux/alpha/bits/dirent.h | 3 + sysdeps/unix/sysv/linux/bits/dirent.h | 4 + sysdeps/unix/sysv/linux/closedir.c | 4 + sysdeps/unix/sysv/linux/dirstream.h | 9 +- sysdeps/unix/sysv/linux/opendir.c | 3 + sysdeps/unix/sysv/linux/readdir.c | 107 +++++++++++---- sysdeps/unix/sysv/linux/readdir64.c | 11 ++ sysdeps/unix/sysv/linux/rewinddir.c | 5 + sysdeps/unix/sysv/linux/seekdir.c | 30 +++- sysdeps/unix/sysv/linux/telldir.c | 36 +++++ sysdeps/unix/sysv/linux/telldir.h | 67 +++++++++ sysdeps/unix/sysv/linux/tst-opendir-lfs.c | 2 + sysdeps/unix/sysv/linux/tst-opendir.c | 145 ++++++++++++++++++++ 18 files changed, 432 insertions(+), 30 deletions(-) create mode 100644 support/xreallocarray.c create mode 100644 sysdeps/unix/sysv/linux/telldir.h create mode 100644 sysdeps/unix/sysv/linux/tst-opendir-lfs.c create mode 100644 sysdeps/unix/sysv/linux/tst-opendir.c