Skip to content

Commit f520bed

Browse files
jankarabrauner
authored andcommitted
fs/xattr: Fix handling of AT_FDCWD in setxattrat(2) and getxattrat(2)
Currently, setxattrat(2) and getxattrat(2) are wrongly handling the calls of the from setxattrat(AF_FDCWD, NULL, AT_EMPTY_PATH, ...) and fail with -EBADF error instead of operating on CWD. Fix it. Fixes: 6140be9 ("fs/xattr: add *at family syscalls") Signed-off-by: Jan Kara <jack@suse.cz> Link: https://lore.kernel.org/20250424132246.16822-2-jack@suse.cz Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 1d28f25 commit f520bed

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/xattr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ static int path_setxattrat(int dfd, const char __user *pathname,
703703
return error;
704704

705705
filename = getname_maybe_null(pathname, at_flags);
706-
if (!filename) {
706+
if (!filename && dfd >= 0) {
707707
CLASS(fd, f)(dfd);
708708
if (fd_empty(f))
709709
error = -EBADF;
@@ -847,7 +847,7 @@ static ssize_t path_getxattrat(int dfd, const char __user *pathname,
847847
return error;
848848

849849
filename = getname_maybe_null(pathname, at_flags);
850-
if (!filename) {
850+
if (!filename && dfd >= 0) {
851851
CLASS(fd, f)(dfd);
852852
if (fd_empty(f))
853853
return -EBADF;

0 commit comments

Comments
 (0)