mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/4] xattr: fix AT_FDCWD handling
@ 2026-11-30 15:51 Christian Brauner
  2026-11-30 15:51 ` [PATCH 1/4] xattr: don't route f*xattr() through the *xattrat() helpers Christian Brauner
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Christian Brauner @ 2026-11-30 15:51 UTC (permalink / raw)
  To: linux-fsdevel
  Cc: Andreas Gruenbacher, Jan Kara, Alexander Viro,
	Christian Göttsche, linux-kernel,
	Christian Brauner (Amutable),
	stable

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) <brauner@kernel.org>
---
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


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-11-30 18:05 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 2/4] xattr: let listxattrat() and removexattrat() handle AT_FDCWD Christian Brauner
2026-11-30 18:03   ` 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

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®