From patchwork Tue Nov 26 15:54:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13886126 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6AF001D0DEC for ; Tue, 26 Nov 2024 15:54:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732636493; cv=none; b=r1qR9z/bhlItkkeTcRggsAIwoJsmdMXbNgM/O48+2XqwFfj6ya3wdYmgCXFAOR+tnWBPVvGzmL78DlLAgOCFrfiQeM8CvCI6L93CL7p/HUNcUPPR65BUWdTRkMgTlT6yBJ3XeQNrd6Eef81ql5n1qjmV2Ncx0XqmqzxjTu9cp0Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732636493; c=relaxed/simple; bh=8e8Q8/YtSaVAdENoI1U6mbj2xfawBpxlEtPJSKzh+B0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=b+SIfuixF2VxICbPWfpEbQrBcia5RoMR8D8IVxIhul0TEQMmwHtiRX65mBq5NyZqjv83Lh72TjIq071Lx+cprjQ5k+I/NueX4i3e18Nn880d8miKh9NJ+R2luO4gzs5K8xuSRBGtTOlu5Ze0Q6FIJzOKjJGZr3Ak+bVmGFIO3zw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lxVVjKpe; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lxVVjKpe" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2CC9BC4CECF; Tue, 26 Nov 2024 15:54:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732636493; bh=8e8Q8/YtSaVAdENoI1U6mbj2xfawBpxlEtPJSKzh+B0=; h=From:To:Cc:Subject:Date:From; b=lxVVjKpeNBqXWucQV4DimWxB2ihN/uWsYVVnf1r99Fn0ggsevGLLNxDX/llUnuVB5 Y2Cn5AyufHhlE+IIlXMUno6OzZAIci1PuRgIZw7vwhALOa4zfu+QyNiolbbWCiogh8 Urgu0egXgOwkxTm6Fupx1V/kWvD3hDOvArR/H31CPueV4/XaMxm2yEdwI1DjrPoG6a Ac/q1VqjgtgaW/Tl6hm+EbDJ+CHGHTBxc9WpvOuTXXhiwKTYyP883HKKmsByFI0bIs tv3GkuEdQj0OnhSb36uIfZJvAm0uDWo0YSEwC2qNUbZGdPZ9tgl6F3hg0aDZlEOpC+ L1PC121YliNyw== From: cel@kernel.org To: Hugh Dickens , Christian Brauner , Al Viro Cc: , , yukuai3@huawei.com, yangerkun@huaweicloud.com, Chuck Lever Subject: [RFC PATCH v2 0/5] Improve simple directory offset wrap behavior Date: Tue, 26 Nov 2024 10:54:39 -0500 Message-ID: <20241126155444.2556-1-cel@kernel.org> X-Mailer: git-send-email 2.47.0 Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Chuck Lever This series attempts to narrow some gaps in the current tmpfs directory offset mechanism that relate to misbehaviors reported by Yu Kuai and Yang Erkun . This series replaces the v1 mechanism I posted last week. It reverts offset_readdir() to use the directory's d_children list, instead of its mtree, for finding the next entry, as readdir did before v6.6. Directory offset values continue to be allocated via an mtree. The purpose of this change is to enable readdir results to continue to appear after a directory offset/cookie value wrap, while not regressing generic/736. That should enable this fix to be backported (manually) to v6.6 to address CVE-2024-46701. These are still a little unpolished. I expect review to find opportunities for further code reuse. These patches pass xfstests except for generic/013, generic/637, and generic/650. There appears to be a problem with WHITEOUT renames which I am still looking into. The series has been pushed to: https://git.kernel.org/pub/scm/linux/kernel/git/cel/linux.git/log/?h=tmpfs-fixes Chuck Lever (5): libfs: Return ENOSPC when the directory offset range is exhausted libfs: Check dentry before locking in simple_offset_empty() Revert "libfs: fix infinite directory reads for offset dir" libfs: Refactor end-of-directory detection for simple_offset directories libfs: Refactor offset_iterate_dir() fs/libfs.c | 145 ++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 109 insertions(+), 36 deletions(-)