mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christian Brauner <brauner@kernel.org>
To: linux-fsdevel@vger.kernel.org
Cc: "Andreas Gruenbacher" <agruenba@redhat.com>,
	"Jan Kara" <jack@suse.cz>,
	"Alexander Viro" <viro@zeniv.linux.org.uk>,
	"Christian Göttsche" <cgzones@googlemail.com>,
	linux-kernel@vger.kernel.org,
	"Christian Brauner (Amutable)" <brauner@kernel.org>
Subject: [PATCH 2/4] xattr: let listxattrat() and removexattrat() handle AT_FDCWD
Date: Mon, 30 Nov 2026 16:51:38 +0100	[thread overview]
Message-ID: <20261130-work-xattr-at_fdcwd-misc-v1-2-ab8a1727f992@kernel.org> (raw)
In-Reply-To: <20261130-work-xattr-at_fdcwd-misc-v1-0-ab8a1727f992@kernel.org>

Commit f520bed25d17 ("fs/xattr: Fix handling of AT_FDCWD in
setxattrat(2) and getxattrat(2)") made setxattrat() and getxattrat()
operate on the current working directory when called with AT_FDCWD, an
empty path and AT_EMPTY_PATH, the same way fstatat() does. listxattrat()
and removexattrat() didn't get the same fix and still fail with EBADF.
Do what setxattrat() and getxattrat() do.

Fixes: 6140be90ec70 ("fs/xattr: add *at family syscalls")
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
 fs/xattr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/xattr.c b/fs/xattr.c
index 8e7cceeb0d23c..0c59dfcbe6958 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -1026,7 +1026,7 @@ static ssize_t path_listxattrat(int dfd, const char __user *pathname,
 		return -EINVAL;
 
 	CLASS(filename_maybe_null, filename)(pathname, at_flags);
-	if (!filename) {
+	if (!filename && dfd >= 0) {
 		CLASS(fd, f)(dfd);
 		if (fd_empty(f))
 			return -EBADF;
@@ -1127,7 +1127,7 @@ static int path_removexattrat(int dfd, const char __user *pathname,
 		return error;
 
 	CLASS(filename_maybe_null, filename)(pathname, at_flags);
-	if (!filename) {
+	if (!filename && dfd >= 0) {
 		CLASS(fd, f)(dfd);
 		if (fd_empty(f))
 			return -EBADF;

-- 
2.53.0


  parent reply	other threads:[~2026-11-30 15:52 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 15:51 [PATCH 0/4] xattr: fix AT_FDCWD handling Christian Brauner
2026-11-30 15:51 ` [PATCH 1/4] xattr: don't route f*xattr() through the *xattrat() helpers Christian Brauner
2026-11-30 18:02   ` Andreas Gruenbacher
2026-11-30 15:51 ` Christian Brauner [this message]
2026-11-30 18:03   ` [PATCH 2/4] xattr: let listxattrat() and removexattrat() handle AT_FDCWD Andreas Gruenbacher
2026-11-30 18:04   ` Andreas Gruenbacher
2026-11-30 15:51 ` [PATCH 3/4] selftests/xattr: add AT_FDCWD tests Christian Brauner
2026-11-30 15:51 ` [PATCH 4/4] xattrat: accept empty O_PATH file descriptors Christian Brauner
2026-11-30 18:05 ` [PATCH 0/4] xattr: fix AT_FDCWD handling Andreas Gruenbacher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261130-work-xattr-at_fdcwd-misc-v1-2-ab8a1727f992@kernel.org \
    --to=brauner@kernel.org \
    --cc=agruenba@redhat.com \
    --cc=cgzones@googlemail.com \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®