xattr: switch to CLASS(fd)

[ Upstream commit a71874379e ]

Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Link: https://lore.kernel.org/all/20241002012230.4174585-1-viro@zeniv.linux.org.uk/
[ Neither `fd_file` nor `fd_empty` are available in 6.6.y, so the
  changes to the check are dropped. Kept the minor formatting change. ]
Signed-off-by: Tomasz Kramkowski <tomasz@kramkow.ski>
Tested-by: Barry K. Nathan <barryn@pobox.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Al Viro
2026-04-06 09:55:59 +02:00
committed by Greg Kroah-Hartman
parent 16d41d32b7
commit 9a3a2ae5ef
+10 -17
View File
@@ -698,9 +698,9 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
int error;
CLASS(fd, f)(fd);
if (!f.file)
return -EBADF;
audit_file(f.file);
error = setxattr_copy(name, &ctx);
if (error)
@@ -810,16 +810,13 @@ SYSCALL_DEFINE4(lgetxattr, const char __user *, pathname,
SYSCALL_DEFINE4(fgetxattr, int, fd, const char __user *, name,
void __user *, value, size_t, size)
{
struct fd f = fdget(fd);
ssize_t error = -EBADF;
CLASS(fd, f)(fd);
if (!f.file)
return error;
return -EBADF;
audit_file(f.file);
error = getxattr(file_mnt_idmap(f.file), f.file->f_path.dentry,
return getxattr(file_mnt_idmap(f.file), f.file->f_path.dentry,
name, value, size);
fdput(f);
return error;
}
/*
@@ -886,15 +883,12 @@ SYSCALL_DEFINE3(llistxattr, const char __user *, pathname, char __user *, list,
SYSCALL_DEFINE3(flistxattr, int, fd, char __user *, list, size_t, size)
{
struct fd f = fdget(fd);
ssize_t error = -EBADF;
CLASS(fd, f)(fd);
if (!f.file)
return error;
return -EBADF;
audit_file(f.file);
error = listxattr(f.file->f_path.dentry, list, size);
fdput(f);
return error;
return listxattr(f.file->f_path.dentry, list, size);
}
/*
@@ -951,12 +945,12 @@ SYSCALL_DEFINE2(lremovexattr, const char __user *, pathname,
SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name)
{
struct fd f = fdget(fd);
CLASS(fd, f)(fd);
char kname[XATTR_NAME_MAX + 1];
int error = -EBADF;
int error;
if (!f.file)
return error;
return -EBADF;
audit_file(f.file);
error = strncpy_from_user(kname, name, sizeof(kname));
@@ -971,7 +965,6 @@ SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name)
f.file->f_path.dentry, kname);
mnt_drop_write_file(f.file);
}
fdput(f);
return error;
}