From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796053922; b=29M6avM8BFi7Pzpa5oosBfjP4/QDybqn9PUwhn02QTlIqZxh1kPCaLfOOx72xakLoplK mU6E5aE/+Zpt/r9jC0x2lRoGTUHmzXLSz0qTGVw7HVBAueqlmLLi0/33N/KlViTi38vvS g3jnGMzvwrPti8U7dTPWM36jXtusHfjUiHOdhVgskR3kD7VjiUKvzXsQ9WI10wviFWfIF 8U39/yIdB6u5PL+Aokxqfw3fdmyKgx6meQTJMX5+dCNr1X9OGjFCbyLpIiJJ0gV2j1JOD v3c91J34TTWHmhGL9DzlYCql22nkJ/wYbvNnqrsKm9fXLF4WCemvgsYh2qzmQiGI2UQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796053922; h=Received:DKIM-Signature:From:Subject:Date:Message-Id:MIME-Version: Content-Type:Content-Transfer-Encoding:X-B4-Tracking:X-Change-ID:To: Cc:X-Mailer:X-Developer-Signature:X-Developer-Key; bh=cJRJCdfOqF6o2r+oUjLLNzPiJxqw4L+bzaTc3/BQxwk=; b=sz+Paq/KWEYCXxRVYgY5j/i6ykNvAaQY4WgJmW1Lhr7gA6DLyngemXSRfOCsZnR8MAvp BKxwTDTbou0kwiUWS0mWF/sLOU7OhssSizK6/5DtWRkr7K4u5l1TeBFC8XRJFO25FNAIY gwxyhnLLSLDK88Ca1DS7JsZVFOFpwl9FcpkLTGlrqiWHxEu5LC9ekZZlywXrRqRoYigBp EPH5urGFJplR4h/49HGT8IikJVE+YrvGLL4o93rZGHnsFxKwfSKc93JlEioyaLjfvjLjB Sx0OfLqjIVKEAGubjbFLU9XRG5yB+DgmIENJ/Mu8AcnvMIsdjbQwrgKs3FYVG5A0I0Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=a9MIVHFU; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E1B65606A31C; Mon, 30 Nov 2026 15:52:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=a9MIVHFU Received: by smtp.kernel.org (Postfix) with ESMTPSA id 912EF1F00898; Mon, 30 Nov 2026 15:51:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796053921; bh=cJRJCdfOqF6o2r+oUjLLNzPiJxqw4L+bzaTc3/BQxwk=; h=From:Subject:Date:To:Cc; b=a9MIVHFUVz5brh2Nu0X0oVsmzhyfFoBMu2kghgMZlMt34GoebMmqNqxeKVLsrdV3G EPe/eHRjYUEpNVHou/xQeGqDeYI2Zwg8FBl8BQBljbVxcLezBTrwUZ0fxp8Z6WnIcE ukNWcctmrp0x69l8j9yxvLVSmmurqFNRIOQTSipabvo4u/jyxjgZEo/VOo3i5SUrsa s1J0RB2nRUEgAWfdUAYLqwZOdHXkp/WeSOnggd/S8Qm2XkgLbjOxrw/5H7KJC0INMj DNZvH+Ut6U6FQhjmCdo9wkWrnrhY6L9RMUs7vzhmBa1nqafmPVIExoyRgWed0GdWkl /dIDLNMqZdP+w== From: Christian Brauner Subject: [PATCH 0/4] xattr: fix AT_FDCWD handling Date: Mon, 30 Nov 2026 16:51:36 +0100 Message-Id: <20261130-work-xattr-at_fdcwd-misc-v1-0-ab8a1727f992@kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAAAAAAAC/zXM0QrCMAyF4VcZuTalnbCiryIy2jRzVeykrW4w9 u62Ey//cPKtkDh6TnBuVoj88clPoYQ6NECjCTdG70pDK9tOqaPEeYoPXEzOEU3uB0ezw6dPhNp 21miSlvQJyvsr8uCXnb5cf53e9s6Uq1cX1iRGG02gsZ6qLHZZ/GVRZVF3sG1fRLkxFqwAAAA= X-Change-ID: 20261130-work-xattr-at_fdcwd-misc-7b6ba7c0bc79 To: linux-fsdevel@vger.kernel.org Cc: Andreas Gruenbacher , Jan Kara , Alexander Viro , =?utf-8?q?Christian_G=C3=B6ttsche?= , linux-kernel@vger.kernel.org, "Christian Brauner (Amutable)" , stable@vger.kernel.org X-Mailer: b4 0.17-dev-04696 X-Developer-Signature: v=1; a=openpgp-sha256; l=2164; i=brauner@kernel.org; h=from:subject:message-id; bh=fqOWB2P6/whwtwPRzlHrMju105PdSx91eQsIA/0oKNM=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMWTzzp7+d1lNg+SqR8/n3vrHvVCEb8IBVumnnw/Hyexjy tGqCrYO7ShlYRDjYpAVU2RxaDcJl1vOU7HZKFMDZg4rE8gQBi5OAZjI02+MDGcOtm85ujh1WkDh l/er7i27YdM//8KHnRW/5Wepmh39WpjO8N8zfCMTZ73czWMHG3f784Vf5bT/VaQVktU/UUM79Mj jIH4A X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Two bugs in the AT_FDCWD handling of the xattr system calls while reviewing Andreas' patch that lets *xattrat() accept O_PATH file descriptors (cf. [1]) surfaced. Both predate that patch: * fsetxattr() and fgetxattr() operate on the current working directory when passed AT_FDCWD instead of failing with EBADF. They're implemented on top of the *xattrat() helpers and since commit f520bed25d17 ("fs/xattr: Fix handling of AT_FDCWD in setxattrat(2) and getxattrat(2)") those resolve AT_FDCWD with an empty path to the current working directory. That's a regression since v6.15. * listxattrat() and removexattrat() fail with EBADF when called with AT_FDCWD, an empty path and AT_EMPTY_PATH while setxattrat() and getxattrat() operate on the current working directory. They never got the same fix. The f*xattr() system calls now resolve the file descriptor themselves like fchmod() and fchown() do instead of going through the *xattrat() helpers. That fixes the first bug and leaves the helpers to the path based system calls. With this Andreas' patch doesn't need the fd_maybe_raw class anymore as the helpers can simply use CLASS(fd_raw). I've reworked it accordingly and it's the last patch in this series. The new selftest covers both bugs. [1]: https://lore.kernel.org/20260722151023.1308069-1-agruenba@redhat.com Signed-off-by: Christian Brauner (Amutable) --- Andreas Gruenbacher (1): xattrat: accept empty O_PATH file descriptors Christian Brauner (3): xattr: don't route f*xattr() through the *xattrat() helpers xattr: let listxattrat() and removexattrat() handle AT_FDCWD selftests/xattr: add AT_FDCWD tests fs/xattr.c | 73 +++++- .../testing/selftests/filesystems/xattr/.gitignore | 1 + tools/testing/selftests/filesystems/xattr/Makefile | 3 +- .../selftests/filesystems/xattr/xattr_fdcwd_test.c | 265 +++++++++++++++++++++ 4 files changed, 330 insertions(+), 12 deletions(-) --- base-commit: 4a3b05a191ed84099d4ffaff7d29f73f08d27408 change-id: 20261130-work-xattr-at_fdcwd-misc-7b6ba7c0bc79