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>,
	stable@vger.kernel.org
Subject: [PATCH 0/4] xattr: fix AT_FDCWD handling
Date: Mon, 30 Nov 2026 16:51:36 +0100	[thread overview]
Message-ID: <20261130-work-xattr-at_fdcwd-misc-v1-0-ab8a1727f992@kernel.org> (raw)

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


             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 Christian Brauner [this message]
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

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-0-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=stable@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®