[PATCH 2/4] xattr: let listxattrat() and removexattrat() handle AT_FDCWD
From: Christian Brauner
Date: Mon Nov 30 2026 - 10:52:11 EST
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@xxxxxxxxxx>
---
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