AI Trajectory


Trajectory: (Expand/Collapse All)
Seq Timestamp Type Name Duration
0/0 2026/10/15 15:55 flow patch-triage
4m Args:
null

Results:
{
  "EnableConfigs": [
    "SECURITY_LANDLOCK",
    "SECURITY_PATH",
    "SECURITY",
    "FS_POSIX_ACL"
  ],
  "FocusSymbols": [
    "hook_path_setattr",
    "hook_path_file_setattr",
    "hook_path_file_getattr",
    "hook_path_setxattr",
    "hook_path_getxattr",
    "hook_path_listxattr",
    "hook_path_removexattr",
    "hook_path_set_acl",
    "hook_path_get_acl",
    "hook_path_remove_acl",
    "vfs_fileattr_set",
    "vfs_fileattr_get",
    "__notify_change"
  ],
  "KMSANReasoning": "The patch series primarily refactors VFS and LSM interfaces by converting metadata hooks (getattr, setattr, getxattr, setxattr, listxattr, removexattr, get_acl, set_acl, remove_acl, and fileattr get/set) from accepting raw dentries to accepting `const struct path *`, enabling Landlock to enforce access control on file/directory metadata (introducing LANDLOCK_ACCESS_FS_READ_METADATA and LANDLOCK_ACCESS_FS_WRITE_METADATA for Landlock ABI v13).\n\nReviewing memory initialization and data flow:\n1. No uninitialized memory or info-leak vectors: The patch does not introduce or modify any kernel structures copied to user space, nor does it alter data buffer sizing, bounds checks, or padding exposure.\n2. Stack variables: Every newly introduced `struct path` stack variable across drivers and filesystems (devtmpfs, cachefiles, overlayfs, nfsd, ksmbd) is fully initialized via designated initializers (e.g. `{ .mnt = ..., .dentry = ... }`) or helper initializers (`ovl_path_real`, `ecryptfs_lower_path`).\n3. Branching and logic: Control flow changes in Landlock and VFS depend on validated permissions, struct paths, and `iattr` flags; no branching depends on uninitialized data.\n\nAny potential bugs in this patch series would pertain to access control correctness, permission checks, or pointer validity, which are covered by functional tests and standard detectors (KASAN). There are no uninitialized memory risks that would require or benefit from a dedicated KMSAN fuzzing session.",
  "NeedsKMSAN": false,
  "Reasoning": "The patch series introduces Landlock ABI v13 support for controlling file and directory metadata access via two new access rights (LANDLOCK_ACCESS_FS_READ_METADATA and LANDLOCK_ACCESS_FS_WRITE_METADATA). To support path-based metadata access control, the series refactors multiple core VFS interfaces (notify_change, vfs_setxattr, vfs_getxattr, vfs_fileattr_get/set, posix_acl operations) and transitions LSM hooks from inode-based to struct path-based hooks across core VFS, Landlock, and other LSMs. These changes affect reachable core VFS and security subsystem paths and warrant fuzzing.",
  "WorthFuzzing": true
}

1/1 2026/10/15 15:55 action read-patch-diff
0m Args:
null

Results:
{
  "PatchDiff": "commit 014a9caffbc22fe4a10d9464410d1aade02103dc\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate:   Thu Oct 15 15:55:15 2026 +0000\n\n    syz-cluster: applied patch under review\n\ndiff --git a/Documentation/bpf/fs_kfuncs.rst b/Documentation/bpf/fs_kfuncs.rst\nindex 8762c3233a3d1..9586dbbbf177c 100644\n--- a/Documentation/bpf/fs_kfuncs.rst\n+++ b/Documentation/bpf/fs_kfuncs.rst\n@@ -18,4 +18,4 @@ To avoid recursions, these kfuncs follow the following rules:\n 1. These kfuncs are only permitted from BPF LSM function.\n 2. These kfuncs should not call into other LSM hooks, i.e. security_*(). For\n    example, ``bpf_get_file_xattr()`` does not use ``vfs_getxattr()``, because\n-   the latter calls LSM hook ``security_inode_getxattr``.\n+   the latter calls LSM hook ``security_path_getxattr``.\ndiff --git a/Documentation/userspace-api/landlock.rst b/Documentation/userspace-api/landlock.rst\nindex 3d45b956b6407..62fe39a8b61e6 100644\n--- a/Documentation/userspace-api/landlock.rst\n+++ b/Documentation/userspace-api/landlock.rst\n@@ -87,7 +87,9 @@ to be explicit about the denied-by-default access rights.\n             LANDLOCK_ACCESS_FS_REFER |\n             LANDLOCK_ACCESS_FS_TRUNCATE |\n             LANDLOCK_ACCESS_FS_IOCTL_DEV |\n-            LANDLOCK_ACCESS_FS_RESOLVE_UNIX,\n+            LANDLOCK_ACCESS_FS_RESOLVE_UNIX |\n+            LANDLOCK_ACCESS_FS_READ_METADATA |\n+            LANDLOCK_ACCESS_FS_WRITE_METADATA,\n         .handled_access_net =\n             LANDLOCK_ACCESS_NET_BIND_TCP |\n             LANDLOCK_ACCESS_NET_CONNECT_TCP |\n@@ -159,6 +161,10 @@ version, and only use the available subset of access rights:\n         ruleset_attr.handled_permissions \u0026=\n             ~(LANDLOCK_PERMISSION_NAMESPACE_USE |\n               LANDLOCK_PERMISSION_CAPABILITY_USE);\n+        /* Removes metadata rights for ABI \u003c 13 */\n+        ruleset_attr.handled_access_fs \u0026=\n+            ~(LANDLOCK_ACCESS_FS_READ_METADATA |\n+              LANDLOCK_ACCESS_FS_WRITE_METADATA);\n     }\n \n This enables the creation of an inclusive ruleset that will contain our rules.\n@@ -669,6 +675,45 @@ for writing, sidestepping the ``LANDLOCK_ACCESS_FS_TRUNCATE`` right.\n \n The truncate right is associated with the opened file (see below).\n \n+File metadata\n+-------------\n+\n+The ``LANDLOCK_ACCESS_FS_READ_METADATA`` right governs reading file and\n+directory metadata: :manpage:`stat(2)` and friends,\n+:manpage:`getxattr(2)`, :manpage:`listxattr(2)` and friends, and POSIX ACL\n+reads.\n+\n+The ``LANDLOCK_ACCESS_FS_WRITE_METADATA`` right governs explicit changes to\n+file and directory metadata: :manpage:`chmod(2)` and friends,\n+:manpage:`chown(2)` and friends, :manpage:`utimensat(2)`,\n+:manpage:`setxattr(2)`, :manpage:`removexattr(2)` and friends, and POSIX ACL\n+changes.  Both rights apply to files and directories alike.\n+\n+Implicit metadata changes performed by the kernel are not restricted by\n+``LANDLOCK_ACCESS_FS_WRITE_METADATA``: reading a file may update its access\n+time, writing a file updates its modification and change times and may change\n+the file size, and writing to or truncating a file with a set-user-ID or\n+set-group-ID bit clears these bits.  File size changes through\n+:manpage:`truncate(2)` and friends are governed by\n+``LANDLOCK_ACCESS_FS_TRUNCATE`` instead.  Metadata change requests that do\n+not change any attribute (e.g. :manpage:`chown(2)` with owner and group\n+``-1``) are not restricted either.\n+\n+.. warning::\n+\n+   Many programs read metadata as part of reading file contents or listing\n+   directories (e.g. calling :manpage:`stat(2)` before or after\n+   :manpage:`open(2)`), and do not expect such calls to fail with\n+   ``EACCES``.  Most of the time, ``LANDLOCK_ACCESS_FS_READ_METADATA``\n+   should therefore be granted together with\n+   ``LANDLOCK_ACCESS_FS_READ_FILE`` and ``LANDLOCK_ACCESS_FS_READ_DIR``.\n+   Conversely, denying only ``LANDLOCK_ACCESS_FS_READ_FILE`` or\n+   ``LANDLOCK_ACCESS_FS_READ_DIR`` does not hide metadata: it remains\n+   readable through :manpage:`stat(2)` and friends unless\n+   ``LANDLOCK_ACCESS_FS_READ_METADATA`` is denied as well.  Tailored\n+   programs that do not read metadata at all can still deny this right to\n+   further restrict their sandbox.\n+\n Rights associated with file descriptors\n ---------------------------------------\n \ndiff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c\nindex 11c70888f38be..71da9235ed49e 100644\n--- a/drivers/base/devtmpfs.c\n+++ b/drivers/base/devtmpfs.c\n@@ -284,13 +284,14 @@ static int handle_create(const char *nodename, umode_t mode, kuid_t uid,\n \t\t\tdev-\u003edevt, NULL);\n \tif (!err) {\n \t\tstruct iattr newattrs;\n+\t\tstruct path attr_path = { .mnt = path.mnt, .dentry = dentry };\n \n \t\tnewattrs.ia_mode = mode;\n \t\tnewattrs.ia_uid = uid;\n \t\tnewattrs.ia_gid = gid;\n \t\tnewattrs.ia_valid = ATTR_MODE|ATTR_UID|ATTR_GID;\n \t\tinode_lock(d_inode(dentry));\n-\t\tnotify_change(\u0026nop_mnt_idmap, dentry, \u0026newattrs, NULL);\n+\t\tnotify_change(\u0026attr_path, \u0026newattrs, NULL);\n \t\tinode_unlock(d_inode(dentry));\n \n \t\t/* mark as kernel-created inode */\n@@ -380,6 +381,7 @@ static int handle_remove(const char *nodename, struct device *dev)\n \tinode = d_inode(dentry);\n \tif (dev_mynode(dev, inode)) {\n \t\tstruct iattr newattrs;\n+\t\tstruct path attr_path = { .mnt = parent.mnt, .dentry = dentry };\n \t\t/*\n \t\t * before unlinking this node, reset permissions\n \t\t * of possible references like hardlinks\n@@ -390,7 +392,7 @@ static int handle_remove(const char *nodename, struct device *dev)\n \t\tnewattrs.ia_valid =\n \t\t\tATTR_UID|ATTR_GID|ATTR_MODE;\n \t\tinode_lock(d_inode(dentry));\n-\t\tnotify_change(\u0026nop_mnt_idmap, dentry, \u0026newattrs, NULL);\n+\t\tnotify_change(\u0026attr_path, \u0026newattrs, NULL);\n \t\tinode_unlock(d_inode(dentry));\n \t\terr = vfs_unlink(\u0026nop_mnt_idmap, d_inode(parent.dentry),\n \t\t\t\t dentry, NULL);\ndiff --git a/drivers/block/zloop.c b/drivers/block/zloop.c\nindex 8f485ef515577..b385192aacb11 100644\n--- a/drivers/block/zloop.c\n+++ b/drivers/block/zloop.c\n@@ -715,7 +715,7 @@ static int zloop_record_safe_wps(struct zloop_device *zlo)\n \n \t\tif (!zloop_zone_is_active(zone))\n \t\t\tcontinue;\n-\t\tret = vfs_setxattr(file_mnt_idmap(file), file_dentry(file),\n+\t\tret = vfs_setxattr(\u0026file-\u003ef_path,\n \t\t\t\t\"user.zloop.wp\", \u0026zone-\u003ewp, sizeof(zone-\u003ewp), 0);\n \t\tif (ret) {\n \t\t\tpr_err(\"%pg: failed to record write pointer (%d)\\n\",\n@@ -1417,7 +1417,7 @@ static void zloop_forget_cache(struct zloop_device *zlo)\n \t\tif (!zloop_zone_is_active(zone))\n \t\t\tcontinue;\n \n-\t\tret = vfs_getxattr(file_mnt_idmap(file), file_dentry(file),\n+\t\tret = vfs_getxattr(\u0026file-\u003ef_path,\n \t\t\t\t\"user.zloop.wp\", \u0026old_wp, sizeof(old_wp));\n \t\tif (ret == -ENODATA) {\n \t\t\told_wp = 0;\ndiff --git a/fs/attr.c b/fs/attr.c\nindex 9706d370f34af..c8bf69e609713 100644\n--- a/fs/attr.c\n+++ b/fs/attr.c\n@@ -397,35 +397,10 @@ int may_setattr(const struct mnt_idmap *idmap, struct inode *inode,\n }\n EXPORT_SYMBOL(may_setattr);\n \n-/**\n- * notify_change - modify attributes of a filesystem object\n- * @idmap:\tidmap of the mount the inode was found from\n- * @dentry:\tobject affected\n- * @attr:\tnew attributes\n- * @delegated_inode: returns inode, if the inode is delegated\n- *\n- * The caller must hold the i_rwsem exclusively on the affected object.\n- *\n- * If notify_change discovers a delegation in need of breaking,\n- * it will return -EWOULDBLOCK and return a reference to the inode in\n- * delegated_inode.  The caller should then break the delegation and\n- * retry.  Because breaking a delegation may take a long time, the\n- * caller should drop the i_rwsem before doing so.\n- *\n- * Alternatively, a caller may pass NULL for delegated_inode.  This may\n- * be appropriate for callers that expect the underlying filesystem not\n- * to be NFS exported.  Also, passing NULL is fine for callers holding\n- * the file open for write, as there can be no conflicting delegation in\n- * that case.\n- *\n- * If the inode has been found through an idmapped mount the idmap of\n- * the vfsmount must be passed through @idmap. This function will then\n- * take care to map the inode according to @idmap before checking\n- * permissions. On non-idmapped mounts or if permission checking is to be\n- * performed on the raw inode simply pass @nop_mnt_idmap.\n- */\n-int notify_change(const struct mnt_idmap *idmap, struct dentry *dentry,\n-\t\t  struct iattr *attr, struct delegated_inode *delegated_inode)\n+static int do_notify_change(const struct path *const path,\n+\t\t\t    const struct mnt_idmap *const idmap,\n+\t\t\t    struct dentry *const dentry, struct iattr *attr,\n+\t\t\t    struct delegated_inode *delegated_inode)\n {\n \tstruct inode *inode = dentry-\u003ed_inode;\n \tumode_t mode = inode-\u003ei_mode;\n@@ -537,9 +512,16 @@ int notify_change(const struct mnt_idmap *idmap, struct dentry *dentry,\n \t    !vfsgid_valid(i_gid_into_vfsgid(idmap, inode)))\n \t\treturn -EOVERFLOW;\n \n-\terror = security_inode_setattr(idmap, dentry, attr);\n-\tif (error)\n-\t\treturn error;\n+\t/*\n+\t * The LSM checks are only performed for user-facing calls (i.e.\n+\t * when @path is set): internal forwards, e.g. from a stacking\n+\t * filesystem, were already checked on the user-facing path.\n+\t */\n+\tif (path) {\n+\t\terror = security_path_setattr(path, attr);\n+\t\tif (error)\n+\t\t\treturn error;\n+\t}\n \n \t/*\n \t * If ATTR_DELEG is set, then these attributes are being set on\n@@ -564,4 +546,65 @@ int notify_change(const struct mnt_idmap *idmap, struct dentry *dentry,\n \n \treturn error;\n }\n+\n+/**\n+ * __notify_change - modify attributes of a filesystem object, without\n+ *                   the LSM check\n+ * @idmap:\tidmap of the mount the inode was found from\n+ * @dentry:\tobject affected\n+ * @attr:\tnew attributes\n+ * @delegated_inode: returns inode, if the inode is delegated\n+ *\n+ * Like notify_change(), but no security_path_setattr() hook is called:\n+ * this is the variant to use for internal forwards, where the LSM\n+ * checks were already performed on the user-facing path.\n+ *\n+ * The caller must hold the i_rwsem exclusively on the affected object.\n+ *\n+ * If the inode has been found through an idmapped mount, permission\n+ * checking is performed based on @idmap.  This function will take care\n+ * to map the inode according to the idmap before checking permissions.\n+ *\n+ * Return: 0 on success, or a negative error on failure.\n+ */\n+int __notify_change(const struct mnt_idmap *idmap, struct dentry *dentry,\n+\t\t    struct iattr *attr, struct delegated_inode *delegated_inode)\n+{\n+\treturn do_notify_change(NULL, idmap, dentry, attr, delegated_inode);\n+}\n+EXPORT_SYMBOL(__notify_change);\n+\n+/**\n+ * notify_change - modify attributes of a filesystem object\n+ * @path:\tobject affected\n+ * @attr:\tnew attributes\n+ * @delegated_inode: returns inode, if the inode is delegated\n+ *\n+ * The caller must hold the i_rwsem exclusively on the affected object.\n+ *\n+ * If notify_change discovers a delegation in need of breaking,\n+ * it will return -EWOULDBLOCK and return a reference to the inode in\n+ * delegated_inode.  The caller should then break the delegation and\n+ * retry.  Because breaking a delegation may take a long time, the\n+ * caller should drop the i_rwsem before doing so.\n+ *\n+ * Alternatively, a caller may pass NULL for delegated_inode.  This may\n+ * be appropriate for callers that expect the underlying filesystem not\n+ * to be NFS exported.  Also, passing NULL is fine for callers holding\n+ * the file open for write, as there can be no conflicting delegation in\n+ * that case.\n+ *\n+ * If the inode has been found through an idmapped mount, permission\n+ * checking is performed based on the idmap of @path-\u003emnt.  This function\n+ * will take care to map the inode according to the idmap before\n+ * checking permissions.\n+ *\n+ * Return: 0 on success, or a negative error on failure.\n+ */\n+int notify_change(const struct path *path, struct iattr *attr,\n+\t\t  struct delegated_inode *delegated_inode)\n+{\n+\treturn do_notify_change(path, mnt_idmap(path-\u003emnt), path-\u003edentry, attr,\n+\t\t\t\tdelegated_inode);\n+}\n EXPORT_SYMBOL(notify_change);\ndiff --git a/fs/bpf_fs_kfuncs.c b/fs/bpf_fs_kfuncs.c\nindex 35ccd98a4de64..ab25344e6205d 100644\n--- a/fs/bpf_fs_kfuncs.c\n+++ b/fs/bpf_fs_kfuncs.c\n@@ -566,10 +566,10 @@ BTF_SET_START(d_inode_locked_hooks)\n BTF_ID(func, bpf_lsm_inode_post_removexattr)\n BTF_ID(func, bpf_lsm_inode_post_setattr)\n BTF_ID(func, bpf_lsm_inode_post_setxattr)\n-BTF_ID(func, bpf_lsm_inode_removexattr)\n+BTF_ID(func, bpf_lsm_path_removexattr)\n BTF_ID(func, bpf_lsm_inode_rmdir)\n-BTF_ID(func, bpf_lsm_inode_setattr)\n-BTF_ID(func, bpf_lsm_inode_setxattr)\n+BTF_ID(func, bpf_lsm_path_setattr)\n+BTF_ID(func, bpf_lsm_path_setxattr)\n BTF_ID(func, bpf_lsm_inode_unlink)\n BTF_SET_END(d_inode_locked_hooks)\n \ndiff --git a/fs/cachefiles/xattr.c b/fs/cachefiles/xattr.c\nindex 8ebb713482e3e..8bafb4dc1f745 100644\n--- a/fs/cachefiles/xattr.c\n+++ b/fs/cachefiles/xattr.c\n@@ -40,7 +40,6 @@ struct cachefiles_vol_xattr {\n int cachefiles_preset_object_xattr(struct cachefiles_object *object, struct file *file)\n {\n \tstruct cachefiles_xattr *buf;\n-\tstruct dentry *dentry = file-\u003ef_path.dentry;\n \tunsigned int len = object-\u003ecookie-\u003eaux_len;\n \tint ret;\n \n@@ -55,7 +54,7 @@ int cachefiles_preset_object_xattr(struct cachefiles_object *object, struct file\n \tif (ret == 0) {\n \t\tret = mnt_want_write_file(file);\n \t\tif (ret == 0) {\n-\t\t\tret = vfs_setxattr(\u0026nop_mnt_idmap, dentry,\n+\t\t\tret = vfs_setxattr(\u0026file-\u003ef_path,\n \t\t\t\t\t   cachefiles_xattr_cache, buf,\n \t\t\t\t\t   sizeof(struct cachefiles_xattr) + len, 0);\n \t\t\tmnt_drop_write_file(file);\n@@ -91,7 +90,6 @@ int cachefiles_preset_object_xattr(struct cachefiles_object *object, struct file\n int cachefiles_set_object_xattr(struct cachefiles_object *object)\n {\n \tstruct cachefiles_xattr *buf;\n-\tstruct dentry *dentry;\n \tstruct file *file = object-\u003efile;\n \tunsigned int len = object-\u003ecookie-\u003eaux_len;\n \tuoff_t object_size = object-\u003ecookie-\u003eobject_size;\n@@ -99,7 +97,6 @@ int cachefiles_set_object_xattr(struct cachefiles_object *object)\n \n \tif (!file)\n \t\treturn -ESTALE;\n-\tdentry = file-\u003ef_path.dentry;\n \n \t_enter(\"%x,#%d\", object-\u003edebug_id, len);\n \n@@ -121,7 +118,7 @@ int cachefiles_set_object_xattr(struct cachefiles_object *object)\n \tif (ret == 0) {\n \t\tret = mnt_want_write_file(file);\n \t\tif (ret == 0) {\n-\t\t\tret = vfs_setxattr(\u0026nop_mnt_idmap, dentry,\n+\t\t\tret = vfs_setxattr(\u0026file-\u003ef_path,\n \t\t\t\t\t   cachefiles_xattr_cache, buf,\n \t\t\t\t\t   sizeof(struct cachefiles_xattr) + len, 0);\n \t\t\tmnt_drop_write_file(file);\n@@ -160,7 +157,6 @@ int cachefiles_set_object_xattr(struct cachefiles_object *object)\n int cachefiles_check_auxdata(struct cachefiles_object *object, struct file *file)\n {\n \tstruct cachefiles_xattr *buf;\n-\tstruct dentry *dentry = file-\u003ef_path.dentry;\n \tstruct inode *inode = file_inode(file);\n \tunsigned int len = object-\u003ecookie-\u003eaux_len, tlen;\n \tconst void *p = fscache_get_aux(object-\u003ecookie);\n@@ -177,7 +173,7 @@ int cachefiles_check_auxdata(struct cachefiles_object *object, struct file *file\n \n \txlen = cachefiles_inject_read_error();\n \tif (xlen == 0)\n-\t\txlen = vfs_getxattr(\u0026nop_mnt_idmap, dentry, cachefiles_xattr_cache, buf, tlen);\n+\t\txlen = vfs_getxattr(\u0026file-\u003ef_path, cachefiles_xattr_cache, buf, tlen);\n \tif (xlen != tlen) {\n \t\tif (xlen \u003c 0) {\n \t\t\tret = xlen;\n@@ -226,6 +222,7 @@ int cachefiles_remove_object_xattr(struct cachefiles_cache *cache,\n \t\t\t\t   struct cachefiles_object *object,\n \t\t\t\t   struct dentry *dentry)\n {\n+\tstruct path path = { .mnt = cache-\u003emnt, .dentry = dentry };\n \tint ret;\n \n \ttrace_cachefiles_coherency(object, d_inode(dentry)-\u003ei_ino, 0, NULL, 0,\n@@ -235,8 +232,7 @@ int cachefiles_remove_object_xattr(struct cachefiles_cache *cache,\n \tif (ret == 0) {\n \t\tret = mnt_want_write(cache-\u003emnt);\n \t\tif (ret == 0) {\n-\t\t\tret = vfs_removexattr(\u0026nop_mnt_idmap, dentry,\n-\t\t\t\t\t      cachefiles_xattr_cache);\n+\t\t\tret = vfs_removexattr(\u0026path, cachefiles_xattr_cache);\n \t\t\tmnt_drop_write(cache-\u003emnt);\n \t\t}\n \t}\n@@ -282,7 +278,8 @@ bool cachefiles_set_volume_xattr(struct cachefiles_volume *volume)\n \tstruct cachefiles_vol_xattr *buf;\n \tunsigned int len = volume-\u003evcookie-\u003ecoherency_len;\n \tconst void *p = volume-\u003evcookie-\u003ecoherency;\n-\tstruct dentry *dentry = volume-\u003edentry;\n+\tstruct path path = { .mnt = volume-\u003ecache-\u003emnt,\n+\t\t\t     .dentry = volume-\u003edentry };\n \tint ret;\n \n \t_enter(\"%x,#%d\", volume-\u003evcookie-\u003edebug_id, len);\n@@ -298,22 +295,21 @@ bool cachefiles_set_volume_xattr(struct cachefiles_volume *volume)\n \tif (ret == 0) {\n \t\tret = mnt_want_write(volume-\u003ecache-\u003emnt);\n \t\tif (ret == 0) {\n-\t\t\tret = vfs_setxattr(\u0026nop_mnt_idmap, dentry,\n-\t\t\t\t\t   cachefiles_xattr_cache,\n+\t\t\tret = vfs_setxattr(\u0026path, cachefiles_xattr_cache,\n \t\t\t\t\t   buf, len, 0);\n \t\t\tmnt_drop_write(volume-\u003ecache-\u003emnt);\n \t\t}\n \t}\n \tif (ret \u003c 0) {\n-\t\ttrace_cachefiles_vfs_error(NULL, d_inode(dentry), ret,\n+\t\ttrace_cachefiles_vfs_error(NULL, d_inode(path.dentry), ret,\n \t\t\t\t\t   cachefiles_trace_setxattr_error);\n-\t\ttrace_cachefiles_vol_coherency(volume, d_inode(dentry)-\u003ei_ino,\n+\t\ttrace_cachefiles_vol_coherency(volume, d_inode(path.dentry)-\u003ei_ino,\n \t\t\t\t\t       cachefiles_coherency_vol_set_fail);\n \t\tif (ret != -ENOMEM)\n \t\t\tcachefiles_io_error(\n \t\t\t\tvolume-\u003ecache, \"Failed to set xattr with error %d\", ret);\n \t} else {\n-\t\ttrace_cachefiles_vol_coherency(volume, d_inode(dentry)-\u003ei_ino,\n+\t\ttrace_cachefiles_vol_coherency(volume, d_inode(path.dentry)-\u003ei_ino,\n \t\t\t\t\t       cachefiles_coherency_vol_set_ok);\n \t}\n \n@@ -328,9 +324,10 @@ bool cachefiles_set_volume_xattr(struct cachefiles_volume *volume)\n int cachefiles_check_volume_xattr(struct cachefiles_volume *volume)\n {\n \tstruct cachefiles_vol_xattr *buf;\n-\tstruct dentry *dentry = volume-\u003edentry;\n \tunsigned int len = volume-\u003evcookie-\u003ecoherency_len;\n \tconst void *p = volume-\u003evcookie-\u003ecoherency;\n+\tstruct path path = { .mnt = volume-\u003ecache-\u003emnt,\n+\t\t\t     .dentry = volume-\u003edentry };\n \tenum cachefiles_coherency_trace why;\n \tssize_t xlen;\n \tint ret = -ESTALE;\n@@ -344,11 +341,11 @@ int cachefiles_check_volume_xattr(struct cachefiles_volume *volume)\n \n \txlen = cachefiles_inject_read_error();\n \tif (xlen == 0)\n-\t\txlen = vfs_getxattr(\u0026nop_mnt_idmap, dentry, cachefiles_xattr_cache, buf, len);\n+\t\txlen = vfs_getxattr(\u0026path, cachefiles_xattr_cache, buf, len);\n \tif (xlen != len) {\n \t\tif (xlen \u003c 0) {\n \t\t\tret = xlen;\n-\t\t\ttrace_cachefiles_vfs_error(NULL, d_inode(dentry), xlen,\n+\t\t\ttrace_cachefiles_vfs_error(NULL, d_inode(path.dentry), xlen,\n \t\t\t\t\t\t   cachefiles_trace_getxattr_error);\n \t\t\tif (xlen == -EIO)\n \t\t\t\tcachefiles_io_error(\n@@ -365,7 +362,7 @@ int cachefiles_check_volume_xattr(struct cachefiles_volume *volume)\n \t\tret = 0;\n \t}\n \n-\ttrace_cachefiles_vol_coherency(volume, d_inode(dentry)-\u003ei_ino, why);\n+\ttrace_cachefiles_vol_coherency(volume, d_inode(path.dentry)-\u003ei_ino, why);\n \tkfree(buf);\n \t_leave(\" = %d\", ret);\n \treturn ret;\ndiff --git a/fs/coredump.c b/fs/coredump.c\nindex b25ef2ffbdeed..57787e8c699f5 100644\n--- a/fs/coredump.c\n+++ b/fs/coredump.c\n@@ -1060,7 +1060,7 @@ static bool coredump_file(struct core_name *cn, struct coredump_params *cprm,\n \t}\n \tif (!(file-\u003ef_mode \u0026 FMODE_CAN_WRITE))\n \t\treturn false;\n-\tif (do_truncate(idmap, file-\u003ef_path.dentry, 0, 0, file))\n+\tif (do_truncate(\u0026file-\u003ef_path, 0, 0, file))\n \t\treturn false;\n \n \tcprm-\u003efile = no_free_ptr(file);\ndiff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c\nindex 48e520960d665..e894ce435b5bb 100644\n--- a/fs/ecryptfs/inode.c\n+++ b/fs/ecryptfs/inode.c\n@@ -732,7 +732,8 @@ upper_size_to_lower_size(struct ecryptfs_crypt_stat *crypt_stat,\n  */\n static int __ecryptfs_truncate(struct dentry *dentry, const struct iattr *ia)\n {\n-\tstruct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry);\n+\tstruct path lower_path = ecryptfs_lower_path(dentry);\n+\tstruct dentry *lower_dentry = lower_path.dentry;\n \tstruct inode *inode = d_inode(dentry);\n \tstruct ecryptfs_crypt_stat *crypt_stat;\n \tloff_t i_size = i_size_read(inode);\n@@ -821,7 +822,7 @@ static int __ecryptfs_truncate(struct dentry *dentry, const struct iattr *ia)\n set_size:\n \tlower_ia.ia_valid |= ATTR_SIZE;\n \tinode_lock(d_inode(lower_dentry));\n-\trc = notify_change(\u0026nop_mnt_idmap, lower_dentry, \u0026lower_ia, NULL);\n+\trc = notify_change(\u0026lower_path, \u0026lower_ia, NULL);\n \tinode_unlock(d_inode(lower_dentry));\n out:\n \tecryptfs_put_lower_file(inode);\n@@ -873,7 +874,6 @@ static int ecryptfs_setattr(const struct mnt_idmap *idmap,\n \t\t\t    struct dentry *dentry, struct iattr *ia)\n {\n \tstruct inode *inode = d_inode(dentry);\n-\tstruct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry);\n \tstruct inode *lower_inode = ecryptfs_inode_to_lower(inode);\n \tstruct ecryptfs_crypt_stat *crypt_stat;\n \tint rc;\n@@ -925,14 +925,14 @@ static int ecryptfs_setattr(const struct mnt_idmap *idmap,\n \tif (ia-\u003eia_valid \u0026 ATTR_SIZE) {\n \t\trc = __ecryptfs_truncate(dentry, ia);\n \t} else {\n+\t\tstruct path lower_path = ecryptfs_lower_path(dentry);\n \t\tstruct iattr lower_ia;\n \n \t\tecryptfs_iattr_to_lower(\u0026lower_ia, ia);\n \n-\t\tinode_lock(d_inode(lower_dentry));\n-\t\trc = notify_change(\u0026nop_mnt_idmap, lower_dentry, \u0026lower_ia,\n-\t\t\t\tNULL);\n-\t\tinode_unlock(d_inode(lower_dentry));\n+\t\tinode_lock(d_inode(lower_path.dentry));\n+\t\trc = notify_change(\u0026lower_path, \u0026lower_ia, NULL);\n+\t\tinode_unlock(d_inode(lower_path.dentry));\n \t}\n out:\n \tfsstack_copy_attr_all(inode, lower_inode);\n@@ -991,17 +991,17 @@ ecryptfs_setxattr(struct dentry *dentry, struct inode *inode,\n \t\t  size_t size, int flags)\n {\n \tint rc;\n-\tstruct dentry *lower_dentry;\n+\tstruct path lower_path;\n \tstruct inode *lower_inode;\n \n-\tlower_dentry = ecryptfs_dentry_to_lower(dentry);\n-\tlower_inode = d_inode(lower_dentry);\n+\tlower_path = ecryptfs_lower_path(dentry);\n+\tlower_inode = d_inode(lower_path.dentry);\n \tif (!(lower_inode-\u003ei_opflags \u0026 IOP_XATTR)) {\n \t\trc = -EOPNOTSUPP;\n \t\tgoto out;\n \t}\n \tinode_lock(lower_inode);\n-\trc = __vfs_setxattr_locked(\u0026nop_mnt_idmap, lower_dentry, name, value, size, flags, NULL);\n+\trc = __vfs_setxattr_locked(\u0026lower_path, name, value, size, flags, NULL);\n \tinode_unlock(lower_inode);\n \tif (!rc \u0026\u0026 inode)\n \t\tfsstack_copy_attr_all(inode, lower_inode);\n@@ -1075,7 +1075,7 @@ static int ecryptfs_removexattr(struct dentry *dentry, struct inode *inode,\n \n static int ecryptfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa)\n {\n-\treturn vfs_fileattr_get(ecryptfs_dentry_to_lower(dentry), fa);\n+\treturn __vfs_fileattr_get(ecryptfs_dentry_to_lower(dentry), fa);\n }\n \n static int ecryptfs_fileattr_set(const struct mnt_idmap *idmap,\n@@ -1084,7 +1084,7 @@ static int ecryptfs_fileattr_set(const struct mnt_idmap *idmap,\n \tstruct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry);\n \tint rc;\n \n-\trc = vfs_fileattr_set(\u0026nop_mnt_idmap, lower_dentry, fa);\n+\trc = __vfs_fileattr_set(\u0026nop_mnt_idmap, lower_dentry, fa);\n \tfsstack_copy_attr_all(d_inode(dentry), d_inode(lower_dentry));\n \n \treturn rc;\n@@ -1093,8 +1093,9 @@ static int ecryptfs_fileattr_set(const struct mnt_idmap *idmap,\n static struct posix_acl *ecryptfs_get_acl(const struct mnt_idmap *idmap,\n \t\t\t\t\t  struct dentry *dentry, int type)\n {\n-\treturn vfs_get_acl(idmap, ecryptfs_dentry_to_lower(dentry),\n-\t\t\t   posix_acl_xattr_name(type));\n+\tstruct path lower_path = ecryptfs_lower_path(dentry);\n+\n+\treturn vfs_get_acl(\u0026lower_path, posix_acl_xattr_name(type));\n }\n \n static int ecryptfs_set_acl(const struct mnt_idmap *idmap,\n@@ -1102,11 +1103,10 @@ static int ecryptfs_set_acl(const struct mnt_idmap *idmap,\n \t\t\t    int type)\n {\n \tint rc;\n-\tstruct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry);\n-\tstruct inode *lower_inode = d_inode(lower_dentry);\n+\tstruct path lower_path = ecryptfs_lower_path(dentry);\n+\tstruct inode *lower_inode = d_inode(lower_path.dentry);\n \n-\trc = vfs_set_acl(\u0026nop_mnt_idmap, lower_dentry,\n-\t\t\t posix_acl_xattr_name(type), acl);\n+\trc = vfs_set_acl(\u0026lower_path, posix_acl_xattr_name(type), acl);\n \tif (!rc)\n \t\tfsstack_copy_attr_all(d_inode(dentry), lower_inode);\n \treturn rc;\ndiff --git a/fs/exfat/file.c b/fs/exfat/file.c\nindex 1386149916bbe..51ed20e27429b 100644\n--- a/fs/exfat/file.c\n+++ b/fs/exfat/file.c\n@@ -551,8 +551,7 @@ static int exfat_ioctl_set_attributes(struct file *file, u32 __user *user_attr)\n \t * out the RO attribute for checking by the security\n \t * module, just because it maps to a file mode.\n \t */\n-\terr = security_inode_setattr(file_mnt_idmap(file),\n-\t\t\t\t     file-\u003ef_path.dentry, \u0026ia);\n+\terr = security_path_setattr(\u0026file-\u003ef_path, \u0026ia);\n \tif (err)\n \t\tgoto out_unlock_inode;\n \ndiff --git a/fs/fat/file.c b/fs/fat/file.c\nindex d4f1b360b9743..5178561906dd1 100644\n--- a/fs/fat/file.c\n+++ b/fs/fat/file.c\n@@ -92,8 +92,7 @@ static int fat_ioctl_set_attributes(struct file *file, u32 __user *user_attr)\n \t * out the RO attribute for checking by the security\n \t * module, just because it maps to a file mode.\n \t */\n-\terr = security_inode_setattr(file_mnt_idmap(file),\n-\t\t\t\t     file-\u003ef_path.dentry, \u0026ia);\n+\terr = security_path_setattr(\u0026file-\u003ef_path, \u0026ia);\n \tif (err)\n \t\tgoto out_unlock_inode;\n \ndiff --git a/fs/file_attr.c b/fs/file_attr.c\nindex 833e03810b24c..ea56843450f70 100644\n--- a/fs/file_attr.c\n+++ b/fs/file_attr.c\n@@ -75,27 +75,46 @@ void fileattr_fill_flags(struct file_kattr *fa, u32 flags)\n EXPORT_SYMBOL(fileattr_fill_flags);\n \n /**\n- * vfs_fileattr_get - retrieve miscellaneous file attributes\n+ * __vfs_fileattr_get - retrieve miscellaneous file attributes\n  * @dentry:\tthe object to retrieve from\n  * @fa:\t\tfileattr pointer\n  *\n- * Call i_op-\u003efileattr_get() callback, if exists.\n+ * Call i_op-\u003efileattr_get() callback, if exists.  Unlike\n+ * vfs_fileattr_get(), no security hook is called: this is the variant to\n+ * use for internal forwards, where the LSM checks were already performed\n+ * on the user-facing path (e.g. by a stacking filesystem).\n  *\n  * Return: 0 on success, or a negative error on failure.\n  */\n-int vfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa)\n+int __vfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa)\n {\n \tstruct inode *inode = d_inode(dentry);\n-\tint error;\n \n \tif (!inode-\u003ei_op-\u003efileattr_get)\n \t\treturn -ENOIOCTLCMD;\n \n-\terror = security_inode_file_getattr(dentry, fa);\n+\treturn inode-\u003ei_op-\u003efileattr_get(dentry, fa);\n+}\n+EXPORT_SYMBOL(__vfs_fileattr_get);\n+\n+/**\n+ * vfs_fileattr_get - retrieve miscellaneous file attributes\n+ * @path:\tthe object to retrieve from\n+ * @fa:\t\tfileattr pointer\n+ *\n+ * Call i_op-\u003efileattr_get() callback, if exists.\n+ *\n+ * Return: 0 on success, or a negative error on failure.\n+ */\n+int vfs_fileattr_get(const struct path *path, struct file_kattr *fa)\n+{\n+\tint error;\n+\n+\terror = security_path_file_getattr(path, fa);\n \tif (error)\n \t\treturn error;\n \n-\treturn inode-\u003ei_op-\u003efileattr_get(dentry, fa);\n+\treturn __vfs_fileattr_get(path-\u003edentry, fa);\n }\n EXPORT_SYMBOL(vfs_fileattr_get);\n \n@@ -254,24 +273,10 @@ static int fileattr_set_prepare(struct inode *inode,\n \treturn 0;\n }\n \n-/**\n- * vfs_fileattr_set - change miscellaneous file attributes\n- * @idmap:\tidmap of the mount\n- * @dentry:\tthe object to change\n- * @fa:\t\tfileattr pointer\n- *\n- * After verifying permissions, call i_op-\u003efileattr_set() callback, if\n- * exists.\n- *\n- * Verifying attributes involves retrieving current attributes with\n- * i_op-\u003efileattr_get(), this also allows initializing attributes that have\n- * not been set by the caller to current values.  Inode lock is held\n- * thoughout to prevent racing with another instance.\n- *\n- * Return: 0 on success, or a negative error on failure.\n- */\n-int vfs_fileattr_set(const struct mnt_idmap *idmap, struct dentry *dentry,\n-\t\t     struct file_kattr *fa)\n+static int do_vfs_fileattr_set(const struct path *const path,\n+\t\t\t       const struct mnt_idmap *const idmap,\n+\t\t\t       struct dentry *const dentry,\n+\t\t\t       struct file_kattr *const fa)\n {\n \tstruct inode *inode = d_inode(dentry);\n \tstruct file_kattr old_ma = {};\n@@ -284,7 +289,7 @@ int vfs_fileattr_set(const struct mnt_idmap *idmap, struct dentry *dentry,\n \t\treturn -EPERM;\n \n \tinode_lock(inode);\n-\terr = vfs_fileattr_get(dentry, \u0026old_ma);\n+\terr = __vfs_fileattr_get(dentry, \u0026old_ma);\n \tif (!err) {\n \t\t/* initialize missing bits from old_ma */\n \t\tif (fa-\u003eflags_valid) {\n@@ -300,9 +305,17 @@ int vfs_fileattr_set(const struct mnt_idmap *idmap, struct dentry *dentry,\n \t\terr = fileattr_set_prepare(inode, \u0026old_ma, fa);\n \t\tif (err)\n \t\t\tgoto out;\n-\t\terr = security_inode_file_setattr(dentry, fa);\n-\t\tif (err)\n-\t\t\tgoto out;\n+\t\t/*\n+\t\t * The LSM checks are only performed for user-facing calls\n+\t\t * (i.e. when @path is set): internal forwards, e.g. from a\n+\t\t * stacking filesystem, were already checked on the\n+\t\t * user-facing path.\n+\t\t */\n+\t\tif (path) {\n+\t\t\terr = security_path_file_setattr(path, fa);\n+\t\t\tif (err)\n+\t\t\t\tgoto out;\n+\t\t}\n \t\terr = inode-\u003ei_op-\u003efileattr_set(idmap, dentry, fa);\n \t\tif (err)\n \t\t\tgoto out;\n@@ -313,6 +326,48 @@ int vfs_fileattr_set(const struct mnt_idmap *idmap, struct dentry *dentry,\n \tinode_unlock(inode);\n \treturn err;\n }\n+\n+/**\n+ * __vfs_fileattr_set - change miscellaneous file attributes\n+ * @idmap:\tidmap of the mount\n+ * @dentry:\tthe object to change\n+ * @fa:\t\tfileattr pointer\n+ *\n+ * After verifying permissions, call i_op-\u003efileattr_set() callback, if\n+ * exists.  Unlike vfs_fileattr_set(), no security hook is called: this is\n+ * the variant to use for internal forwards, where the LSM checks were\n+ * already performed on the user-facing path (e.g. by a stacking\n+ * filesystem).\n+ *\n+ * Verifying attributes involves retrieving current attributes with\n+ * i_op-\u003efileattr_get(), this also allows initializing attributes that have\n+ * not been set by the caller to current values.  Inode lock is held\n+ * thoughout to prevent racing with another instance.\n+ *\n+ * Return: 0 on success, or a negative error on failure.\n+ */\n+int __vfs_fileattr_set(const struct mnt_idmap *idmap, struct dentry *dentry,\n+\t\t       struct file_kattr *fa)\n+{\n+\treturn do_vfs_fileattr_set(NULL, idmap, dentry, fa);\n+}\n+EXPORT_SYMBOL(__vfs_fileattr_set);\n+\n+/**\n+ * vfs_fileattr_set - change miscellaneous file attributes\n+ * @path:\tthe object to change\n+ * @fa:\t\tfileattr pointer\n+ *\n+ * After verifying permissions, call i_op-\u003efileattr_set() callback, if\n+ * exists.\n+ *\n+ * Return: 0 on success, or a negative error on failure.\n+ */\n+int vfs_fileattr_set(const struct path *path, struct file_kattr *fa)\n+{\n+\treturn do_vfs_fileattr_set(path, mnt_idmap(path-\u003emnt), path-\u003edentry,\n+\t\t\t\t   fa);\n+}\n EXPORT_SYMBOL(vfs_fileattr_set);\n \n int ioctl_getflags(struct file *file, unsigned int __user *argp)\n@@ -320,7 +375,7 @@ int ioctl_getflags(struct file *file, unsigned int __user *argp)\n \tstruct file_kattr fa = { .flags_valid = true }; /* hint only */\n \tint err;\n \n-\terr = vfs_fileattr_get(file-\u003ef_path.dentry, \u0026fa);\n+\terr = vfs_fileattr_get(\u0026file-\u003ef_path, \u0026fa);\n \tif (!err)\n \t\terr = put_user(fa.flags, argp);\n \treturn err;\n@@ -328,8 +383,6 @@ int ioctl_getflags(struct file *file, unsigned int __user *argp)\n \n int ioctl_setflags(struct file *file, unsigned int __user *argp)\n {\n-\tconst struct mnt_idmap *idmap = file_mnt_idmap(file);\n-\tstruct dentry *dentry = file-\u003ef_path.dentry;\n \tstruct file_kattr fa = {};\n \tunsigned int flags;\n \tint err;\n@@ -339,7 +392,7 @@ int ioctl_setflags(struct file *file, unsigned int __user *argp)\n \t\terr = mnt_want_write_file(file);\n \t\tif (!err) {\n \t\t\tfileattr_fill_flags(\u0026fa, flags);\n-\t\t\terr = vfs_fileattr_set(idmap, dentry, \u0026fa);\n+\t\t\terr = vfs_fileattr_set(\u0026file-\u003ef_path, \u0026fa);\n \t\t\tmnt_drop_write_file(file);\n \t\t}\n \t}\n@@ -351,7 +404,7 @@ int ioctl_fsgetxattr(struct file *file, void __user *argp)\n \tstruct file_kattr fa = { .fsx_valid = true }; /* hint only */\n \tint err;\n \n-\terr = vfs_fileattr_get(file-\u003ef_path.dentry, \u0026fa);\n+\terr = vfs_fileattr_get(\u0026file-\u003ef_path, \u0026fa);\n \tif (!err)\n \t\terr = copy_fsxattr_to_user(\u0026fa, argp);\n \n@@ -360,8 +413,6 @@ int ioctl_fsgetxattr(struct file *file, void __user *argp)\n \n int ioctl_fssetxattr(struct file *file, void __user *argp)\n {\n-\tconst struct mnt_idmap *idmap = file_mnt_idmap(file);\n-\tstruct dentry *dentry = file-\u003ef_path.dentry;\n \tstruct file_kattr fa = {};\n \tint err;\n \n@@ -369,7 +420,7 @@ int ioctl_fssetxattr(struct file *file, void __user *argp)\n \tif (!err) {\n \t\terr = mnt_want_write_file(file);\n \t\tif (!err) {\n-\t\t\terr = vfs_fileattr_set(idmap, dentry, \u0026fa);\n+\t\t\terr = vfs_fileattr_set(\u0026file-\u003ef_path, \u0026fa);\n \t\t\tmnt_drop_write_file(file);\n \t\t}\n \t}\n@@ -416,7 +467,7 @@ SYSCALL_DEFINE5(file_getattr, int, dfd, const char __user *, filename,\n \t\t\treturn error;\n \t}\n \n-\terror = vfs_fileattr_get(filepath.dentry, \u0026fa);\n+\terror = vfs_fileattr_get(\u0026filepath, \u0026fa);\n \tif (error == -ENOIOCTLCMD || error == -ENOTTY)\n \t\terror = -EOPNOTSUPP;\n \tif (error)\n@@ -480,8 +531,7 @@ SYSCALL_DEFINE5(file_setattr, int, dfd, const char __user *, filename,\n \n \terror = mnt_want_write(filepath.mnt);\n \tif (!error) {\n-\t\terror = vfs_fileattr_set(mnt_idmap(filepath.mnt),\n-\t\t\t\t\t filepath.dentry, \u0026fa);\n+\t\terror = vfs_fileattr_set(\u0026filepath, \u0026fa);\n \t\tif (error == -ENOIOCTLCMD || error == -ENOTTY)\n \t\t\terror = -EOPNOTSUPP;\n \t\tmnt_drop_write(filepath.mnt);\ndiff --git a/fs/inode.c b/fs/inode.c\nindex 702f2d5ef459c..ea557adbbd203 100644\n--- a/fs/inode.c\n+++ b/fs/inode.c\n@@ -2356,8 +2356,7 @@ int dentry_needs_remove_privs(const struct mnt_idmap *idmap,\n \treturn mask;\n }\n \n-static int __remove_privs(const struct mnt_idmap *idmap,\n-\t\t\t  struct dentry *dentry, int kill)\n+static int __remove_privs(const struct path *path, int kill)\n {\n \tstruct iattr newattrs;\n \n@@ -2366,7 +2365,7 @@ static int __remove_privs(const struct mnt_idmap *idmap,\n \t * Note we call this on write, so notify_change will not\n \t * encounter any conflicting delegations:\n \t */\n-\treturn notify_change(idmap, dentry, \u0026newattrs, NULL);\n+\treturn notify_change(path, \u0026newattrs, NULL);\n }\n \n static int file_remove_privs_flags(struct file *file, unsigned int flags)\n@@ -2387,7 +2386,7 @@ static int file_remove_privs_flags(struct file *file, unsigned int flags)\n \t\tif (flags \u0026 IOCB_NOWAIT)\n \t\t\treturn -EAGAIN;\n \n-\t\terror = __remove_privs(file_mnt_idmap(file), dentry, kill);\n+\t\terror = __remove_privs(\u0026file-\u003ef_path, kill);\n \t}\n \n \tif (!error)\ndiff --git a/fs/internal.h b/fs/internal.h\nindex e833c7e6e14fb..050c35f75d4a7 100644\n--- a/fs/internal.h\n+++ b/fs/internal.h\n@@ -304,20 +304,19 @@ int import_xattr_name(struct xattr_name *kname, const char __user *name);\n int may_write_xattr(const struct mnt_idmap *idmap, struct inode *inode);\n \n #ifdef CONFIG_FS_POSIX_ACL\n-int do_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,\n-\t       const char *acl_name, const void *kvalue, size_t size);\n-ssize_t do_get_acl(const struct mnt_idmap *idmap, struct dentry *dentry,\n-\t\t   const char *acl_name, void *kvalue, size_t size);\n+int do_set_acl(const struct path *path, const char *acl_name,\n+\t       const void *kvalue, size_t size);\n+ssize_t do_get_acl(const struct path *path, const char *acl_name,\n+\t\t   void *kvalue, size_t size);\n #else\n-static inline int do_set_acl(const struct mnt_idmap *idmap,\n-\t\t\t     struct dentry *dentry, const char *acl_name,\n+static inline int do_set_acl(const struct path *path, const char *acl_name,\n \t\t\t     const void *kvalue, size_t size)\n {\n \treturn -EOPNOTSUPP;\n }\n-static inline ssize_t do_get_acl(const struct mnt_idmap *idmap,\n-\t\t\t\t struct dentry *dentry, const char *acl_name,\n-\t\t\t\t void *kvalue, size_t size)\n+static inline ssize_t do_get_acl(const struct path *path,\n+\t\t\t\t const char *acl_name, void *kvalue,\n+\t\t\t\t size_t size)\n {\n \treturn -EOPNOTSUPP;\n }\ndiff --git a/fs/namei.c b/fs/namei.c\nindex fd160bd7886fa..e43c552e1e96c 100644\n--- a/fs/namei.c\n+++ b/fs/namei.c\n@@ -4335,7 +4335,7 @@ static int may_open(const struct mnt_idmap *idmap, const struct path *path,\n \treturn 0;\n }\n \n-static int handle_truncate(const struct mnt_idmap *idmap, struct file *filp)\n+static int handle_truncate(struct file *filp)\n {\n \tconst struct path *path = \u0026filp-\u003ef_path;\n \tstruct inode *inode = path-\u003edentry-\u003ed_inode;\n@@ -4345,8 +4345,7 @@ static int handle_truncate(const struct mnt_idmap *idmap, struct file *filp)\n \n \terror = security_file_truncate(filp);\n \tif (!error) {\n-\t\terror = do_truncate(idmap, path-\u003edentry, 0,\n-\t\t\t\t    ATTR_MTIME|ATTR_CTIME|ATTR_OPEN,\n+\t\terror = do_truncate(path, 0, ATTR_MTIME|ATTR_CTIME|ATTR_OPEN,\n \t\t\t\t    filp);\n \t}\n \tput_write_access(inode);\n@@ -4894,7 +4893,7 @@ static int do_open(struct nameidata *nd,\n \tif (!error)\n \t\terror = security_file_post_open(file, op-\u003eacc_mode);\n \tif (!error \u0026\u0026 do_truncate)\n-\t\terror = handle_truncate(idmap, file);\n+\t\terror = handle_truncate(file);\n \tif (unlikely(error \u003e 0)) {\n \t\tWARN_ON(1);\n \t\terror = -EINVAL;\ndiff --git a/fs/nfsd/nfs4ctl.h b/fs/nfsd/nfs4ctl.h\nindex bcec4c4ef1d53..97ab3d4212aaa 100644\n--- a/fs/nfsd/nfs4ctl.h\n+++ b/fs/nfsd/nfs4ctl.h\n@@ -38,7 +38,7 @@ int nfsd4_create_laundry_wq(void);\n void nfsd4_destroy_laundry_wq(void);\n bool nfsd_wait_for_delegreturn(struct svc_rqst *rqstp, struct inode *inode);\n \n-extern int nfsd4_is_junction(struct dentry *dentry);\n+extern int nfsd4_is_junction(const struct path *path);\n extern int register_cld_notifier(void);\n extern void unregister_cld_notifier(void);\n #ifdef CONFIG_NFSD_V4_2_INTER_SSC\n@@ -68,7 +68,7 @@ static inline bool nfsd_wait_for_delegreturn(struct svc_rqst *rqstp,\n \treturn false;\n }\n \n-static inline int nfsd4_is_junction(struct dentry *dentry)\n+static inline int nfsd4_is_junction(const struct path *path)\n {\n \treturn 0;\n }\ndiff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c\nindex 1de6c6d757c3e..400a429418794 100644\n--- a/fs/nfsd/nfs4state.c\n+++ b/fs/nfsd/nfs4state.c\n@@ -10477,8 +10477,10 @@ bool nfsd4_vet_deleg_time(struct timespec64 *req, const struct timespec64 *orig,\n \treturn true;\n }\n \n-static int cb_getattr_update_times(struct dentry *dentry, struct nfs4_delegation *dp)\n+static int cb_getattr_update_times(const struct path *path,\n+\t\t\t\t   struct nfs4_delegation *dp)\n {\n+\tstruct dentry *dentry = path-\u003edentry;\n \tstruct inode *inode = d_inode(dentry);\n \tstruct nfs4_cb_fattr *ncf = \u0026dp-\u003edl_cb_fattr;\n \tstruct iattr attrs = { };\n@@ -10508,7 +10510,7 @@ static int cb_getattr_update_times(struct dentry *dentry, struct nfs4_delegation\n \n \tattrs.ia_valid |= ATTR_DELEG;\n \tinode_lock(inode);\n-\tret = notify_change(\u0026nop_mnt_idmap, dentry, \u0026attrs, NULL);\n+\tret = notify_change(path, \u0026attrs, NULL);\n \tinode_unlock(inode);\n \treturn ret;\n }\n@@ -10531,7 +10533,7 @@ static int cb_getattr_update_times(struct dentry *dentry, struct nfs4_delegation\n  * caller must put the reference.\n  */\n __be32\n-nfsd4_deleg_getattr_conflict(struct svc_rqst *rqstp, struct dentry *dentry,\n+nfsd4_deleg_getattr_conflict(struct svc_rqst *rqstp, const struct path *path,\n \t\t\t     struct nfs4_delegation **pdp)\n {\n \tstruct nfsd_thread_local_info *ntli = rqstp-\u003erq_private;\n@@ -10539,7 +10541,7 @@ nfsd4_deleg_getattr_conflict(struct svc_rqst *rqstp, struct dentry *dentry,\n \tstruct nfs4_delegation *dp = NULL;\n \tstruct file_lease *fl;\n \tstruct nfs4_cb_fattr *ncf;\n-\tstruct inode *inode = d_inode(dentry);\n+\tstruct inode *inode = d_inode(path-\u003edentry);\n \t__be32 status;\n \n \tctx = locks_inode_context(inode);\n@@ -10603,7 +10605,7 @@ nfsd4_deleg_getattr_conflict(struct svc_rqst *rqstp, struct dentry *dentry,\n \t\t * not update the file's metadata with the client's\n \t\t * modified size\n \t\t */\n-\t\terr = cb_getattr_update_times(dentry, dp);\n+\t\terr = cb_getattr_update_times(path, dp);\n \t\tif (err) {\n \t\t\tstatus = nfserrno(err);\n \t\t\tgoto out_status;\n@@ -10789,7 +10791,7 @@ void nfsd_update_cmtime_attr(struct file *f, unsigned int flags)\n \t};\n \n \tinode_lock(inode);\n-\tret = notify_change(\u0026nop_mnt_idmap, f-\u003ef_path.dentry, \u0026attr, NULL);\n+\tret = notify_change(\u0026f-\u003ef_path, \u0026attr, NULL);\n \tinode_unlock(inode);\n \tif (ret)\n \t\tpr_notice_ratelimited(\"nfsd: Unable to update timestamps on \"\ndiff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c\nindex 84161dbecd1cb..2a86b69b2ae9b 100644\n--- a/fs/nfsd/nfs4xdr.c\n+++ b/fs/nfsd/nfs4xdr.c\n@@ -4083,7 +4083,7 @@ nfsd4_encode_fattr4(struct svc_rqst *rqstp, struct xdr_stream *xdr,\n \t    (attrmask[1] \u0026 (FATTR4_WORD1_TIME_ACCESS |\n \t\t\t    FATTR4_WORD1_TIME_MODIFY |\n \t\t\t    FATTR4_WORD1_TIME_METADATA))) {\n-\t\tstatus = nfsd4_deleg_getattr_conflict(rqstp, dentry, \u0026dp);\n+\t\tstatus = nfsd4_deleg_getattr_conflict(rqstp, \u0026path, \u0026dp);\n \t\tif (status)\n \t\t\tgoto out;\n \t}\ndiff --git a/fs/nfsd/state.h b/fs/nfsd/state.h\nindex cd9294f024bb9..183123f0b91f2 100644\n--- a/fs/nfsd/state.h\n+++ b/fs/nfsd/state.h\n@@ -1018,7 +1018,7 @@ static inline bool try_to_expire_client(struct nfs4_client *clp)\n }\n \n extern __be32 nfsd4_deleg_getattr_conflict(struct svc_rqst *rqstp,\n-\t\tstruct dentry *dentry, struct nfs4_delegation **pdp);\n+\t\tconst struct path *path, struct nfs4_delegation **pdp);\n \n struct nfsd4_get_dir_delegation;\n struct nfs4_delegation *nfsd_get_dir_deleg(struct nfsd4_compound_state *cstate,\ndiff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c\nindex 56c49b5bc5bb7..eb7dee641612c 100644\n--- a/fs/nfsd/vfs.c\n+++ b/fs/nfsd/vfs.c\n@@ -233,11 +233,13 @@ static int nfsd_lookup_parent(struct svc_rqst *rqstp, struct dentry *dparent, st\n  */\n int nfsd_mountpoint(struct dentry *dentry, struct svc_export *exp)\n {\n+\tstruct path path = { .mnt = exp-\u003eex_path.mnt, .dentry = dentry };\n+\n \tif (!d_inode(dentry))\n \t\treturn 0;\n \tif (exp-\u003eex_flags \u0026 NFSEXP_V4ROOT)\n \t\treturn 1;\n-\tif (nfsd4_is_junction(dentry))\n+\tif (nfsd4_is_junction(\u0026path))\n \t\treturn 1;\n \tif (d_managed(dentry))\n \t\t/*\n@@ -455,7 +457,7 @@ nfsd_get_write_access(struct svc_fh *fhp)\n \treturn nfserrno(get_write_access(d_inode(fhp-\u003efh_dentry)));\n }\n \n-static int __nfsd_setattr(struct dentry *dentry, struct iattr *iap)\n+static int __nfsd_setattr(const struct path *path, struct iattr *iap)\n {\n \tint host_err;\n \n@@ -475,7 +477,7 @@ static int __nfsd_setattr(struct dentry *dentry, struct iattr *iap)\n \t\tif (iap-\u003eia_size \u003c 0)\n \t\t\treturn -EFBIG;\n \n-\t\thost_err = notify_change(\u0026nop_mnt_idmap, dentry, \u0026size_attr, NULL);\n+\t\thost_err = notify_change(path, \u0026size_attr, NULL);\n \t\tif (host_err)\n \t\t\treturn host_err;\n \t\tiap-\u003eia_valid \u0026= ~ATTR_SIZE;\n@@ -501,7 +503,7 @@ static int __nfsd_setattr(struct dentry *dentry, struct iattr *iap)\n \tif (!(iap-\u003eia_valid \u0026 ATTR_DELEG))\n \t\tiap-\u003eia_valid |= ATTR_CTIME;\n \n-\treturn notify_change(\u0026nop_mnt_idmap, dentry, iap, NULL);\n+\treturn notify_change(path, iap, NULL);\n }\n \n /**\n@@ -524,6 +526,7 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp,\n {\n \tstruct dentry\t*dentry;\n \tstruct inode\t*inode;\n+\tstruct path\tpath;\n \tstruct iattr\t*iap = attr-\u003ena_iattr;\n \tint\t\taccmode = NFSD_MAY_SATTR;\n \tumode_t\t\tftype = 0;\n@@ -569,6 +572,11 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp,\n \tdentry = fhp-\u003efh_dentry;\n \tinode = d_inode(dentry);\n \n+\tpath = (struct path){\n+\t\t.mnt\t= fhp-\u003efh_export-\u003eex_path.mnt,\n+\t\t.dentry\t= dentry,\n+\t};\n+\n \tnfsd_sanitize_attrs(inode, iap);\n \n \t/*\n@@ -612,14 +620,14 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp,\n \t\t * copy for every loop iteration.\n \t\t */\n \t\tattrs = *iap;\n-\t\thost_err = __nfsd_setattr(dentry, \u0026attrs);\n+\t\thost_err = __nfsd_setattr(\u0026path, \u0026attrs);\n \t\tif (host_err != -EAGAIN || !retries--)\n \t\t\tbreak;\n \t\tif (!nfsd_wait_for_delegreturn(rqstp, inode))\n \t\t\tbreak;\n \t}\n \tif (attr-\u003ena_seclabel \u0026\u0026 attr-\u003ena_seclabel-\u003elen)\n-\t\tattr-\u003ena_labelerr = security_inode_setsecctx(dentry,\n+\t\tattr-\u003ena_labelerr = security_path_setsecctx(\u0026path,\n \t\t\tattr-\u003ena_seclabel-\u003edata, attr-\u003ena_seclabel-\u003elen);\n \tif (IS_ENABLED(CONFIG_FS_POSIX_ACL) \u0026\u0026 attr-\u003ena_dpacl) {\n \t\tif (!S_ISDIR(inode-\u003ei_mode))\n@@ -678,14 +686,14 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp,\n /**\n  * nfsd4_is_junction - Test if an object could be an NFS junction\n  *\n- * @dentry: object to test\n+ * @path: object to test\n  *\n- * Returns 1 if \"dentry\" appears to contain NFS junction information.\n+ * Returns 1 if \"path\" appears to contain NFS junction information.\n  * Otherwise 0 is returned.\n  */\n-int nfsd4_is_junction(struct dentry *dentry)\n+int nfsd4_is_junction(const struct path *path)\n {\n-\tstruct inode *inode = d_inode(dentry);\n+\tstruct inode *inode = d_inode(path-\u003edentry);\n \n \tif (inode == NULL)\n \t\treturn 0;\n@@ -693,8 +701,7 @@ int nfsd4_is_junction(struct dentry *dentry)\n \t\treturn 0;\n \tif (!(inode-\u003ei_mode \u0026 S_ISVTX))\n \t\treturn 0;\n-\tif (vfs_getxattr(\u0026nop_mnt_idmap, dentry, NFSD_JUNCTION_XATTR_NAME,\n-\t\t\t NULL, 0) \u003c= 0)\n+\tif (vfs_getxattr(path, NFSD_JUNCTION_XATTR_NAME, NULL, 0) \u003c= 0)\n \t\treturn 0;\n \treturn 1;\n }\n@@ -2646,19 +2653,20 @@ nfsd_getxattr(struct svc_rqst *rqstp, struct svc_fh *fhp, char *name,\n \t__be32 err;\n \tchar *buf;\n \tstruct inode *inode;\n-\tstruct dentry *dentry;\n+\tstruct path path;\n \n \terr = fh_verify(rqstp, fhp, 0, NFSD_MAY_READ);\n \tif (err)\n \t\treturn err;\n \n \terr = nfs_ok;\n-\tdentry = fhp-\u003efh_dentry;\n-\tinode = d_inode(dentry);\n+\tpath.mnt = fhp-\u003efh_export-\u003eex_path.mnt;\n+\tpath.dentry = fhp-\u003efh_dentry;\n+\tinode = d_inode(path.dentry);\n \n \tinode_lock_shared(inode);\n \n-\tlen = vfs_getxattr(\u0026nop_mnt_idmap, dentry, name, NULL, 0);\n+\tlen = vfs_getxattr(\u0026path, name, NULL, 0);\n \n \t/*\n \t * Zero-length attribute, just return.\n@@ -2685,7 +2693,7 @@ nfsd_getxattr(struct svc_rqst *rqstp, struct svc_fh *fhp, char *name,\n \t\tgoto out;\n \t}\n \n-\tlen = vfs_getxattr(\u0026nop_mnt_idmap, dentry, name, buf, len);\n+\tlen = vfs_getxattr(\u0026path, name, buf, len);\n \tif (len \u003c= 0) {\n \t\tkvfree(buf);\n \t\tbuf = NULL;\n@@ -2719,19 +2727,20 @@ nfsd_listxattr(struct svc_rqst *rqstp, struct svc_fh *fhp, char **bufp,\n \t__be32 err;\n \tchar *buf;\n \tstruct inode *inode;\n-\tstruct dentry *dentry;\n+\tstruct path path;\n \n \terr = fh_verify(rqstp, fhp, 0, NFSD_MAY_READ);\n \tif (err)\n \t\treturn err;\n \n-\tdentry = fhp-\u003efh_dentry;\n-\tinode = d_inode(dentry);\n+\tpath.mnt = fhp-\u003efh_export-\u003eex_path.mnt;\n+\tpath.dentry = fhp-\u003efh_dentry;\n+\tinode = d_inode(path.dentry);\n \t*lenp = 0;\n \n \tinode_lock_shared(inode);\n \n-\tlen = vfs_listxattr(dentry, NULL, 0);\n+\tlen = vfs_listxattr(\u0026path, NULL, 0);\n \tif (len \u003c= 0) {\n \t\terr = nfsd_xattr_errno(len);\n \t\tgoto out;\n@@ -2748,7 +2757,7 @@ nfsd_listxattr(struct svc_rqst *rqstp, struct svc_fh *fhp, char **bufp,\n \t\tgoto out;\n \t}\n \n-\tlen = vfs_listxattr(dentry, buf, len);\n+\tlen = vfs_listxattr(\u0026path, buf, len);\n \tif (len \u003c= 0) {\n \t\tkvfree(buf);\n \t\terr = nfsd_xattr_errno(len);\n@@ -2781,6 +2790,7 @@ nfsd_removexattr(struct svc_rqst *rqstp, struct svc_fh *fhp, char *name)\n {\n \t__be32 err;\n \tint ret;\n+\tstruct path path;\n \n \terr = fh_verify(rqstp, fhp, 0, NFSD_MAY_WRITE);\n \tif (err)\n@@ -2790,16 +2800,17 @@ nfsd_removexattr(struct svc_rqst *rqstp, struct svc_fh *fhp, char *name)\n \tif (ret)\n \t\treturn nfserrno(ret);\n \n-\tinode_lock(fhp-\u003efh_dentry-\u003ed_inode);\n+\tpath.mnt = fhp-\u003efh_export-\u003eex_path.mnt;\n+\tpath.dentry = fhp-\u003efh_dentry;\n+\tinode_lock(d_inode(path.dentry));\n \terr = fh_fill_pre_attrs(fhp);\n \tif (err != nfs_ok)\n \t\tgoto out_unlock;\n-\tret = __vfs_removexattr_locked(\u0026nop_mnt_idmap, fhp-\u003efh_dentry,\n-\t\t\t\t       name, NULL);\n+\tret = __vfs_removexattr_locked(\u0026path, name, NULL);\n \terr = nfsd_xattr_errno(ret);\n \tfh_fill_post_attrs(fhp);\n out_unlock:\n-\tinode_unlock(fhp-\u003efh_dentry-\u003ed_inode);\n+\tinode_unlock(d_inode(path.dentry));\n \tfh_drop_write(fhp);\n \n \treturn err;\n@@ -2811,6 +2822,7 @@ nfsd_setxattr(struct svc_rqst *rqstp, struct svc_fh *fhp, char *name,\n {\n \t__be32 err;\n \tint ret;\n+\tstruct path path;\n \n \terr = fh_verify(rqstp, fhp, 0, NFSD_MAY_WRITE);\n \tif (err)\n@@ -2819,16 +2831,17 @@ nfsd_setxattr(struct svc_rqst *rqstp, struct svc_fh *fhp, char *name,\n \tret = fh_want_write(fhp);\n \tif (ret)\n \t\treturn nfserrno(ret);\n-\tinode_lock(fhp-\u003efh_dentry-\u003ed_inode);\n+\tpath.mnt = fhp-\u003efh_export-\u003eex_path.mnt;\n+\tpath.dentry = fhp-\u003efh_dentry;\n+\tinode_lock(d_inode(path.dentry));\n \terr = fh_fill_pre_attrs(fhp);\n \tif (err != nfs_ok)\n \t\tgoto out_unlock;\n-\tret = __vfs_setxattr_locked(\u0026nop_mnt_idmap, fhp-\u003efh_dentry,\n-\t\t\t\t    name, buf, len, flags, NULL);\n+\tret = __vfs_setxattr_locked(\u0026path, name, buf, len, flags, NULL);\n \tfh_fill_post_attrs(fhp);\n \terr = nfsd_xattr_errno(ret);\n out_unlock:\n-\tinode_unlock(fhp-\u003efh_dentry-\u003ed_inode);\n+\tinode_unlock(d_inode(path.dentry));\n \tfh_drop_write(fhp);\n \treturn err;\n }\n@@ -2967,7 +2980,7 @@ nfsd_get_case_info(struct dentry *dentry, bool *case_insensitive,\n \t}\n \tsaved = override_creds(probe);\n \n-\terr = vfs_fileattr_get(cd, \u0026fa);\n+\terr = __vfs_fileattr_get(cd, \u0026fa);\n \n \tput_cred(revert_creds(saved));\n out:\ndiff --git a/fs/ntfs/named_stream.c b/fs/ntfs/named_stream.c\nindex 95a3c05f98211..f0b577a6f7c3e 100644\n--- a/fs/ntfs/named_stream.c\n+++ b/fs/ntfs/named_stream.c\n@@ -897,7 +897,7 @@ static int ntfs_stream_setattr_common(const struct mnt_idmap *idmap,\n \t\t\tgoto out;\n \t\t}\n \t\tif (base_attr.ia_valid)\n-\t\t\terr = notify_change(idmap, base_dentry, \u0026base_attr,\n+\t\t\terr = __notify_change(idmap, base_dentry, \u0026base_attr,\n \t\t\t\t\tNULL);\n \t\telse\n \t\t\terr = 0;\ndiff --git a/fs/open.c b/fs/open.c\nindex bf398105f03a0..97a5f770fa045 100644\n--- a/fs/open.c\n+++ b/fs/open.c\n@@ -36,10 +36,12 @@\n \n #include \"internal.h\"\n \n-int do_truncate(const struct mnt_idmap *idmap, struct dentry *dentry,\n-\t\tloff_t length, unsigned int time_attrs, struct file *filp)\n+int do_truncate(const struct path *path, loff_t length,\n+\t\tunsigned int time_attrs, struct file *filp)\n {\n \tint ret;\n+\tconst struct mnt_idmap *idmap = mnt_idmap(path-\u003emnt);\n+\tstruct dentry *dentry = path-\u003edentry;\n \tstruct iattr newattrs;\n \n \t/* Not pretty: \"inode-\u003ei_size\" shouldn't really be signed. But it is. */\n@@ -65,7 +67,7 @@ int do_truncate(const struct mnt_idmap *idmap, struct dentry *dentry,\n \t\treturn ret;\n \n \t/* Note any delegations or leases have already been broken: */\n-\tret = notify_change(idmap, dentry, \u0026newattrs, NULL);\n+\tret = notify_change(path, \u0026newattrs, NULL);\n \tinode_unlock(dentry-\u003ed_inode);\n \treturn ret;\n }\n@@ -115,7 +117,7 @@ int vfs_truncate(const struct path *path, loff_t length)\n \n \terror = security_path_truncate(path);\n \tif (!error)\n-\t\terror = do_truncate(idmap, path-\u003edentry, length, 0, NULL);\n+\t\terror = do_truncate(path, length, 0, NULL);\n \n put_write_and_out:\n \tput_write_access(inode);\n@@ -191,7 +193,7 @@ int do_ftruncate(struct file *file, loff_t length, unsigned int flags)\n \t\treturn error;\n \n \tscoped_guard(super_write, inode-\u003ei_sb)\n-\t\treturn do_truncate(file_mnt_idmap(file), dentry, length,\n+\t\treturn do_truncate(\u0026file-\u003ef_path, length,\n \t\t\t\t   ATTR_MTIME | ATTR_CTIME, file);\n }\n \n@@ -683,8 +685,7 @@ int chmod_common(const struct path *path, umode_t mode)\n \t\tgoto out_unlock;\n \tnewattrs.ia_mode = (mode \u0026 S_IALLUGO) | (inode-\u003ei_mode \u0026 ~S_IALLUGO);\n \tnewattrs.ia_valid = ATTR_MODE | ATTR_CTIME;\n-\terror = notify_change(mnt_idmap(path-\u003emnt), path-\u003edentry,\n-\t\t\t      \u0026newattrs, \u0026delegated_inode);\n+\terror = notify_change(path, \u0026newattrs, \u0026delegated_inode);\n out_unlock:\n \tinode_unlock(inode);\n \tif (is_delegated(\u0026delegated_inode)) {\n@@ -822,8 +823,7 @@ int chown_common(const struct path *path, uid_t user, gid_t group)\n \t\tfrom_vfsuid(idmap, fs_userns, newattrs.ia_vfsuid),\n \t\tfrom_vfsgid(idmap, fs_userns, newattrs.ia_vfsgid));\n \tif (!error)\n-\t\terror = notify_change(idmap, path-\u003edentry, \u0026newattrs,\n-\t\t\t\t      \u0026delegated_inode);\n+\t\terror = notify_change(path, \u0026newattrs, \u0026delegated_inode);\n \tinode_unlock(inode);\n \tif (is_delegated(\u0026delegated_inode)) {\n \t\terror = break_deleg_wait(\u0026delegated_inode);\ndiff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c\nindex e963701b4c877..6dc241f195a66 100644\n--- a/fs/overlayfs/copy_up.c\n+++ b/fs/overlayfs/copy_up.c\n@@ -83,7 +83,7 @@ int ovl_copy_xattr(struct super_block *sb, const struct path *oldpath, struct de\n \tif (!old-\u003ed_inode-\u003ei_op-\u003elistxattr || !new-\u003ed_inode-\u003ei_op-\u003elistxattr)\n \t\treturn 0;\n \n-\tlist_size = vfs_listxattr(old, NULL, 0);\n+\tlist_size = vfs_listxattr(oldpath, NULL, 0);\n \tif (list_size \u003c= 0) {\n \t\tif (list_size == -EOPNOTSUPP)\n \t\t\treturn 0;\n@@ -94,7 +94,7 @@ int ovl_copy_xattr(struct super_block *sb, const struct path *oldpath, struct de\n \tif (!buf)\n \t\treturn -ENOMEM;\n \n-\tlist_size = vfs_listxattr(old, buf, list_size);\n+\tlist_size = vfs_listxattr(oldpath, buf, list_size);\n \tif (list_size \u003c= 0) {\n \t\terror = list_size;\n \t\tgoto out;\ndiff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c\nindex 70183d516e5e9..9e89aeabeaa85 100644\n--- a/fs/overlayfs/inode.c\n+++ b/fs/overlayfs/inode.c\n@@ -392,7 +392,7 @@ static void ovl_idmap_posix_acl(const struct inode *realinode,\n  * \u003e and following it on overlayfs.\n  * \u003e\n  * \u003e Applying the same logic to acl: we do need to call the\n- * \u003e security_inode_getxattr() on the underlying fs, even if just want to\n+ * \u003e security_path_getxattr() on the underlying fs, even if just want to\n  * \u003e check permissions on overlay. This is currently not done, which is an\n  * \u003e inconsistency.\n  * \u003e\n@@ -414,7 +414,7 @@ struct posix_acl *ovl_get_acl_path(const struct path *path,\n \tif (noperm)\n \t\treal_acl = get_inode_acl(realinode, posix_acl_type(acl_name));\n \telse\n-\t\treal_acl = vfs_get_acl(idmap, path-\u003edentry, acl_name);\n+\t\treal_acl = vfs_get_acl(path, acl_name);\n \tif (IS_ERR_OR_NULL(real_acl))\n \t\treturn real_acl;\n \n@@ -502,7 +502,7 @@ static int ovl_set_or_remove_acl(struct dentry *dentry, struct inode *inode,\n \n \t\tovl_path_lower(dentry, \u0026realpath);\n \t\twith_ovl_creds(dentry-\u003ed_sb)\n-\t\t\treal_acl = vfs_get_acl(mnt_idmap(realpath.mnt), realdentry, acl_name);\n+\t\t\treal_acl = vfs_get_acl(\u0026realpath, acl_name);\n \t\tif (IS_ERR(real_acl)) {\n \t\t\terr = PTR_ERR(real_acl);\n \t\t\tgoto out;\n@@ -607,47 +607,10 @@ static int ovl_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,\n \t\treturn realinode-\u003ei_op-\u003efiemap(realinode, fieinfo, start, len);\n }\n \n-/*\n- * Work around the fact that security_file_ioctl() takes a file argument.\n- * Introducing security_inode_fileattr_get/set() hooks would solve this issue\n- * properly.\n- */\n-static int ovl_security_fileattr(const struct path *realpath, struct file_kattr *fa,\n-\t\t\t\t bool set)\n-{\n-\tstruct file *file;\n-\tunsigned int cmd;\n-\tint err;\n-\tunsigned int flags;\n-\n-\tflags = O_RDONLY;\n-\tif (force_o_largefile())\n-\t\tflags |= O_LARGEFILE;\n-\n-\tfile = dentry_open(realpath, flags, current_cred());\n-\tif (IS_ERR(file))\n-\t\treturn PTR_ERR(file);\n-\n-\tif (set)\n-\t\tcmd = fa-\u003efsx_valid ? FS_IOC_FSSETXATTR : FS_IOC_SETFLAGS;\n-\telse\n-\t\tcmd = fa-\u003efsx_valid ? FS_IOC_FSGETXATTR : FS_IOC_GETFLAGS;\n-\n-\terr = security_file_ioctl(file, cmd, 0);\n-\tfput(file);\n-\n-\treturn err;\n-}\n-\n int ovl_real_fileattr_set(const struct path *realpath, struct file_kattr *fa)\n {\n-\tint err;\n-\n-\terr = ovl_security_fileattr(realpath, fa, true);\n-\tif (err)\n-\t\treturn err;\n-\n-\treturn vfs_fileattr_set(mnt_idmap(realpath-\u003emnt), realpath-\u003edentry, fa);\n+\treturn __vfs_fileattr_set(mnt_idmap(realpath-\u003emnt), realpath-\u003edentry,\n+\t\t\t\t  fa);\n }\n \n int ovl_fileattr_set(const struct mnt_idmap *idmap,\n@@ -717,11 +680,7 @@ int ovl_real_fileattr_get(const struct path *realpath, struct file_kattr *fa)\n {\n \tint err;\n \n-\terr = ovl_security_fileattr(realpath, fa, false);\n-\tif (err)\n-\t\treturn err;\n-\n-\terr = vfs_fileattr_get(realpath-\u003edentry, fa);\n+\terr = __vfs_fileattr_get(realpath-\u003edentry, fa);\n \tif (err == -ENOIOCTLCMD)\n \t\terr = -ENOTTY;\n \treturn err;\ndiff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h\nindex 53fbbe15c31df..230070f6caa99 100644\n--- a/fs/overlayfs/overlayfs.h\n+++ b/fs/overlayfs/overlayfs.h\n@@ -206,7 +206,12 @@ static inline int ovl_do_notify_change(struct ovl_fs *ofs,\n \t\t\t\t       struct dentry *upperdentry,\n \t\t\t\t       struct iattr *attr)\n {\n-\treturn notify_change(ovl_upper_mnt_idmap(ofs), upperdentry, attr, NULL);\n+\tstruct path path = {\n+\t\t.mnt = ovl_upper_mnt(ofs),\n+\t\t.dentry = upperdentry,\n+\t};\n+\n+\treturn notify_change(\u0026path, attr, NULL);\n }\n \n static inline int ovl_do_rmdir(struct ovl_fs *ofs,\n@@ -288,8 +293,7 @@ static inline ssize_t ovl_do_getxattr(const struct path *path, const char *name,\n \n \tWARN_ON(path-\u003edentry-\u003ed_sb != path-\u003emnt-\u003emnt_sb);\n \n-\terr = vfs_getxattr(mnt_idmap(path-\u003emnt), path-\u003edentry,\n-\t\t\t       name, value, size);\n+\terr = vfs_getxattr(path, name, value, size);\n \tlen = (value \u0026\u0026 err \u003e 0) ? err : 0;\n \n \tpr_debug(\"getxattr(%pd2, \\\"%s\\\", \\\"%*pE\\\", %zu, 0) = %i\\n\",\n@@ -322,9 +326,13 @@ static inline int ovl_do_setxattr(struct ovl_fs *ofs, struct dentry *dentry,\n \t\t\t\t  const char *name, const void *value,\n \t\t\t\t  size_t size, int flags)\n {\n+\tstruct path path = {\n+\t\t.mnt = ovl_upper_mnt(ofs),\n+\t\t.dentry = dentry,\n+\t};\n+\n \t/* Use vfs_setxattr(), not __vfs_setxattr(): it idmaps the security.capability rootid. */\n-\tint err = vfs_setxattr(ovl_upper_mnt_idmap(ofs), dentry, name,\n-\t\t\t       value, size, flags);\n+\tint err = vfs_setxattr(\u0026path, name, value, size, flags);\n \n \tpr_debug(\"setxattr(%pd2, \\\"%s\\\", \\\"%*pE\\\", %zu, %d) = %i\\n\",\n \t\t dentry, name, min((int)size, 48), value, size, flags, err);\n@@ -341,7 +349,12 @@ static inline int ovl_setxattr(struct ovl_fs *ofs, struct dentry *dentry,\n static inline int ovl_do_removexattr(struct ovl_fs *ofs, struct dentry *dentry,\n \t\t\t\t     const char *name)\n {\n-\tint err = vfs_removexattr(ovl_upper_mnt_idmap(ofs), dentry, name);\n+\tstruct path path = {\n+\t\t.mnt = ovl_upper_mnt(ofs),\n+\t\t.dentry = dentry,\n+\t};\n+\n+\tint err = vfs_removexattr(\u0026path, name);\n \tpr_debug(\"removexattr(%pd2, \\\"%s\\\") = %i\\n\", dentry, name, err);\n \treturn err;\n }\n@@ -355,13 +368,23 @@ static inline int ovl_removexattr(struct ovl_fs *ofs, struct dentry *dentry,\n static inline int ovl_do_set_acl(struct ovl_fs *ofs, struct dentry *dentry,\n \t\t\t\t const char *acl_name, struct posix_acl *acl)\n {\n-\treturn vfs_set_acl(ovl_upper_mnt_idmap(ofs), dentry, acl_name, acl);\n+\tstruct path path = {\n+\t\t.mnt = ovl_upper_mnt(ofs),\n+\t\t.dentry = dentry,\n+\t};\n+\n+\treturn vfs_set_acl(\u0026path, acl_name, acl);\n }\n \n static inline int ovl_do_remove_acl(struct ovl_fs *ofs, struct dentry *dentry,\n \t\t\t\t    const char *acl_name)\n {\n-\treturn vfs_remove_acl(ovl_upper_mnt_idmap(ofs), dentry, acl_name);\n+\tstruct path path = {\n+\t\t.mnt = ovl_upper_mnt(ofs),\n+\t\t.dentry = dentry,\n+\t};\n+\n+\treturn vfs_remove_acl(\u0026path, acl_name);\n }\n \n static inline int ovl_do_rename_rd(struct renamedata *rd)\ndiff --git a/fs/overlayfs/xattrs.c b/fs/overlayfs/xattrs.c\nindex acc54f6138ef5..6fbd0cbce10d5 100644\n--- a/fs/overlayfs/xattrs.c\n+++ b/fs/overlayfs/xattrs.c\n@@ -45,7 +45,7 @@ static int ovl_xattr_set(struct dentry *dentry, struct inode *inode, const char\n \tif (!value \u0026\u0026 !upperdentry) {\n \t\tovl_path_lower(dentry, \u0026realpath);\n \t\twith_ovl_creds(dentry-\u003ed_sb)\n-\t\t\terr = vfs_getxattr(mnt_idmap(realpath.mnt), realdentry, name, NULL, 0);\n+\t\t\terr = vfs_getxattr(\u0026realpath, name, NULL, 0);\n \t\tif (err \u003c 0)\n \t\t\tgoto out;\n \t}\n@@ -86,7 +86,7 @@ static int ovl_xattr_get(struct dentry *dentry, struct inode *inode, const char\n \tovl_i_path_real(inode, \u0026realpath);\n \t/* Use vfs_getxattr(), not __vfs_getxattr(): it idmaps the security.capability rootid. */\n \twith_ovl_creds(dentry-\u003ed_sb)\n-\t\treturn vfs_getxattr(mnt_idmap(realpath.mnt), realpath.dentry, name, value, size);\n+\t\treturn vfs_getxattr(\u0026realpath, name, value, size);\n }\n \n static bool ovl_can_list(struct super_block *sb, const char *s)\n@@ -105,15 +105,17 @@ static bool ovl_can_list(struct super_block *sb, const char *s)\n \n ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size)\n {\n-\tstruct dentry *realdentry = ovl_dentry_real(dentry);\n+\tstruct path realpath;\n \tstruct ovl_fs *ofs = OVL_FS(dentry-\u003ed_sb);\n \tssize_t res;\n \tsize_t len;\n \tchar *s;\n \tsize_t prefix_len, name_len;\n \n+\tovl_path_real(dentry, \u0026realpath);\n+\n \twith_ovl_creds(dentry-\u003ed_sb)\n-\t\tres = vfs_listxattr(realdentry, list, size);\n+\t\tres = vfs_listxattr(\u0026realpath, list, size);\n \tif (res \u003c= 0 || size == 0)\n \t\treturn res;\n \ndiff --git a/fs/posix_acl.c b/fs/posix_acl.c\nindex fe77934ea8f20..d4715c383e041 100644\n--- a/fs/posix_acl.c\n+++ b/fs/posix_acl.c\n@@ -1081,8 +1081,7 @@ static int vfs_set_acl_idmapped_mnt(const struct mnt_idmap *idmap,\n \n /**\n  * vfs_set_acl - set posix acls\n- * @idmap: idmap of the mount\n- * @dentry: the dentry based on which to set the posix acls\n+ * @path: the path based on which to set the posix acls\n  * @acl_name: the name of the posix acl\n  * @kacl: the posix acls in the appropriate VFS format\n  *\n@@ -1091,9 +1090,11 @@ static int vfs_set_acl_idmapped_mnt(const struct mnt_idmap *idmap,\n  *\n  * Return: On success 0, on error negative errno.\n  */\n-int vfs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,\n-\t\tconst char *acl_name, struct posix_acl *kacl)\n+int vfs_set_acl(const struct path *path, const char *acl_name,\n+\t\tstruct posix_acl *kacl)\n {\n+\tconst struct mnt_idmap *idmap = mnt_idmap(path-\u003emnt);\n+\tstruct dentry *dentry = path-\u003edentry;\n \tint acl_type;\n \tint error;\n \tstruct inode *inode = d_inode(dentry);\n@@ -1127,7 +1128,7 @@ int vfs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,\n \tif (error)\n \t\tgoto out_inode_unlock;\n \n-\terror = security_inode_set_acl(idmap, dentry, acl_name, kacl);\n+\terror = security_path_set_acl(path, acl_name, kacl);\n \tif (error)\n \t\tgoto out_inode_unlock;\n \n@@ -1159,8 +1160,7 @@ EXPORT_SYMBOL_GPL(vfs_set_acl);\n \n /**\n  * vfs_get_acl - get posix acls\n- * @idmap: idmap of the mount\n- * @dentry: the dentry based on which to retrieve the posix acls\n+ * @path: the path based on which to retrieve the posix acls\n  * @acl_name: the name of the posix acl\n  *\n  * This function retrieves @kacl from the filesystem. The caller must all\n@@ -1168,9 +1168,10 @@ EXPORT_SYMBOL_GPL(vfs_set_acl);\n  *\n  * Return: On success POSIX ACLs in VFS format, on error negative errno.\n  */\n-struct posix_acl *vfs_get_acl(const struct mnt_idmap *idmap,\n-\t\t\t      struct dentry *dentry, const char *acl_name)\n+struct posix_acl *vfs_get_acl(const struct path *path, const char *acl_name)\n {\n+\tconst struct mnt_idmap *idmap = mnt_idmap(path-\u003emnt);\n+\tstruct dentry *dentry = path-\u003edentry;\n \tstruct inode *inode = d_inode(dentry);\n \tstruct posix_acl *acl;\n \tint acl_type, error;\n@@ -1183,7 +1184,7 @@ struct posix_acl *vfs_get_acl(const struct mnt_idmap *idmap,\n \t * The VFS has no restrictions on reading POSIX ACLs so calling\n \t * something like xattr_permission() isn't needed. Only LSMs get a say.\n \t */\n-\terror = security_inode_get_acl(idmap, dentry, acl_name);\n+\terror = security_path_get_acl(path, acl_name);\n \tif (error)\n \t\treturn ERR_PTR(error);\n \n@@ -1204,17 +1205,17 @@ EXPORT_SYMBOL_GPL(vfs_get_acl);\n \n /**\n  * vfs_remove_acl - remove posix acls\n- * @idmap: idmap of the mount\n- * @dentry: the dentry based on which to retrieve the posix acls\n+ * @path: the path based on which to retrieve the posix acls\n  * @acl_name: the name of the posix acl\n  *\n  * This function removes posix acls.\n  *\n  * Return: On success 0, on error negative errno.\n  */\n-int vfs_remove_acl(const struct mnt_idmap *idmap, struct dentry *dentry,\n-\t\t   const char *acl_name)\n+int vfs_remove_acl(const struct path *path, const char *acl_name)\n {\n+\tconst struct mnt_idmap *idmap = mnt_idmap(path-\u003emnt);\n+\tstruct dentry *dentry = path-\u003edentry;\n \tint acl_type;\n \tint error;\n \tstruct inode *inode = d_inode(dentry);\n@@ -1235,7 +1236,7 @@ int vfs_remove_acl(const struct mnt_idmap *idmap, struct dentry *dentry,\n \tif (error)\n \t\tgoto out_inode_unlock;\n \n-\terror = security_inode_remove_acl(idmap, dentry, acl_name);\n+\terror = security_path_remove_acl(path, acl_name);\n \tif (error)\n \t\tgoto out_inode_unlock;\n \n@@ -1265,8 +1266,8 @@ int vfs_remove_acl(const struct mnt_idmap *idmap, struct dentry *dentry,\n }\n EXPORT_SYMBOL_GPL(vfs_remove_acl);\n \n-int do_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,\n-\t       const char *acl_name, const void *kvalue, size_t size)\n+int do_set_acl(const struct path *path, const char *acl_name,\n+\t       const void *kvalue, size_t size)\n {\n \tint error;\n \tstruct posix_acl *acl = NULL;\n@@ -1281,22 +1282,23 @@ int do_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,\n \t\t\treturn PTR_ERR(acl);\n \t}\n \n-\terror = vfs_set_acl(idmap, dentry, acl_name, acl);\n+\terror = vfs_set_acl(path, acl_name, acl);\n \tposix_acl_release(acl);\n \treturn error;\n }\n \n-ssize_t do_get_acl(const struct mnt_idmap *idmap, struct dentry *dentry,\n-\t\t   const char *acl_name, void *kvalue, size_t size)\n+ssize_t do_get_acl(const struct path *path, const char *acl_name,\n+\t\t   void *kvalue, size_t size)\n {\n \tssize_t error;\n \tstruct posix_acl *acl;\n \n-\tacl = vfs_get_acl(idmap, dentry, acl_name);\n+\tacl = vfs_get_acl(path, acl_name);\n \tif (IS_ERR(acl))\n \t\treturn PTR_ERR(acl);\n \n-\terror = vfs_posix_acl_to_xattr(idmap, d_inode(dentry),\n+\terror = vfs_posix_acl_to_xattr(mnt_idmap(path-\u003emnt),\n+\t\t\t\t       d_inode(path-\u003edentry),\n \t\t\t\t       acl, kvalue, size);\n \tposix_acl_release(acl);\n \treturn error;\ndiff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c\nindex b57942263e130..6c8a6f8f27eef 100644\n--- a/fs/smb/server/smb2pdu.c\n+++ b/fs/smb/server/smb2pdu.c\n@@ -3297,7 +3297,6 @@ static bool smb2_is_private_ea(const char *name, size_t name_len)\n static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len,\n \t\t       const struct path *path, bool get_write)\n {\n-\tconst struct mnt_idmap *idmap = mnt_idmap(path-\u003emnt);\n \tchar *attr_name = NULL, *value;\n \tint rc = 0;\n \tunsigned int next = 0;\n@@ -3337,16 +3336,14 @@ static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len,\n \t\tvalue = (char *)\u0026eabuf-\u003ename + eabuf-\u003eEaNameLength + 1;\n \n \t\tif (!eabuf-\u003eEaValueLength) {\n-\t\t\trc = ksmbd_vfs_casexattr_len(idmap,\n-\t\t\t\t\t\t     path-\u003edentry,\n+\t\t\trc = ksmbd_vfs_casexattr_len(path,\n \t\t\t\t\t\t     attr_name,\n \t\t\t\t\t\t     XATTR_USER_PREFIX_LEN +\n \t\t\t\t\t\t     eabuf-\u003eEaNameLength, NULL);\n \n \t\t\t/* delete the EA only when it exits */\n \t\t\tif (rc \u003e 0) {\n-\t\t\t\trc = ksmbd_vfs_remove_xattr(idmap,\n-\t\t\t\t\t\t\t    path,\n+\t\t\t\trc = ksmbd_vfs_remove_xattr(path,\n \t\t\t\t\t\t\t    attr_name,\n \t\t\t\t\t\t\t    get_write);\n \n@@ -3361,7 +3358,7 @@ static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len,\n \t\t\t/* if the EA doesn't exist, just do nothing. */\n \t\t\trc = 0;\n \t\t} else {\n-\t\t\trc = ksmbd_vfs_setxattr(idmap, path, attr_name, value,\n+\t\t\trc = ksmbd_vfs_setxattr(path, attr_name, value,\n \t\t\t\t\t\tle16_to_cpu(eabuf-\u003eEaValueLength),\n \t\t\t\t\t\t0, get_write);\n \t\t\tif (rc \u003c 0) {\n@@ -3398,7 +3395,6 @@ static noinline int smb2_set_stream_name_xattr(const struct path *path,\n \t\t\t\t\t       struct ksmbd_file *fp,\n \t\t\t\t\t       char *stream_name, int s_type)\n {\n-\tconst struct mnt_idmap *idmap = mnt_idmap(path-\u003emnt);\n \tsize_t xattr_stream_size;\n \tchar *xattr_stream_name;\n \tint rc;\n@@ -3414,8 +3410,7 @@ static noinline int smb2_set_stream_name_xattr(const struct path *path,\n \tfp-\u003estream.size = xattr_stream_size;\n \n \t/* Keep the existing xattr's case for subsequent writes and removal. */\n-\trc = ksmbd_vfs_casexattr_len(idmap,\n-\t\t\t\t     path-\u003edentry,\n+\trc = ksmbd_vfs_casexattr_len(path,\n \t\t\t\t     xattr_stream_name,\n \t\t\t\t     xattr_stream_size, xattr_stream_name);\n \tif (rc \u003e= 0)\n@@ -3444,7 +3439,7 @@ static noinline int smb2_set_stream_name_xattr(const struct path *path,\n \t\t\t\t0x00, 0x00, 0x01, 0x00,\t/* version */\n \t\t\t\t[15] = 0x80,\t\t/* backup time */\n \t\t\t};\n-\t\t\trc = ksmbd_vfs_setxattr(idmap, path, xattr_stream_name,\n+\t\t\trc = ksmbd_vfs_setxattr(path, xattr_stream_name,\n \t\t\t\t\t\t(void *)afpinfo_empty,\n \t\t\t\t\t\tsizeof(afpinfo_empty), 0, false);\n \t\t\treturn rc \u003c 0 ? rc : 0;\n@@ -3453,7 +3448,7 @@ static noinline int smb2_set_stream_name_xattr(const struct path *path,\n \t\treturn -EBADF;\n \t}\n \n-\trc = ksmbd_vfs_setxattr(idmap, path, xattr_stream_name, NULL, 0, 0, false);\n+\trc = ksmbd_vfs_setxattr(path, xattr_stream_name, NULL, 0, 0, false);\n \tif (rc \u003c 0)\n \t\tpr_err(\"Failed to store XATTR stream name :%d\\n\", rc);\n \treturn 0;\n@@ -3468,8 +3463,7 @@ static noinline int smb2_set_stream_name_xattr(const struct path *path,\n  */\n static loff_t ksmbd_stream_eof(struct ksmbd_file *fp)\n {\n-\tssize_t slen = ksmbd_vfs_casexattr_len(file_mnt_idmap(fp-\u003efilp),\n-\t\t\t\t\t       fp-\u003efilp-\u003ef_path.dentry,\n+\tssize_t slen = ksmbd_vfs_casexattr_len(\u0026fp-\u003efilp-\u003ef_path,\n \t\t\t\t\t       fp-\u003estream.name,\n \t\t\t\t\t       fp-\u003estream.size, NULL);\n \treturn slen \u003c 0 ? 0 : (loff_t)slen;\n@@ -3477,12 +3471,11 @@ static loff_t ksmbd_stream_eof(struct ksmbd_file *fp)\n \n static int smb2_remove_smb_xattrs(const struct path *path)\n {\n-\tconst struct mnt_idmap *idmap = mnt_idmap(path-\u003emnt);\n \tchar *name, *xattr_list = NULL;\n \tssize_t xattr_list_len;\n \tint err = 0;\n \n-\txattr_list_len = ksmbd_vfs_listxattr(path-\u003edentry, \u0026xattr_list);\n+\txattr_list_len = ksmbd_vfs_listxattr(path, \u0026xattr_list);\n \tif (xattr_list_len \u003c 0) {\n \t\tgoto out;\n \t} else if (!xattr_list_len) {\n@@ -3497,8 +3490,7 @@ static int smb2_remove_smb_xattrs(const struct path *path)\n \t\tif (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN) \u0026\u0026\n \t\t    !strncmp(\u0026name[XATTR_USER_PREFIX_LEN], STREAM_PREFIX,\n \t\t\t     STREAM_PREFIX_LEN)) {\n-\t\t\terr = ksmbd_vfs_remove_xattr(idmap, path,\n-\t\t\t\t\t\t     name, true);\n+\t\t\terr = ksmbd_vfs_remove_xattr(path, name, true);\n \t\t\tif (err)\n \t\t\t\tksmbd_debug(SMB, \"remove xattr failed : %s\\n\",\n \t\t\t\t\t    name);\n@@ -3544,7 +3536,7 @@ static void smb2_new_xattrs(struct ksmbd_tree_connect *tcon, const struct path *\n \tda.flags = XATTR_DOSINFO_ATTRIB | XATTR_DOSINFO_CREATE_TIME |\n \t\tXATTR_DOSINFO_ITIME;\n \n-\trc = ksmbd_vfs_set_dos_attrib_xattr(mnt_idmap(path-\u003emnt), path, \u0026da, true);\n+\trc = ksmbd_vfs_set_dos_attrib_xattr(path, \u0026da, true);\n \tif (rc)\n \t\tksmbd_debug(SMB, \"failed to store file attribute into xattr\\n\");\n }\n@@ -3553,18 +3545,19 @@ static bool smb2_parent_compressed(struct ksmbd_tree_connect *tcon,\n \t\t\t\t   const struct path *path)\n {\n \tstruct dentry *parent = dget_parent(path-\u003edentry);\n+\tstruct path parent_path = { .mnt = path-\u003emnt, .dentry = parent };\n \tstruct file_kattr fa = { .flags_valid = true };\n \tstruct xattr_dos_attrib da;\n \tbool compressed = false;\n \tint rc;\n \n-\trc = vfs_fileattr_get(parent, \u0026fa);\n+\trc = vfs_fileattr_get(\u0026parent_path, \u0026fa);\n \tif (!rc \u0026\u0026 fa.flags \u0026 FS_COMPR_FL) {\n \t\tcompressed = true;\n \t\tgoto out;\n \t}\n \n-\trc = ksmbd_vfs_get_dos_attrib_xattr(mnt_idmap(path-\u003emnt), parent, \u0026da);\n+\trc = ksmbd_vfs_get_dos_attrib_xattr(\u0026parent_path, \u0026da);\n \tif (rc \u003e 0 \u0026\u0026 da.attr \u0026 FILE_ATTRIBUTE_COMPRESSED)\n \t\tcompressed = true;\n \n@@ -3584,8 +3577,7 @@ static void smb2_update_xattrs(struct ksmbd_tree_connect *tcon,\n \tfp-\u003ef_ci-\u003em_fattr \u0026= ~(FILE_ATTRIBUTE_HIDDEN_LE | FILE_ATTRIBUTE_SYSTEM_LE);\n \n \t/* get FileAttributes from XATTR_NAME_DOS_ATTRIBUTE */\n-\trc = ksmbd_vfs_get_dos_attrib_xattr(mnt_idmap(path-\u003emnt),\n-\t\t\t\t\t    path-\u003edentry, \u0026da);\n+\trc = ksmbd_vfs_get_dos_attrib_xattr(path, \u0026da);\n \tif (rc \u003e 0) {\n \t\tif (store_dos_attrs) {\n \t\t\tfp-\u003ef_ci-\u003em_fattr = cpu_to_le32(da.attr);\n@@ -4623,8 +4615,7 @@ int smb2_open(struct ksmbd_work *work)\n \n \t\t\tif (test_share_config_flag(tcon-\u003eshare_conf,\n \t\t\t\t\t\t   KSMBD_SHARE_FLAG_STORE_DOS_ATTRS) \u0026\u0026\n-\t\t\t    ksmbd_vfs_get_dos_attrib_xattr(mnt_idmap(path.mnt),\n-\t\t\t\t\t\t\t path.dentry, \u0026da) \u003e 0 \u0026\u0026\n+\t\t\t    ksmbd_vfs_get_dos_attrib_xattr(\u0026path, \u0026da) \u003e 0 \u0026\u0026\n \t\t\t    da.attr \u0026 FILE_ATTRIBUTE_READONLY) {\n \t\t\t\trsp-\u003ehdr.Status = STATUS_CANNOT_DELETE;\n \t\t\t\trc = -EACCES;\n@@ -4962,7 +4953,6 @@ int smb2_open(struct ksmbd_work *work)\n \t\t\t\t\t}\n \n \t\t\t\t\trc = ksmbd_vfs_set_sd_xattr(conn,\n-\t\t\t\t\t\t\t\t    idmap,\n \t\t\t\t\t\t\t\t    \u0026path,\n \t\t\t\t\t\t\t\t    pntsd,\n \t\t\t\t\t\t\t\t    pntsd_size,\n@@ -5186,7 +5176,7 @@ int smb2_open(struct ksmbd_work *work)\n \t\tsmb2_new_xattrs(tcon, \u0026path, fp);\n \t}\n \n-\tksmbd_vfs_update_compressed_fattr(path.dentry, \u0026fp-\u003ef_ci-\u003em_fattr);\n+\tksmbd_vfs_update_compressed_fattr(\u0026path, \u0026fp-\u003ef_ci-\u003em_fattr);\n \n \tif (created) {\n \t\tif (fp-\u003ecoption \u0026 FILE_NO_COMPRESSION_LE) {\n@@ -6163,7 +6153,6 @@ static int process_query_dir_entries(struct smb2_query_dir_private *priv)\n \t\tksmbd_kstat.kstat = \u0026kstat;\n \t\tif (priv-\u003einfo_level != FILE_NAMES_INFORMATION) {\n \t\t\trc = ksmbd_vfs_fill_dentry_attrs(priv-\u003ework,\n-\t\t\t\t\t\t\t idmap,\n \t\t\t\t\t\t\t dent,\n \t\t\t\t\t\t\t \u0026ksmbd_kstat);\n \t\t\tif (rc) {\n@@ -6765,7 +6754,6 @@ static int smb2_get_ea(struct ksmbd_work *work, struct ksmbd_file *fp,\n \tssize_t buf_free_len, alignment_bytes, next_offset, rsp_data_cnt = 0;\n \tstruct smb2_ea_info_req *ea_req = NULL;\n \tconst struct path *path;\n-\tconst struct mnt_idmap *idmap = file_mnt_idmap(fp-\u003efilp);\n \n \tif (!(fp-\u003edaccess \u0026 FILE_READ_EA_LE)) {\n \t\tpr_err(\"Not permitted to read ext attr : 0x%x\\n\",\n@@ -6802,7 +6790,7 @@ static int smb2_get_ea(struct ksmbd_work *work, struct ksmbd_file *fp,\n \tif (buf_free_len \u003c 0)\n \t\treturn -EINVAL;\n \n-\trc = ksmbd_vfs_listxattr(path-\u003edentry, \u0026xattr_list);\n+\trc = ksmbd_vfs_listxattr(path, \u0026xattr_list);\n \tif (rc \u003c 0) {\n \t\trsp-\u003ehdr.Status = STATUS_INVALID_HANDLE;\n \t\tgoto out;\n@@ -6848,8 +6836,7 @@ static int smb2_get_ea(struct ksmbd_work *work, struct ksmbd_file *fp,\n \t\tbuf_free_len -= (offsetof(struct smb2_ea_info, name) +\n \t\t\t\tname_len + 1);\n \t\t/* bailout if xattr can't fit in buf_free_len */\n-\t\tvalue_len = ksmbd_vfs_getxattr(idmap, path-\u003edentry,\n-\t\t\t\t\t       name, \u0026buf);\n+\t\tvalue_len = ksmbd_vfs_getxattr(path, name, \u0026buf);\n \t\tif (value_len \u003c= 0) {\n \t\t\trc = -ENOENT;\n \t\t\trsp-\u003ehdr.Status = STATUS_INVALID_HANDLE;\n@@ -7139,7 +7126,7 @@ static char *smb2_get_normalized_stream_name(struct ksmbd_file *fp)\n \tif (!ksmbd_stream_fd(fp))\n \t\treturn NULL;\n \n-\txattr_list_len = ksmbd_vfs_listxattr(fp-\u003efilp-\u003ef_path.dentry,\n+\txattr_list_len = ksmbd_vfs_listxattr(\u0026fp-\u003efilp-\u003ef_path,\n \t\t\t\t\t     \u0026xattr_list);\n \tif (xattr_list_len \u003c= 0)\n \t\tgoto out;\n@@ -7242,7 +7229,7 @@ static int get_file_stream_info(struct ksmbd_work *work,\n \tif (buf_free_len \u003c 0)\n \t\tgoto out;\n \n-\txattr_list_len = ksmbd_vfs_listxattr(path-\u003edentry, \u0026xattr_list);\n+\txattr_list_len = ksmbd_vfs_listxattr(path, \u0026xattr_list);\n \tif (xattr_list_len \u003c 0) {\n \t\tgoto out;\n \t} else if (!xattr_list_len) {\n@@ -7287,8 +7274,7 @@ static int get_file_stream_info(struct ksmbd_work *work,\n \t\tstreamlen *= 2;\n \t\tkfree(stream_buf);\n \t\tfile_info-\u003eStreamNameLength = cpu_to_le32(streamlen);\n-\t\tslen = ksmbd_vfs_xattr_len(file_mnt_idmap(fp-\u003efilp),\n-\t\t\t\t\t   path-\u003edentry, stream_name);\n+\t\tslen = ksmbd_vfs_xattr_len(path, stream_name);\n \t\tssize = slen \u003c 0 ? 0 : (loff_t)slen;\n \t\tfile_info-\u003eStreamSize = cpu_to_le64(ssize);\n \t\tfile_info-\u003eStreamAllocationSize = cpu_to_le64(ssize);\n@@ -7757,7 +7743,7 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work,\n \t\t\tFILE_SUPPORTS_SPARSE_FILES |\n \t\t\tFILE_SUPPORTS_BLOCK_REFCOUNTING;\n \n-\t\terr = vfs_fileattr_get(path.dentry, \u0026fa);\n+\t\terr = vfs_fileattr_get(\u0026path, \u0026fa);\n \t\t/*\n \t\t * -EINVAL, -EOPNOTSUPP: ntfs-3g and other FUSE\n \t\t * filesystems that lack FS_IOC_FSGETXATTR support.\n@@ -8026,8 +8012,8 @@ static int smb2_get_info_sec(struct ksmbd_work *work,\n \n \tif (test_share_config_flag(work-\u003etcon-\u003eshare_conf,\n \t\t\t\t   KSMBD_SHARE_FLAG_ACL_XATTR))\n-\t\tppntsd_size = ksmbd_vfs_get_sd_xattr(work-\u003econn, idmap,\n-\t\t\t\t\t\t     fp-\u003efilp-\u003ef_path.dentry,\n+\t\tppntsd_size = ksmbd_vfs_get_sd_xattr(work-\u003econn,\n+\t\t\t\t\t\t     \u0026fp-\u003efilp-\u003ef_path,\n \t\t\t\t\t\t     \u0026ppntsd);\n \n \t/* Check if sd buffer size exceeds response buffer size */\n@@ -8388,8 +8374,7 @@ static int smb2_rename(struct ksmbd_work *work,\n \t\t\t\tgoto out;\n \t\t\t}\n \n-\t\t\tstream_buf_len = ksmbd_vfs_getcasexattr(file_mnt_idmap(fp-\u003efilp),\n-\t\t\t\t\t\t\t\tfp-\u003efilp-\u003ef_path.dentry,\n+\t\t\tstream_buf_len = ksmbd_vfs_getcasexattr(\u0026fp-\u003efilp-\u003ef_path,\n \t\t\t\t\t\t\t\tfp-\u003estream.name,\n \t\t\t\t\t\t\t\tfp-\u003estream.size,\n \t\t\t\t\t\t\t\t\u0026stream_buf);\n@@ -8400,8 +8385,7 @@ static int smb2_rename(struct ksmbd_work *work,\n \t\t\t}\n \t\t}\n \n-\t\trc = ksmbd_vfs_setxattr(file_mnt_idmap(fp-\u003efilp),\n-\t\t\t\t\t\u0026fp-\u003efilp-\u003ef_path,\n+\t\trc = ksmbd_vfs_setxattr(\u0026fp-\u003efilp-\u003ef_path,\n \t\t\t\t\txattr_stream_name,\n \t\t\t\t\tstream_buf, stream_buf_len, 0, true);\n \t\tkfree(stream_buf);\n@@ -8508,7 +8492,6 @@ static int set_file_basic_info(struct ksmbd_file *fp,\n \tstruct iattr attrs;\n \tstruct file *filp;\n \tstruct inode *inode;\n-\tconst struct mnt_idmap *idmap;\n \t__le32 attrs_mask = FILE_ATTRIBUTE_DIRECTORY_LE |\n \t\tFILE_ATTRIBUTE_COMPRESSED_LE;\n \tint rc = 0;\n@@ -8519,7 +8502,6 @@ static int set_file_basic_info(struct ksmbd_file *fp,\n \tattrs.ia_valid = 0;\n \tfilp = fp-\u003efilp;\n \tinode = file_inode(filp);\n-\tidmap = file_mnt_idmap(filp);\n \n \tif (file_info-\u003eCreationTime)\n \t\tfp-\u003ecreate_time = le64_to_cpu(file_info-\u003eCreationTime);\n@@ -8564,7 +8546,7 @@ static int set_file_basic_info(struct ksmbd_file *fp,\n \t\tda.flags = XATTR_DOSINFO_ATTRIB | XATTR_DOSINFO_CREATE_TIME |\n \t\t\tXATTR_DOSINFO_ITIME;\n \n-\t\trc = ksmbd_vfs_set_dos_attrib_xattr(idmap, \u0026filp-\u003ef_path, \u0026da,\n+\t\trc = ksmbd_vfs_set_dos_attrib_xattr(\u0026filp-\u003ef_path, \u0026da,\n \t\t\t\ttrue);\n \t\tif (rc)\n \t\t\tksmbd_debug(SMB,\n@@ -8580,7 +8562,7 @@ static int set_file_basic_info(struct ksmbd_file *fp,\n \t\t\treturn -EACCES;\n \n \t\tinode_lock(inode);\n-\t\trc = notify_change(idmap, dentry, \u0026attrs, NULL);\n+\t\trc = notify_change(\u0026filp-\u003ef_path, \u0026attrs, NULL);\n \t\tinode_unlock(inode);\n \t}\n \treturn rc;\n@@ -11127,7 +11109,6 @@ static inline int fsctl_set_sparse(struct ksmbd_work *work, u64 id,\n \t\t\t\t   struct file_sparse *sparse)\n {\n \tstruct ksmbd_file *fp;\n-\tconst struct mnt_idmap *idmap;\n \tint ret = 0;\n \t__le32 old_fattr;\n \n@@ -11151,8 +11132,6 @@ static inline int fsctl_set_sparse(struct ksmbd_work *work, u64 id,\n \t\tgoto out;\n \t}\n \n-\tidmap = file_mnt_idmap(fp-\u003efilp);\n-\n \told_fattr = fp-\u003ef_ci-\u003em_fattr;\n \tif (!sparse-\u003eSetSparse \u0026\u0026\n \t    (old_fattr \u0026 FILE_ATTRIBUTE_SPARSE_FILE_LE)) {\n@@ -11170,8 +11149,7 @@ static inline int fsctl_set_sparse(struct ksmbd_work *work, u64 id,\n \t\tconst struct cred *saved_cred;\n \t\tstruct xattr_dos_attrib da = {0};\n \n-\t\tret = ksmbd_vfs_get_dos_attrib_xattr(idmap,\n-\t\t\t\t\t\t     fp-\u003efilp-\u003ef_path.dentry, \u0026da);\n+\t\tret = ksmbd_vfs_get_dos_attrib_xattr(\u0026fp-\u003efilp-\u003ef_path, \u0026da);\n \t\tif (ret \u003c= 0) {\n \t\t\tda.version = 4;\n \t\t\tda.itime = fp-\u003eitime;\n@@ -11183,8 +11161,7 @@ static inline int fsctl_set_sparse(struct ksmbd_work *work, u64 id,\n \t\tda.attr = le32_to_cpu(fp-\u003ef_ci-\u003em_fattr);\n \t\tda.flags |= XATTR_DOSINFO_ATTRIB;\n \t\tsaved_cred = override_creds(fp-\u003efilp-\u003ef_cred);\n-\t\tret = ksmbd_vfs_set_dos_attrib_xattr(idmap,\n-\t\t\t\t\t\t     \u0026fp-\u003efilp-\u003ef_path,\n+\t\tret = ksmbd_vfs_set_dos_attrib_xattr(\u0026fp-\u003efilp-\u003ef_path,\n \t\t\t\t\t\t     \u0026da, true);\n \t\trevert_creds(saved_cred);\n \t\tif (ret)\ndiff --git a/fs/smb/server/smb_common.c b/fs/smb/server/smb_common.c\nindex 7dbcfa658edd5..2cc8e24dcd6cb 100644\n--- a/fs/smb/server/smb_common.c\n+++ b/fs/smb/server/smb_common.c\n@@ -467,7 +467,6 @@ int ksmbd_populate_dot_dotdot_entries(struct ksmbd_work *work, int info_level,\n {\n \tint i, rc = 0;\n \tstruct ksmbd_conn *conn = work-\u003econn;\n-\tconst struct mnt_idmap *idmap = file_mnt_idmap(dir-\u003efilp);\n \n \tfor (i = 0; i \u003c 2; i++) {\n \t\tstruct kstat kstat;\n@@ -493,7 +492,6 @@ int ksmbd_populate_dot_dotdot_entries(struct ksmbd_work *work, int info_level,\n \n \t\t\tksmbd_kstat.kstat = \u0026kstat;\n \t\t\trc = ksmbd_vfs_fill_dentry_attrs(work,\n-\t\t\t\t\t\t\t idmap,\n \t\t\t\t\t\t\t dentry,\n \t\t\t\t\t\t\t \u0026ksmbd_kstat);\n \t\t\tif (rc)\ndiff --git a/fs/smb/server/smbacl.c b/fs/smb/server/smbacl.c\nindex 96428df33b438..bcc506fca33e5 100644\n--- a/fs/smb/server/smbacl.c\n+++ b/fs/smb/server/smbacl.c\n@@ -1199,8 +1199,8 @@ int smb_inherit_dacl(struct ksmbd_conn *conn,\n \tstruct smb_acl *parent_pdacl;\n \tstruct smb_ntsd *parent_pntsd = NULL;\n \tstruct smb_sid owner_sid, group_sid;\n-\tstruct dentry *parent = path-\u003edentry-\u003ed_parent;\n-\tconst struct mnt_idmap *idmap = mnt_idmap(path-\u003emnt);\n+\tstruct path parent_path = { .mnt = path-\u003emnt,\n+\t\t\t\t    .dentry = path-\u003edentry-\u003ed_parent };\n \tint inherited_flags = 0, flags = 0, i, nt_size = 0, pdacl_size;\n \tint rc = 0, pntsd_type, ppntsd_size, acl_len, aces_size;\n \tunsigned int dacloffset;\n@@ -1209,8 +1209,8 @@ int smb_inherit_dacl(struct ksmbd_conn *conn,\n \tchar *aces_base;\n \tbool is_dir = S_ISDIR(d_inode(path-\u003edentry)-\u003ei_mode);\n \n-\tppntsd_size = ksmbd_vfs_get_sd_xattr(conn, idmap,\n-\t\t\t\t\t    parent, \u0026parent_pntsd);\n+\tppntsd_size = ksmbd_vfs_get_sd_xattr(conn, \u0026parent_path,\n+\t\t\t\t\t    \u0026parent_pntsd);\n \tif (ppntsd_size \u003c= 0)\n \t\treturn -ENOENT;\n \n@@ -1427,7 +1427,7 @@ int smb_inherit_dacl(struct ksmbd_conn *conn,\n \t\t\tpntsd_size += sizeof(struct smb_acl) + nt_size;\n \t\t}\n \n-\t\tksmbd_vfs_set_sd_xattr(conn, idmap, path, pntsd, pntsd_size, false);\n+\t\tksmbd_vfs_set_sd_xattr(conn, path, pntsd, pntsd_size, false);\n \t\tkfree(pntsd);\n \t}\n \n@@ -1476,8 +1476,7 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path,\n \tvfsuid_t vfsuid;\n \n \tksmbd_debug(SMB, \"check permission using windows acl\\n\");\n-\tpntsd_size = ksmbd_vfs_get_sd_xattr(conn, idmap,\n-\t\t\t\t\t    path-\u003edentry, \u0026pntsd);\n+\tpntsd_size = ksmbd_vfs_get_sd_xattr(conn, path, \u0026pntsd);\n \tif (pntsd_size \u003c= 0 || !pntsd)\n \t\tgoto err_out;\n \n@@ -1701,7 +1700,7 @@ int set_info_sec(struct ksmbd_conn *conn, struct ksmbd_tree_connect *tcon,\n \tnewattrs.ia_valid |= ATTR_MODE;\n \tnewattrs.ia_mode = (inode-\u003ei_mode \u0026 ~0777) | (fattr.cf_mode \u0026 0777);\n \n-\tksmbd_vfs_remove_acl_xattrs(idmap, path);\n+\tksmbd_vfs_remove_acl_xattrs(path);\n \t/* Update posix acls */\n \tif (IS_ENABLED(CONFIG_FS_POSIX_ACL) \u0026\u0026 fattr.cf_dacls) {\n \t\trc = set_posix_acl(idmap, path-\u003edentry,\n@@ -1721,7 +1720,7 @@ int set_info_sec(struct ksmbd_conn *conn, struct ksmbd_tree_connect *tcon,\n \t}\n \n \tinode_lock(inode);\n-\trc = notify_change(idmap, path-\u003edentry, \u0026newattrs, NULL);\n+\trc = notify_change(path, \u0026newattrs, NULL);\n \tinode_unlock(inode);\n \tif (rc)\n \t\tgoto out;\n@@ -1732,8 +1731,8 @@ int set_info_sec(struct ksmbd_conn *conn, struct ksmbd_tree_connect *tcon,\n \n \tif (test_share_config_flag(tcon-\u003eshare_conf, KSMBD_SHARE_FLAG_ACL_XATTR)) {\n \t\t/* Update WinACL in xattr */\n-\t\tksmbd_vfs_remove_sd_xattrs(idmap, path);\n-\t\tksmbd_vfs_set_sd_xattr(conn, idmap, path, pntsd, ntsd_len,\n+\t\tksmbd_vfs_remove_sd_xattrs(path);\n+\t\tksmbd_vfs_set_sd_xattr(conn, path, pntsd, ntsd_len,\n \t\t\t\tget_write);\n \t}\n \ndiff --git a/fs/smb/server/tests/smbacl_kunit.c b/fs/smb/server/tests/smbacl_kunit.c\nindex 33496b4d31a3e..0e918b72f94fe 100644\n--- a/fs/smb/server/tests/smbacl_kunit.c\n+++ b/fs/smb/server/tests/smbacl_kunit.c\n@@ -221,8 +221,7 @@ static void ksmbd_smb_check_perm_dacl_boundary_test(struct kunit *test)\n \t\t\t\tmk_vma_flags(VMA_NORESERVE_BIT));\n \tKUNIT_ASSERT_NOT_ERR_OR_NULL(test, file);\n \n-\trc = ksmbd_vfs_set_sd_xattr(NULL, mnt_idmap(file-\u003ef_path.mnt),\n-\t\t\t\t    \u0026file-\u003ef_path, pntsd, ntsd_size,\n+\trc = ksmbd_vfs_set_sd_xattr(NULL, \u0026file-\u003ef_path, pntsd, ntsd_size,\n \t\t\t\t    false);\n \tKUNIT_EXPECT_EQ(test, 0, rc);\n \tif (rc)\n@@ -263,8 +262,7 @@ ksmbd_smb_check_perm_dacl_maximal_boundary_test(struct kunit *test)\n \t\t\t\tmk_vma_flags(VMA_NORESERVE_BIT));\n \tKUNIT_ASSERT_NOT_ERR_OR_NULL(test, file);\n \n-\trc = ksmbd_vfs_set_sd_xattr(NULL, mnt_idmap(file-\u003ef_path.mnt),\n-\t\t\t\t    \u0026file-\u003ef_path, pntsd, ntsd_size,\n+\trc = ksmbd_vfs_set_sd_xattr(NULL, \u0026file-\u003ef_path, pntsd, ntsd_size,\n \t\t\t\t    false);\n \tKUNIT_EXPECT_EQ(test, 0, rc);\n \tif (rc)\ndiff --git a/fs/smb/server/vfs.c b/fs/smb/server/vfs.c\nindex d21ed90454f9a..c27a04dcfe385 100644\n--- a/fs/smb/server/vfs.c\n+++ b/fs/smb/server/vfs.c\n@@ -218,14 +218,14 @@ int ksmbd_vfs_mkdir(struct ksmbd_work *work, const char *name, umode_t mode)\n \treturn err;\n }\n \n-ssize_t ksmbd_vfs_getcasexattr(const struct mnt_idmap *idmap,\n-\t\t\t       struct dentry *dentry, char *attr_name,\n+ssize_t ksmbd_vfs_getcasexattr(const struct path *path,\n+\t\t\t       char *attr_name,\n \t\t\t       int attr_name_len, char **attr_value)\n {\n \tchar *name, *xattr_list = NULL;\n \tssize_t value_len = -ENOENT, xattr_list_len;\n \n-\txattr_list_len = ksmbd_vfs_listxattr(dentry, \u0026xattr_list);\n+\txattr_list_len = ksmbd_vfs_listxattr(path, \u0026xattr_list);\n \tif (xattr_list_len \u003c= 0)\n \t\tgoto out;\n \n@@ -235,8 +235,7 @@ ssize_t ksmbd_vfs_getcasexattr(const struct mnt_idmap *idmap,\n \t\tif (strncasecmp(attr_name, name, attr_name_len))\n \t\t\tcontinue;\n \n-\t\tvalue_len = ksmbd_vfs_getxattr(idmap,\n-\t\t\t\t\t       dentry,\n+\t\tvalue_len = ksmbd_vfs_getxattr(path,\n \t\t\t\t\t       name,\n \t\t\t\t\t       attr_value);\n \t\tif (value_len \u003c 0)\n@@ -260,8 +259,7 @@ static int ksmbd_vfs_stream_read(struct ksmbd_file *fp, char *buf, loff_t *pos,\n \t\t    *pos, count);\n \n \tsaved_cred = override_creds(fp-\u003efilp-\u003ef_cred);\n-\tv_len = ksmbd_vfs_getcasexattr(file_mnt_idmap(fp-\u003efilp),\n-\t\t\t\t       fp-\u003efilp-\u003ef_path.dentry,\n+\tv_len = ksmbd_vfs_getcasexattr(\u0026fp-\u003efilp-\u003ef_path,\n \t\t\t\t       fp-\u003estream.name,\n \t\t\t\t       fp-\u003estream.size,\n \t\t\t\t       \u0026stream_buf);\n@@ -388,7 +386,6 @@ static int ksmbd_vfs_stream_write(struct ksmbd_file *fp, char *buf, loff_t *pos,\n {\n \tconst struct cred *saved_cred;\n \tchar *stream_buf = NULL, *wbuf;\n-\tconst struct mnt_idmap *idmap = file_mnt_idmap(fp-\u003efilp);\n \tsize_t size, write_end;\n \tssize_t v_len;\n \tint err = 0;\n@@ -406,8 +403,7 @@ static int ksmbd_vfs_stream_write(struct ksmbd_file *fp, char *buf, loff_t *pos,\n \twrite_end = *pos + count;\n \n \tsaved_cred = override_creds(fp-\u003efilp-\u003ef_cred);\n-\tv_len = ksmbd_vfs_getcasexattr(idmap,\n-\t\t\t\t       fp-\u003efilp-\u003ef_path.dentry,\n+\tv_len = ksmbd_vfs_getcasexattr(\u0026fp-\u003efilp-\u003ef_path,\n \t\t\t\t       fp-\u003estream.name,\n \t\t\t\t       fp-\u003estream.size,\n \t\t\t\t       \u0026stream_buf);\n@@ -434,8 +430,7 @@ static int ksmbd_vfs_stream_write(struct ksmbd_file *fp, char *buf, loff_t *pos,\n \n \tmemcpy(\u0026stream_buf[*pos], buf, count);\n \n-\terr = ksmbd_vfs_setxattr(idmap,\n-\t\t\t\t \u0026fp-\u003efilp-\u003ef_path,\n+\terr = ksmbd_vfs_setxattr(\u0026fp-\u003efilp-\u003ef_path,\n \t\t\t\t fp-\u003estream.name,\n \t\t\t\t (void *)stream_buf,\n \t\t\t\t size,\n@@ -465,7 +460,6 @@ static int ksmbd_vfs_stream_write(struct ksmbd_file *fp, char *buf, loff_t *pos,\n int ksmbd_vfs_stream_truncate(struct ksmbd_file *fp, loff_t newsize)\n {\n \tconst struct cred *saved_cred;\n-\tconst struct mnt_idmap *idmap = file_mnt_idmap(fp-\u003efilp);\n \tchar *stream_buf = NULL, *new_buf = NULL;\n \tssize_t v_len;\n \tint err;\n@@ -476,7 +470,7 @@ int ksmbd_vfs_stream_truncate(struct ksmbd_file *fp, loff_t newsize)\n \t\treturn -EFBIG;\n \n \tsaved_cred = override_creds(fp-\u003efilp-\u003ef_cred);\n-\tv_len = ksmbd_vfs_getcasexattr(idmap, fp-\u003efilp-\u003ef_path.dentry,\n+\tv_len = ksmbd_vfs_getcasexattr(\u0026fp-\u003efilp-\u003ef_path,\n \t\t\t\t       fp-\u003estream.name, fp-\u003estream.size,\n \t\t\t\t       \u0026stream_buf);\n \tif (v_len \u003c 0) {\n@@ -499,7 +493,7 @@ int ksmbd_vfs_stream_truncate(struct ksmbd_file *fp, loff_t newsize)\n \t\t\tmemcpy(new_buf, stream_buf, v_len);\n \t}\n \n-\terr = ksmbd_vfs_setxattr(idmap, \u0026fp-\u003efilp-\u003ef_path, fp-\u003estream.name,\n+\terr = ksmbd_vfs_setxattr(\u0026fp-\u003efilp-\u003ef_path, fp-\u003estream.name,\n \t\t\t\t new_buf, newsize, 0, true);\n \tif (new_buf != stream_buf)\n \t\tkvfree(new_buf);\n@@ -870,17 +864,17 @@ int ksmbd_vfs_truncate(struct ksmbd_work *work,\n \n /**\n  * ksmbd_vfs_listxattr() - vfs helper for smb list extended attributes\n- * @dentry:\tdentry of file for listing xattrs\n+ * @path:\tpath of file for listing xattrs\n  * @list:\tdestination buffer\n  *\n  * Return:\txattr list length on success, otherwise error\n  */\n-ssize_t ksmbd_vfs_listxattr(struct dentry *dentry, char **list)\n+ssize_t ksmbd_vfs_listxattr(const struct path *path, char **list)\n {\n \tssize_t size;\n \tchar *vlist = NULL;\n \n-\tsize = vfs_listxattr(dentry, NULL, 0);\n+\tsize = vfs_listxattr(path, NULL, 0);\n \tif (size \u003c= 0)\n \t\treturn size;\n \n@@ -889,7 +883,7 @@ ssize_t ksmbd_vfs_listxattr(struct dentry *dentry, char **list)\n \t\treturn -ENOMEM;\n \n \t*list = vlist;\n-\tsize = vfs_listxattr(dentry, vlist, size);\n+\tsize = vfs_listxattr(path, vlist, size);\n \tif (size \u003c 0) {\n \t\tksmbd_debug(VFS, \"listxattr failed\\n\");\n \t\tkvfree(vlist);\n@@ -899,30 +893,27 @@ ssize_t ksmbd_vfs_listxattr(struct dentry *dentry, char **list)\n \treturn size;\n }\n \n-ssize_t ksmbd_vfs_xattr_len(const struct mnt_idmap *idmap,\n-\t\t\t    struct dentry *dentry, char *xattr_name)\n+ssize_t ksmbd_vfs_xattr_len(const struct path *path, char *xattr_name)\n {\n-\treturn vfs_getxattr(idmap, dentry, xattr_name, NULL, 0);\n+\treturn vfs_getxattr(path, xattr_name, NULL, 0);\n }\n \n /**\n  * ksmbd_vfs_getxattr() - vfs helper for smb get extended attributes value\n- * @idmap:\tidmap\n- * @dentry:\tdentry of file for getting xattrs\n+ * @path:\tpath of file for getting xattrs\n  * @xattr_name:\tname of xattr name to query\n  * @xattr_buf:\tdestination buffer xattr value\n  *\n  * Return:\tread xattr value length on success, otherwise error\n  */\n-ssize_t ksmbd_vfs_getxattr(const struct mnt_idmap *idmap,\n-\t\t\t   struct dentry *dentry,\n+ssize_t ksmbd_vfs_getxattr(const struct path *path,\n \t\t\t   char *xattr_name, char **xattr_buf)\n {\n \tssize_t xattr_len;\n \tchar *buf;\n \n \t*xattr_buf = NULL;\n-\txattr_len = ksmbd_vfs_xattr_len(idmap, dentry, xattr_name);\n+\txattr_len = ksmbd_vfs_xattr_len(path, xattr_name);\n \tif (xattr_len \u003c 0)\n \t\treturn xattr_len;\n \n@@ -930,8 +921,7 @@ ssize_t ksmbd_vfs_getxattr(const struct mnt_idmap *idmap,\n \tif (!buf)\n \t\treturn -ENOMEM;\n \n-\txattr_len = vfs_getxattr(idmap, dentry, xattr_name,\n-\t\t\t\t (void *)buf, xattr_len);\n+\txattr_len = vfs_getxattr(path, xattr_name, (void *)buf, xattr_len);\n \tif (xattr_len \u003e 0)\n \t\t*xattr_buf = buf;\n \telse\n@@ -941,7 +931,6 @@ ssize_t ksmbd_vfs_getxattr(const struct mnt_idmap *idmap,\n \n /**\n  * ksmbd_vfs_setxattr() - vfs helper for smb set extended attributes value\n- * @idmap:\tidmap of the relevant mount\n  * @path:\tpath of dentry to set XATTR at\n  * @attr_name:\txattr name for setxattr\n  * @attr_value:\txattr value to set\n@@ -951,8 +940,7 @@ ssize_t ksmbd_vfs_getxattr(const struct mnt_idmap *idmap,\n  *\n  * Return:\t0 on success, otherwise error\n  */\n-int ksmbd_vfs_setxattr(const struct mnt_idmap *idmap,\n-\t\t       const struct path *path, const char *attr_name,\n+int ksmbd_vfs_setxattr(const struct path *path, const char *attr_name,\n \t\t       void *attr_value, size_t attr_size, int flags,\n \t\t       bool get_write)\n {\n@@ -964,8 +952,7 @@ int ksmbd_vfs_setxattr(const struct mnt_idmap *idmap,\n \t\t\treturn err;\n \t}\n \n-\terr = vfs_setxattr(idmap,\n-\t\t\t   path-\u003edentry,\n+\terr = vfs_setxattr(path,\n \t\t\t   attr_name,\n \t\t\t   attr_value,\n \t\t\t   attr_size,\n@@ -1235,8 +1222,7 @@ int ksmbd_vfs_query_allocated_ranges(struct ksmbd_file *fp, loff_t start,\n \treturn ret;\n }\n \n-int ksmbd_vfs_remove_xattr(const struct mnt_idmap *idmap,\n-\t\t\t   const struct path *path, char *attr_name,\n+int ksmbd_vfs_remove_xattr(const struct path *path, char *attr_name,\n \t\t\t   bool get_write)\n {\n \tint err;\n@@ -1247,7 +1233,7 @@ int ksmbd_vfs_remove_xattr(const struct mnt_idmap *idmap,\n \t\t\treturn err;\n \t}\n \n-\terr = vfs_removexattr(idmap, path-\u003edentry, attr_name);\n+\terr = vfs_removexattr(path, attr_name);\n \n \tif (get_write == true)\n \t\tmnt_drop_write(path-\u003emnt);\n@@ -1529,14 +1515,13 @@ struct dentry *ksmbd_vfs_kern_path_create(struct ksmbd_work *work,\n \treturn dent;\n }\n \n-int ksmbd_vfs_remove_acl_xattrs(const struct mnt_idmap *idmap,\n-\t\t\t\tconst struct path *path)\n+int ksmbd_vfs_remove_acl_xattrs(const struct path *path)\n {\n \tchar *name, *xattr_list = NULL;\n \tssize_t xattr_list_len;\n \tint err = 0;\n \n-\txattr_list_len = ksmbd_vfs_listxattr(path-\u003edentry, \u0026xattr_list);\n+\txattr_list_len = ksmbd_vfs_listxattr(path, \u0026xattr_list);\n \tif (xattr_list_len \u003c 0) {\n \t\tgoto out;\n \t} else if (!xattr_list_len) {\n@@ -1556,7 +1541,7 @@ int ksmbd_vfs_remove_acl_xattrs(const struct mnt_idmap *idmap,\n \t\t\t     sizeof(XATTR_NAME_POSIX_ACL_ACCESS) - 1) ||\n \t\t    !strncmp(name, XATTR_NAME_POSIX_ACL_DEFAULT,\n \t\t\t     sizeof(XATTR_NAME_POSIX_ACL_DEFAULT) - 1)) {\n-\t\t\terr = vfs_remove_acl(idmap, path-\u003edentry, name);\n+\t\t\terr = vfs_remove_acl(path, name);\n \t\t\tif (err)\n \t\t\t\tksmbd_debug(SMB,\n \t\t\t\t\t    \"remove acl xattr failed : %s\\n\", name);\n@@ -1569,13 +1554,13 @@ int ksmbd_vfs_remove_acl_xattrs(const struct mnt_idmap *idmap,\n \treturn err;\n }\n \n-int ksmbd_vfs_remove_sd_xattrs(const struct mnt_idmap *idmap, const struct path *path)\n+int ksmbd_vfs_remove_sd_xattrs(const struct path *path)\n {\n \tchar *name, *xattr_list = NULL;\n \tssize_t xattr_list_len;\n \tint err = 0;\n \n-\txattr_list_len = ksmbd_vfs_listxattr(path-\u003edentry, \u0026xattr_list);\n+\txattr_list_len = ksmbd_vfs_listxattr(path, \u0026xattr_list);\n \tif (xattr_list_len \u003c 0) {\n \t\tgoto out;\n \t} else if (!xattr_list_len) {\n@@ -1588,7 +1573,7 @@ int ksmbd_vfs_remove_sd_xattrs(const struct mnt_idmap *idmap, const struct path\n \t\tksmbd_debug(SMB, \"%s, len %zd\\n\", name, strlen(name));\n \n \t\tif (!strncmp(name, XATTR_NAME_SD, XATTR_NAME_SD_LEN)) {\n-\t\t\terr = ksmbd_vfs_remove_xattr(idmap, path, name, true);\n+\t\t\terr = ksmbd_vfs_remove_xattr(path, name, true);\n \t\t\tif (err)\n \t\t\t\tksmbd_debug(SMB, \"remove xattr failed : %s\\n\", name);\n \t\t}\n@@ -1664,7 +1649,6 @@ static struct xattr_smb_acl *ksmbd_vfs_make_xattr_posix_acl(const struct mnt_idm\n }\n \n int ksmbd_vfs_set_sd_xattr(struct ksmbd_conn *conn,\n-\t\t\t   const struct mnt_idmap *idmap,\n \t\t\t   const struct path *path,\n \t\t\t   struct smb_ntsd *pntsd, int len,\n \t\t\t   bool get_write)\n@@ -1675,6 +1659,7 @@ int ksmbd_vfs_set_sd_xattr(struct ksmbd_conn *conn,\n \tstruct xattr_smb_acl *smb_acl, *def_smb_acl = NULL;\n \tstruct dentry *dentry = path-\u003edentry;\n \tstruct inode *inode = d_inode(dentry);\n+\tconst struct mnt_idmap *idmap = mnt_idmap(path-\u003emnt);\n \n \tacl.version = 4;\n \tacl.hash_type = XATTR_SD_HASH_TYPE_SHA256;\n@@ -1716,7 +1701,7 @@ int ksmbd_vfs_set_sd_xattr(struct ksmbd_conn *conn,\n \t\tgoto out;\n \t}\n \n-\trc = ksmbd_vfs_setxattr(idmap, path,\n+\trc = ksmbd_vfs_setxattr(path,\n \t\t\t\tXATTR_NAME_SD, sd_ndr.data,\n \t\t\t\tsd_ndr.offset, 0, get_write);\n \tif (rc \u003c 0)\n@@ -1732,19 +1717,19 @@ int ksmbd_vfs_set_sd_xattr(struct ksmbd_conn *conn,\n EXPORT_SYMBOL_IF_KUNIT(ksmbd_vfs_set_sd_xattr);\n \n int ksmbd_vfs_get_sd_xattr(struct ksmbd_conn *conn,\n-\t\t\t   const struct mnt_idmap *idmap,\n-\t\t\t   struct dentry *dentry,\n+\t\t\t   const struct path *path,\n \t\t\t   struct smb_ntsd **pntsd)\n {\n \tint rc;\n \tstruct ndr n;\n-\tstruct inode *inode = d_inode(dentry);\n+\tstruct inode *inode = d_inode(path-\u003edentry);\n \tstruct ndr acl_ndr = {0};\n \tstruct xattr_ntacl acl = {0};\n \tstruct xattr_smb_acl *smb_acl = NULL, *def_smb_acl = NULL;\n+\tconst struct mnt_idmap *idmap = mnt_idmap(path-\u003emnt);\n \t__u8 cmp_hash[XATTR_SD_HASH_SIZE] = {0};\n \n-\trc = ksmbd_vfs_getxattr(idmap, dentry, XATTR_NAME_SD, \u0026n.data);\n+\trc = ksmbd_vfs_getxattr(path, XATTR_NAME_SD, \u0026n.data);\n \tif (rc \u003c= 0)\n \t\treturn rc;\n \n@@ -1801,8 +1786,7 @@ int ksmbd_vfs_get_sd_xattr(struct ksmbd_conn *conn,\n \treturn rc;\n }\n \n-int ksmbd_vfs_set_dos_attrib_xattr(const struct mnt_idmap *idmap,\n-\t\t\t\t   const struct path *path,\n+int ksmbd_vfs_set_dos_attrib_xattr(const struct path *path,\n \t\t\t\t   struct xattr_dos_attrib *da,\n \t\t\t\t   bool get_write)\n {\n@@ -1813,7 +1797,7 @@ int ksmbd_vfs_set_dos_attrib_xattr(const struct mnt_idmap *idmap,\n \tif (err)\n \t\tgoto out;\n \n-\terr = ksmbd_vfs_setxattr(idmap, path, XATTR_NAME_DOS_ATTRIBUTE,\n+\terr = ksmbd_vfs_setxattr(path, XATTR_NAME_DOS_ATTRIBUTE,\n \t\t\t\t (void *)n.data, n.offset, 0, get_write);\n \tif (err)\n \t\tksmbd_debug(SMB, \"failed to store dos attribute in xattr\\n\");\n@@ -1823,14 +1807,13 @@ int ksmbd_vfs_set_dos_attrib_xattr(const struct mnt_idmap *idmap,\n \treturn err;\n }\n \n-int ksmbd_vfs_get_dos_attrib_xattr(const struct mnt_idmap *idmap,\n-\t\t\t\t   struct dentry *dentry,\n+int ksmbd_vfs_get_dos_attrib_xattr(const struct path *path,\n \t\t\t\t   struct xattr_dos_attrib *da)\n {\n \tstruct ndr n;\n \tint err;\n \n-\terr = ksmbd_vfs_getxattr(idmap, dentry, XATTR_NAME_DOS_ATTRIBUTE,\n+\terr = ksmbd_vfs_getxattr(path, XATTR_NAME_DOS_ATTRIBUTE,\n \t\t\t\t (char **)\u0026n.data);\n \tif (err \u003e 0) {\n \t\tn.length = err;\n@@ -1879,7 +1862,6 @@ void *ksmbd_vfs_init_kstat(char **p, struct ksmbd_kstat *ksmbd_kstat)\n }\n \n int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work,\n-\t\t\t\tconst struct mnt_idmap *idmap,\n \t\t\t\tstruct dentry *dentry,\n \t\t\t\tstruct ksmbd_kstat *ksmbd_kstat)\n {\n@@ -1913,7 +1895,7 @@ int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work,\n \t\t\t\t   KSMBD_SHARE_FLAG_STORE_DOS_ATTRS)) {\n \t\tstruct xattr_dos_attrib da;\n \n-\t\trc = ksmbd_vfs_get_dos_attrib_xattr(idmap, dentry, \u0026da);\n+\t\trc = ksmbd_vfs_get_dos_attrib_xattr(\u0026path, \u0026da);\n \t\tif (rc \u003e 0) {\n \t\t\tksmbd_kstat-\u003efile_attributes = cpu_to_le32(da.attr);\n \t\t\tksmbd_kstat-\u003ecreate_time = da.create_time;\n@@ -1936,7 +1918,7 @@ int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work,\n \t\tchar *xattr_list = NULL, *name;\n \t\tssize_t xattr_list_len;\n \n-\t\txattr_list_len = ksmbd_vfs_listxattr(dentry, \u0026xattr_list);\n+\t\txattr_list_len = ksmbd_vfs_listxattr(\u0026path, \u0026xattr_list);\n \t\tif (xattr_list_len \u003e 0) {\n \t\t\tfor (name = xattr_list;\n \t\t\t     name - xattr_list \u003c xattr_list_len;\n@@ -1954,14 +1936,14 @@ int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work,\n \treturn 0;\n }\n \n-ssize_t ksmbd_vfs_casexattr_len(const struct mnt_idmap *idmap,\n-\t\t\t\tstruct dentry *dentry, char *attr_name,\n+ssize_t ksmbd_vfs_casexattr_len(const struct path *path,\n+\t\t\t\tchar *attr_name,\n \t\t\t\tint attr_name_len, char *actual_name)\n {\n \tchar *name, *xattr_list = NULL;\n \tssize_t value_len = -ENOENT, xattr_list_len;\n \n-\txattr_list_len = ksmbd_vfs_listxattr(dentry, \u0026xattr_list);\n+\txattr_list_len = ksmbd_vfs_listxattr(path, \u0026xattr_list);\n \tif (xattr_list_len \u003c 0) {\n \t\tvalue_len = xattr_list_len;\n \t\tgoto out;\n@@ -1977,7 +1959,7 @@ ssize_t ksmbd_vfs_casexattr_len(const struct mnt_idmap *idmap,\n \t\tif (actual_name \u0026\u0026 strlen(name) + 1 != attr_name_len)\n \t\t\tcontinue;\n \n-\t\tvalue_len = ksmbd_vfs_xattr_len(idmap, dentry, name);\n+\t\tvalue_len = ksmbd_vfs_xattr_len(path, name);\n \t\t/* The caller provides attr_name_len bytes for the actual name. */\n \t\tif (value_len \u003e= 0 \u0026\u0026 actual_name)\n \t\t\tmemcpy(actual_name, name, attr_name_len);\n@@ -2133,8 +2115,7 @@ int ksmbd_vfs_copy_file_ranges(struct ksmbd_work *work,\n \n \t\tsaved_cred = override_creds(src_fp-\u003efilp-\u003ef_cred);\n \t\tsrc_file_size = ksmbd_vfs_casexattr_len(\n-\t\t\t\tfile_mnt_idmap(src_fp-\u003efilp),\n-\t\t\t\tsrc_fp-\u003efilp-\u003ef_path.dentry,\n+\t\t\t\t\u0026src_fp-\u003efilp-\u003ef_path,\n \t\t\t\tsrc_fp-\u003estream.name, src_fp-\u003estream.size, NULL);\n \t\trevert_creds(saved_cred);\n \t\tif (src_file_size \u003c 0)\n@@ -2347,12 +2328,12 @@ int ksmbd_vfs_inherit_posix_acl(const struct mnt_idmap *idmap,\n \treturn 0;\n }\n \n-void ksmbd_vfs_update_compressed_fattr(struct dentry *dentry, __le32 *fattr)\n+void ksmbd_vfs_update_compressed_fattr(struct path *path, __le32 *fattr)\n {\n \tint rc;\n \tstruct file_kattr fa = { .flags_valid = true };\n \n-\trc = vfs_fileattr_get(dentry, \u0026fa);\n+\trc = vfs_fileattr_get(path, \u0026fa);\n \tif (rc)\n \t\treturn;\n \n@@ -2365,7 +2346,7 @@ int ksmbd_vfs_get_compression(struct ksmbd_file *fp, u16 *fmt)\n \tstruct file_kattr fa = { .flags_valid = true };\n \tint rc;\n \n-\trc = vfs_fileattr_get(fp-\u003efilp-\u003ef_path.dentry, \u0026fa);\n+\trc = vfs_fileattr_get(\u0026fp-\u003efilp-\u003ef_path, \u0026fa);\n \tif (rc == -ENOIOCTLCMD || rc == -ENOTTY || rc == -EINVAL ||\n \t    rc == -EOPNOTSUPP) {\n \t\tif (fp-\u003ef_ci-\u003em_fattr \u0026 FILE_ATTRIBUTE_COMPRESSED_LE)\n@@ -2393,8 +2374,6 @@ static int __ksmbd_vfs_set_compression(struct ksmbd_work *work,\n {\n \tconst struct cred *saved_cred = NULL;\n \tstruct file_kattr fa;\n-\tstruct dentry *dentry = fp-\u003efilp-\u003ef_path.dentry;\n-\tconst struct mnt_idmap *idmap = file_mnt_idmap(fp-\u003efilp);\n \tu32 flags;\n \t__le32 old_fattr;\n \tint rc;\n@@ -2412,7 +2391,7 @@ static int __ksmbd_vfs_set_compression(struct ksmbd_work *work,\n \t}\n \n \tsaved_cred = override_creds(fp-\u003efilp-\u003ef_cred);\n-\trc = vfs_fileattr_get(dentry, \u0026fa);\n+\trc = vfs_fileattr_get(\u0026fp-\u003efilp-\u003ef_path, \u0026fa);\n \tif (rc == -ENOIOCTLCMD || rc == -ENOTTY || rc == -EINVAL ||\n \t    rc == -EOPNOTSUPP)\n \t\tgoto update_fattr;\n@@ -2433,7 +2412,7 @@ static int __ksmbd_vfs_set_compression(struct ksmbd_work *work,\n \t\tif (rc)\n \t\t\tgoto out;\n \n-\t\trc = vfs_fileattr_set(idmap, dentry, \u0026fa);\n+\t\trc = vfs_fileattr_set(\u0026fp-\u003efilp-\u003ef_path, \u0026fa);\n \t\tmnt_drop_write_file(fp-\u003efilp);\n \t\tif (rc == -ENOIOCTLCMD || rc == -ENOTTY || rc == -EINVAL ||\n \t\t    rc == -EOPNOTSUPP)\n@@ -2452,7 +2431,7 @@ static int __ksmbd_vfs_set_compression(struct ksmbd_work *work,\n \tif (fp-\u003ef_ci-\u003em_fattr != old_fattr) {\n \t\tstruct xattr_dos_attrib da = {0};\n \n-\t\trc = ksmbd_vfs_get_dos_attrib_xattr(idmap, dentry, \u0026da);\n+\t\trc = ksmbd_vfs_get_dos_attrib_xattr(\u0026fp-\u003efilp-\u003ef_path, \u0026da);\n \t\tif (rc \u003c= 0) {\n \t\t\tda.version = 4;\n \t\t\tda.itime = fp-\u003eitime;\n@@ -2463,8 +2442,7 @@ static int __ksmbd_vfs_set_compression(struct ksmbd_work *work,\n \n \t\tda.attr = le32_to_cpu(fp-\u003ef_ci-\u003em_fattr);\n \t\tda.flags |= XATTR_DOSINFO_ATTRIB;\n-\t\trc = ksmbd_vfs_set_dos_attrib_xattr(idmap,\n-\t\t\t\t\t\t    \u0026fp-\u003efilp-\u003ef_path,\n+\t\trc = ksmbd_vfs_set_dos_attrib_xattr(\u0026fp-\u003efilp-\u003ef_path,\n \t\t\t\t\t\t    \u0026da, true);\n \t\tif (rc)\n \t\t\trc = 0;\ndiff --git a/fs/smb/server/vfs.h b/fs/smb/server/vfs.h\nindex 21b0d29a3db0b..404cf98fe6074 100644\n--- a/fs/smb/server/vfs.h\n+++ b/fs/smb/server/vfs.h\n@@ -104,27 +104,24 @@ int ksmbd_vfs_copy_file_ranges(struct ksmbd_work *work,\n \t\t\t       unsigned int *chunk_count_written,\n \t\t\t       unsigned int *chunk_size_written,\n \t\t\t       loff_t  *total_size_written);\n-ssize_t ksmbd_vfs_listxattr(struct dentry *dentry, char **list);\n-ssize_t ksmbd_vfs_getxattr(const struct mnt_idmap *idmap,\n-\t\t\t   struct dentry *dentry,\n+ssize_t ksmbd_vfs_listxattr(const struct path *path, char **list);\n+ssize_t ksmbd_vfs_getxattr(const struct path *path,\n \t\t\t   char *xattr_name,\n \t\t\t   char **xattr_buf);\n-ssize_t ksmbd_vfs_xattr_len(const struct mnt_idmap *idmap,\n-\t\t\t    struct dentry *dentry, char *xattr_name);\n-ssize_t ksmbd_vfs_getcasexattr(const struct mnt_idmap *idmap,\n-\t\t\t       struct dentry *dentry, char *attr_name,\n+ssize_t ksmbd_vfs_xattr_len(const struct path *path,\n+\t\t\t    char *xattr_name);\n+ssize_t ksmbd_vfs_getcasexattr(const struct path *path,\n+\t\t\t       char *attr_name,\n \t\t\t       int attr_name_len, char **attr_value);\n-ssize_t ksmbd_vfs_casexattr_len(const struct mnt_idmap *idmap,\n-\t\t\t\tstruct dentry *dentry, char *attr_name,\n+ssize_t ksmbd_vfs_casexattr_len(const struct path *path,\n+\t\t\t\tchar *attr_name,\n \t\t\t\tint attr_name_len, char *actual_name);\n-int ksmbd_vfs_setxattr(const struct mnt_idmap *idmap,\n-\t\t       const struct path *path, const char *attr_name,\n+int ksmbd_vfs_setxattr(const struct path *path, const char *attr_name,\n \t\t       void *attr_value, size_t attr_size, int flags,\n \t\t       bool get_write);\n int ksmbd_vfs_xattr_stream_name(char *stream_name, char **xattr_stream_name,\n \t\t\t\tsize_t *xattr_stream_name_size, int s_type);\n-int ksmbd_vfs_remove_xattr(const struct mnt_idmap *idmap,\n-\t\t\t   const struct path *path, char *attr_name,\n+int ksmbd_vfs_remove_xattr(const struct path *path, char *attr_name,\n \t\t\t   bool get_write);\n int ksmbd_vfs_kern_path(struct ksmbd_work *work, char *name,\n \t\t\tunsigned int flags,\n@@ -153,36 +150,30 @@ int ksmbd_vfs_query_allocated_ranges(struct ksmbd_file *fp, loff_t start,\n int ksmbd_vfs_unlink(struct file *filp);\n void *ksmbd_vfs_init_kstat(char **p, struct ksmbd_kstat *ksmbd_kstat);\n int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work,\n-\t\t\t\tconst struct mnt_idmap *idmap,\n \t\t\t\tstruct dentry *dentry,\n \t\t\t\tstruct ksmbd_kstat *ksmbd_kstat);\n void ksmbd_vfs_posix_lock_wait(struct file_lock *flock);\n void ksmbd_vfs_posix_lock_unblock(struct file_lock *flock);\n-int ksmbd_vfs_remove_acl_xattrs(const struct mnt_idmap *idmap,\n-\t\t\t\tconst struct path *path);\n-int ksmbd_vfs_remove_sd_xattrs(const struct mnt_idmap *idmap, const struct path *path);\n+int ksmbd_vfs_remove_acl_xattrs(const struct path *path);\n+int ksmbd_vfs_remove_sd_xattrs(const struct path *path);\n int ksmbd_vfs_set_sd_xattr(struct ksmbd_conn *conn,\n-\t\t\t   const struct mnt_idmap *idmap,\n \t\t\t   const struct path *path,\n \t\t\t   struct smb_ntsd *pntsd, int len,\n \t\t\t   bool get_write);\n int ksmbd_vfs_get_sd_xattr(struct ksmbd_conn *conn,\n-\t\t\t   const struct mnt_idmap *idmap,\n-\t\t\t   struct dentry *dentry,\n+\t\t\t   const struct path *path,\n \t\t\t   struct smb_ntsd **pntsd);\n-int ksmbd_vfs_set_dos_attrib_xattr(const struct mnt_idmap *idmap,\n-\t\t\t\t   const struct path *path,\n+int ksmbd_vfs_set_dos_attrib_xattr(const struct path *path,\n \t\t\t\t   struct xattr_dos_attrib *da,\n \t\t\t\t   bool get_write);\n-int ksmbd_vfs_get_dos_attrib_xattr(const struct mnt_idmap *idmap,\n-\t\t\t\t   struct dentry *dentry,\n+int ksmbd_vfs_get_dos_attrib_xattr(const struct path *path,\n \t\t\t\t   struct xattr_dos_attrib *da);\n int ksmbd_vfs_set_init_posix_acl(const struct mnt_idmap *idmap,\n \t\t\t\t const struct path *path);\n int ksmbd_vfs_inherit_posix_acl(const struct mnt_idmap *idmap,\n \t\t\t\tconst struct path *path,\n \t\t\t\tstruct inode *parent_inode);\n-void ksmbd_vfs_update_compressed_fattr(struct dentry *dentry, __le32 *fattr);\n+void ksmbd_vfs_update_compressed_fattr(struct path *path, __le32 *fattr);\n int ksmbd_vfs_get_compression(struct ksmbd_file *fp, u16 *fmt);\n int ksmbd_vfs_set_compression(struct ksmbd_work *work, struct ksmbd_file *fp, u16 fmt);\n int ksmbd_vfs_set_compression_create(struct ksmbd_work *work,\ndiff --git a/fs/smb/server/vfs_cache.c b/fs/smb/server/vfs_cache.c\nindex 496055ce4a4d9..96385d1cdbb42 100644\n--- a/fs/smb/server/vfs_cache.c\n+++ b/fs/smb/server/vfs_cache.c\n@@ -538,8 +538,7 @@ static void __ksmbd_inode_close(struct ksmbd_file *fp)\n \t\t\tconst struct cred *saved_cred;\n \n \t\t\tsaved_cred = override_creds(filp-\u003ef_cred);\n-\t\t\terr = ksmbd_vfs_remove_xattr(file_mnt_idmap(filp),\n-\t\t\t\t\t\t     \u0026filp-\u003ef_path,\n+\t\t\terr = ksmbd_vfs_remove_xattr(\u0026filp-\u003ef_path,\n \t\t\t\t\t\t     fp-\u003estream.name,\n \t\t\t\t\t\t     true);\n \t\t\trevert_creds(saved_cred);\ndiff --git a/fs/stat.c b/fs/stat.c\nindex a2e63c6c45b77..06e4a5dcea574 100644\n--- a/fs/stat.c\n+++ b/fs/stat.c\n@@ -172,7 +172,7 @@ EXPORT_SYMBOL_GPL(generic_fill_statx_atomic_writes);\n  * @request_mask: STATX_xxx flags indicating what the caller wants\n  * @query_flags: Query mode (AT_STATX_SYNC_TYPE)\n  *\n- * Get attributes without calling security_inode_getattr.\n+ * Get attributes without calling security_path_getattr.\n  *\n  * Currently the only caller other than vfs_getattr is internal to the\n  * filehandle lookup code, which uses only the inode number and returns no\n@@ -260,7 +260,7 @@ int vfs_getattr(const struct path *path, struct kstat *stat,\n {\n \tint retval;\n \n-\tretval = security_inode_getattr(path);\n+\tretval = security_path_getattr(path);\n \tif (unlikely(retval))\n \t\treturn retval;\n \treturn vfs_getattr_nosec(path, stat, request_mask, query_flags);\ndiff --git a/fs/utimes.c b/fs/utimes.c\nindex e22664e4115f6..5de794587147c 100644\n--- a/fs/utimes.c\n+++ b/fs/utimes.c\n@@ -64,8 +64,7 @@ int vfs_utimes(const struct path *path, struct timespec64 *times)\n \t}\n retry_deleg:\n \tinode_lock(inode);\n-\terror = notify_change(mnt_idmap(path-\u003emnt), path-\u003edentry, \u0026newattrs,\n-\t\t\t      \u0026delegated_inode);\n+\terror = notify_change(path, \u0026newattrs, \u0026delegated_inode);\n \tinode_unlock(inode);\n \tif (is_delegated(\u0026delegated_inode)) {\n \t\terror = break_deleg_wait(\u0026delegated_inode);\ndiff --git a/fs/xattr.c b/fs/xattr.c\nindex d9f035610f0bf..5e960f4504883 100644\n--- a/fs/xattr.c\n+++ b/fs/xattr.c\n@@ -285,8 +285,7 @@ int __vfs_setxattr_noperm(const struct mnt_idmap *idmap,\n  * __vfs_setxattr_locked - set an extended attribute while holding the inode\n  * lock\n  *\n- *  @idmap: idmap of the mount of the target inode\n- *  @dentry: object to perform setxattr on\n+ *  @path: object to perform setxattr on\n  *  @name: xattr name to set\n  *  @value: value to set @name to\n  *  @size: size of @value\n@@ -295,10 +294,12 @@ int __vfs_setxattr_noperm(const struct mnt_idmap *idmap,\n  *  a delegation was broken on, NULL if none.\n  */\n int\n-__vfs_setxattr_locked(const struct mnt_idmap *idmap, struct dentry *dentry,\n-\t\t      const char *name, const void *value, size_t size,\n-\t\t      int flags, struct delegated_inode *delegated_inode)\n+__vfs_setxattr_locked(const struct path *path, const char *name,\n+\t\t      const void *value, size_t size, int flags,\n+\t\t      struct delegated_inode *delegated_inode)\n {\n+\tconst struct mnt_idmap *idmap = mnt_idmap(path-\u003emnt);\n+\tstruct dentry *dentry = path-\u003edentry;\n \tstruct inode *inode = dentry-\u003ed_inode;\n \tint error;\n \n@@ -306,7 +307,7 @@ __vfs_setxattr_locked(const struct mnt_idmap *idmap, struct dentry *dentry,\n \tif (error)\n \t\treturn error;\n \n-\terror = security_inode_setxattr(idmap, dentry, name, value, size,\n+\terror = security_path_setxattr(path, name, value, size,\n \t\t\t\t\tflags);\n \tif (error)\n \t\tgoto out;\n@@ -324,9 +325,11 @@ __vfs_setxattr_locked(const struct mnt_idmap *idmap, struct dentry *dentry,\n EXPORT_SYMBOL_GPL(__vfs_setxattr_locked);\n \n int\n-vfs_setxattr(const struct mnt_idmap *idmap, struct dentry *dentry,\n-\t     const char *name, const void *value, size_t size, int flags)\n+vfs_setxattr(const struct path *path, const char *name, const void *value,\n+\t     size_t size, int flags)\n {\n+\tconst struct mnt_idmap *idmap = mnt_idmap(path-\u003emnt);\n+\tstruct dentry *dentry = path-\u003edentry;\n \tstruct inode *inode = dentry-\u003ed_inode;\n \tstruct delegated_inode delegated_inode = { };\n \tconst void  *orig_value = value;\n@@ -341,7 +344,7 @@ vfs_setxattr(const struct mnt_idmap *idmap, struct dentry *dentry,\n \n retry_deleg:\n \tinode_lock(inode);\n-\terror = __vfs_setxattr_locked(idmap, dentry, name, value, size,\n+\terror = __vfs_setxattr_locked(path, name, value, size,\n \t\t\t\t      flags, \u0026delegated_inode);\n \tinode_unlock(inode);\n \n@@ -448,9 +451,11 @@ __vfs_getxattr(struct dentry *dentry, struct inode *inode, const char *name,\n EXPORT_SYMBOL(__vfs_getxattr);\n \n ssize_t\n-vfs_getxattr(const struct mnt_idmap *idmap, struct dentry *dentry,\n-\t     const char *name, void *value, size_t size)\n+vfs_getxattr(const struct path *path, const char *name, void *value,\n+\t     size_t size)\n {\n+\tconst struct mnt_idmap *idmap = mnt_idmap(path-\u003emnt);\n+\tstruct dentry *dentry = path-\u003edentry;\n \tstruct inode *inode = dentry-\u003ed_inode;\n \tint error;\n \n@@ -458,7 +463,7 @@ vfs_getxattr(const struct mnt_idmap *idmap, struct dentry *dentry,\n \tif (error)\n \t\treturn error;\n \n-\terror = security_inode_getxattr(dentry, name);\n+\terror = security_path_getxattr(path, name);\n \tif (error)\n \t\treturn error;\n \n@@ -482,12 +487,12 @@ EXPORT_SYMBOL_GPL(vfs_getxattr);\n \n /**\n  * vfs_listxattr - retrieve \\0 separated list of xattr names\n- * @dentry: the dentry from whose inode the xattr names are retrieved\n+ * @path: the path from whose inode the xattr names are retrieved\n  * @list: buffer to store xattr names into\n  * @size: size of the buffer\n  *\n  * This function returns the names of all xattrs associated with the\n- * inode of @dentry.\n+ * inode of @path-\u003edentry.\n  *\n  * Note, for legacy reasons the vfs_listxattr() function lists POSIX\n  * ACLs as well. Since POSIX ACLs are decoupled from IOP_XATTR the\n@@ -503,12 +508,13 @@ EXPORT_SYMBOL_GPL(vfs_getxattr);\n  *         negative error code.\n  */\n ssize_t\n-vfs_listxattr(struct dentry *dentry, char *list, size_t size)\n+vfs_listxattr(const struct path *path, char *list, size_t size)\n {\n+\tstruct dentry *dentry = path-\u003edentry;\n \tstruct inode *inode = d_inode(dentry);\n \tssize_t error;\n \n-\terror = security_inode_listxattr(dentry);\n+\terror = security_path_listxattr(path);\n \tif (error)\n \t\treturn error;\n \n@@ -550,17 +556,17 @@ EXPORT_SYMBOL(__vfs_removexattr);\n  * __vfs_removexattr_locked - set an extended attribute while holding the inode\n  * lock\n  *\n- *  @idmap: idmap of the mount of the target inode\n- *  @dentry: object to perform setxattr on\n+ *  @path: object to perform removexattr on\n  *  @name: name of xattr to remove\n  *  @delegated_inode: on return, will contain an inode pointer that\n  *  a delegation was broken on, NULL if none.\n  */\n int\n-__vfs_removexattr_locked(const struct mnt_idmap *idmap,\n-\t\t\t struct dentry *dentry, const char *name,\n+__vfs_removexattr_locked(const struct path *path, const char *name,\n \t\t\t struct delegated_inode *delegated_inode)\n {\n+\tconst struct mnt_idmap *idmap = mnt_idmap(path-\u003emnt);\n+\tstruct dentry *dentry = path-\u003edentry;\n \tstruct inode *inode = dentry-\u003ed_inode;\n \tint error;\n \n@@ -568,7 +574,7 @@ __vfs_removexattr_locked(const struct mnt_idmap *idmap,\n \tif (error)\n \t\treturn error;\n \n-\terror = security_inode_removexattr(idmap, dentry, name);\n+\terror = security_path_removexattr(path, name);\n \tif (error)\n \t\tgoto out;\n \n@@ -589,17 +595,16 @@ __vfs_removexattr_locked(const struct mnt_idmap *idmap,\n EXPORT_SYMBOL_GPL(__vfs_removexattr_locked);\n \n int\n-vfs_removexattr(const struct mnt_idmap *idmap, struct dentry *dentry,\n-\t\tconst char *name)\n+vfs_removexattr(const struct path *path, const char *name)\n {\n+\tstruct dentry *dentry = path-\u003edentry;\n \tstruct inode *inode = dentry-\u003ed_inode;\n \tstruct delegated_inode delegated_inode = { };\n \tint error;\n \n retry_deleg:\n \tinode_lock(inode);\n-\terror = __vfs_removexattr_locked(idmap, dentry,\n-\t\t\t\t\t name, \u0026delegated_inode);\n+\terror = __vfs_removexattr_locked(path, name, \u0026delegated_inode);\n \tinode_unlock(inode);\n \n \tif (is_delegated(\u0026delegated_inode)) {\n@@ -652,14 +657,13 @@ int setxattr_copy(const char __user *name, struct kernel_xattr_ctx *ctx)\n \treturn error;\n }\n \n-static int do_setxattr(const struct mnt_idmap *idmap, struct dentry *dentry,\n-\t\tstruct kernel_xattr_ctx *ctx)\n+static int do_setxattr(const struct path *path, struct kernel_xattr_ctx *ctx)\n {\n \tif (is_posix_acl_xattr(ctx-\u003ekname-\u003ename))\n-\t\treturn do_set_acl(idmap, dentry, ctx-\u003ekname-\u003ename,\n+\t\treturn do_set_acl(path, ctx-\u003ekname-\u003ename,\n \t\t\t\t  ctx-\u003ekvalue, ctx-\u003esize);\n \n-\treturn vfs_setxattr(idmap, dentry, ctx-\u003ekname-\u003ename,\n+\treturn vfs_setxattr(path, ctx-\u003ekname-\u003ename,\n \t\t\tctx-\u003ekvalue, ctx-\u003esize, ctx-\u003eflags);\n }\n \n@@ -669,7 +673,7 @@ int file_setxattr(struct file *f, struct kernel_xattr_ctx *ctx)\n \n \tif (!error) {\n \t\taudit_file(f);\n-\t\terror = do_setxattr(file_mnt_idmap(f), f-\u003ef_path.dentry, ctx);\n+\t\terror = do_setxattr(\u0026f-\u003ef_path, ctx);\n \t\tmnt_drop_write_file(f);\n \t}\n \treturn error;\n@@ -687,7 +691,7 @@ int filename_setxattr(int dfd, struct filename *filename,\n \t\treturn error;\n \terror = mnt_want_write(path.mnt);\n \tif (!error) {\n-\t\terror = do_setxattr(mnt_idmap(path.mnt), path.dentry, ctx);\n+\t\terror = do_setxattr(\u0026path, ctx);\n \t\tmnt_drop_write(path.mnt);\n \t}\n \tpath_put(\u0026path);\n@@ -787,8 +791,7 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,\n  * Extended attribute GET operations\n  */\n static ssize_t\n-do_getxattr(const struct mnt_idmap *idmap, struct dentry *d,\n-\tstruct kernel_xattr_ctx *ctx)\n+do_getxattr(const struct path *path, struct kernel_xattr_ctx *ctx)\n {\n \tssize_t error;\n \tchar *kname = ctx-\u003ekname-\u003ename;\n@@ -803,9 +806,9 @@ do_getxattr(const struct mnt_idmap *idmap, struct dentry *d,\n \t}\n \n \tif (is_posix_acl_xattr(kname))\n-\t\terror = do_get_acl(idmap, d, kname, kvalue, ctx-\u003esize);\n+\t\terror = do_get_acl(path, kname, kvalue, ctx-\u003esize);\n \telse\n-\t\terror = vfs_getxattr(idmap, d, kname, kvalue, ctx-\u003esize);\n+\t\terror = vfs_getxattr(path, kname, kvalue, ctx-\u003esize);\n \tif (error \u003e 0) {\n \t\tif (ctx-\u003esize \u0026\u0026 copy_to_user(ctx-\u003evalue, kvalue, error))\n \t\t\terror = -EFAULT;\n@@ -822,7 +825,7 @@ do_getxattr(const struct mnt_idmap *idmap, struct dentry *d,\n ssize_t file_getxattr(struct file *f, struct kernel_xattr_ctx *ctx)\n {\n \taudit_file(f);\n-\treturn do_getxattr(file_mnt_idmap(f), f-\u003ef_path.dentry, ctx);\n+\treturn do_getxattr(\u0026f-\u003ef_path, ctx);\n }\n \n ssize_t filename_getxattr(int dfd, struct filename *filename,\n@@ -834,7 +837,7 @@ ssize_t filename_getxattr(int dfd, struct filename *filename,\n \terror = filename_lookup(dfd, filename, lookup_flags, \u0026path, NULL);\n \tif (error)\n \t\treturn error;\n-\terror = do_getxattr(mnt_idmap(path.mnt), path.dentry, ctx);\n+\terror = do_getxattr(\u0026path, ctx);\n \tpath_put(\u0026path);\n \tif (retry_estale(error, lookup_flags)) {\n \t\tlookup_flags |= LOOKUP_REVAL;\n@@ -925,7 +928,7 @@ SYSCALL_DEFINE4(fgetxattr, int, fd, const char __user *, name,\n  * Extended attribute LIST operations\n  */\n static ssize_t\n-listxattr(struct dentry *d, char __user *list, size_t size)\n+listxattr(const struct path *path, char __user *list, size_t size)\n {\n \tssize_t error;\n \tchar *klist = NULL;\n@@ -938,7 +941,7 @@ listxattr(struct dentry *d, char __user *list, size_t size)\n \t\t\treturn -ENOMEM;\n \t}\n \n-\terror = vfs_listxattr(d, klist, size);\n+\terror = vfs_listxattr(path, klist, size);\n \tif (error \u003e 0) {\n \t\tif (size \u0026\u0026 copy_to_user(list, klist, error))\n \t\t\terror = -EFAULT;\n@@ -957,7 +960,7 @@ static\n ssize_t file_listxattr(struct file *f, char __user *list, size_t size)\n {\n \taudit_file(f);\n-\treturn listxattr(f-\u003ef_path.dentry, list, size);\n+\treturn listxattr(\u0026f-\u003ef_path, list, size);\n }\n \n static\n@@ -971,7 +974,7 @@ ssize_t filename_listxattr(int dfd, struct filename *filename,\n \terror = filename_lookup(dfd, filename, lookup_flags, \u0026path, NULL);\n \tif (error)\n \t\treturn error;\n-\terror = listxattr(path.dentry, list, size);\n+\terror = listxattr(\u0026path, list, size);\n \tpath_put(\u0026path);\n \tif (retry_estale(error, lookup_flags)) {\n \t\tlookup_flags |= LOOKUP_REVAL;\n@@ -1029,11 +1032,11 @@ SYSCALL_DEFINE3(flistxattr, int, fd, char __user *, list, size_t, size)\n  * Extended attribute REMOVE operations\n  */\n static long\n-removexattr(const struct mnt_idmap *idmap, struct dentry *d, const char *name)\n+removexattr(const struct path *path, const char *name)\n {\n \tif (is_posix_acl_xattr(name))\n-\t\treturn vfs_remove_acl(idmap, d, name);\n-\treturn vfs_removexattr(idmap, d, name);\n+\t\treturn vfs_remove_acl(path, name);\n+\treturn vfs_removexattr(path, name);\n }\n \n static int file_removexattr(struct file *f, struct xattr_name *kname)\n@@ -1042,8 +1045,7 @@ static int file_removexattr(struct file *f, struct xattr_name *kname)\n \n \tif (!error) {\n \t\taudit_file(f);\n-\t\terror = removexattr(file_mnt_idmap(f),\n-\t\t\t\t    f-\u003ef_path.dentry, kname-\u003ename);\n+\t\terror = removexattr(\u0026f-\u003ef_path, kname-\u003ename);\n \t\tmnt_drop_write_file(f);\n \t}\n \treturn error;\n@@ -1061,7 +1063,7 @@ static int filename_removexattr(int dfd, struct filename *filename,\n \t\treturn error;\n \terror = mnt_want_write(path.mnt);\n \tif (!error) {\n-\t\terror = removexattr(mnt_idmap(path.mnt), path.dentry, kname-\u003ename);\n+\t\terror = removexattr(\u0026path, kname-\u003ename);\n \t\tmnt_drop_write(path.mnt);\n \t}\n \tpath_put(\u0026path);\ndiff --git a/include/linux/fileattr.h b/include/linux/fileattr.h\nindex 09e32b84e02ac..a572cb8500146 100644\n--- a/include/linux/fileattr.h\n+++ b/include/linux/fileattr.h\n@@ -73,9 +73,11 @@ static inline bool fileattr_has_fsx(const struct file_kattr *fa)\n \t\t fa-\u003efsx_projid != 0 ||\tfa-\u003efsx_cowextsize != 0);\n }\n \n-int vfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa);\n-int vfs_fileattr_set(const struct mnt_idmap *idmap, struct dentry *dentry,\n-\t\t     struct file_kattr *fa);\n+int __vfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa);\n+int __vfs_fileattr_set(const struct mnt_idmap *idmap, struct dentry *dentry,\n+\t\t       struct file_kattr *fa);\n+int vfs_fileattr_get(const struct path *path, struct file_kattr *fa);\n+int vfs_fileattr_set(const struct path *path, struct file_kattr *fa);\n int ioctl_getflags(struct file *file, unsigned int __user *argp);\n int ioctl_setflags(struct file *file, unsigned int __user *argp);\n int ioctl_fsgetxattr(struct file *file, void __user *argp);\ndiff --git a/include/linux/fs.h b/include/linux/fs.h\nindex f387c961e0a0a..5db46082906c3 100644\n--- a/include/linux/fs.h\n+++ b/include/linux/fs.h\n@@ -2488,7 +2488,7 @@ static inline bool is_idmapped_mnt(const struct vfsmount *mnt)\n }\n \n int vfs_truncate(const struct path *, loff_t);\n-int do_truncate(const struct mnt_idmap *, struct dentry *, loff_t start,\n+int do_truncate(const struct path *path, loff_t length,\n \t\tunsigned int time_attrs, struct file *filp);\n extern int vfs_fallocate(struct file *file, int mode, loff_t offset,\n \t\t\tloff_t len);\n@@ -2712,8 +2712,10 @@ static inline int bmap(struct inode *inode,  sector_t *block)\n }\n #endif\n \n-int notify_change(const struct mnt_idmap *, struct dentry *,\n-\t\t  struct iattr *, struct delegated_inode *);\n+int __notify_change(const struct mnt_idmap *, struct dentry *,\n+\t\t    struct iattr *, struct delegated_inode *);\n+int notify_change(const struct path *path, struct iattr *attr,\n+\t\t  struct delegated_inode *delegated_inode);\n int inode_permission(const struct mnt_idmap *, struct inode *, int);\n int generic_permission(const struct mnt_idmap *, struct inode *, int);\n static inline int file_permission(struct file *file, int mask)\ndiff --git a/include/linux/landlock.h b/include/linux/landlock.h\nindex 0ee4880988bab..ee1234fbc9f06 100644\n--- a/include/linux/landlock.h\n+++ b/include/linux/landlock.h\n@@ -41,7 +41,9 @@\n \t_LANDLOCK_NAME_ENTRY(LANDLOCK_ACCESS_FS_REFER, \"refer\"), \\\n \t_LANDLOCK_NAME_ENTRY(LANDLOCK_ACCESS_FS_TRUNCATE, \"truncate\"), \\\n \t_LANDLOCK_NAME_ENTRY(LANDLOCK_ACCESS_FS_IOCTL_DEV, \"ioctl_dev\"), \\\n-\t_LANDLOCK_NAME_ENTRY(LANDLOCK_ACCESS_FS_RESOLVE_UNIX, \"resolve_unix\")\n+\t_LANDLOCK_NAME_ENTRY(LANDLOCK_ACCESS_FS_RESOLVE_UNIX, \"resolve_unix\"), \\\n+\t_LANDLOCK_NAME_ENTRY(LANDLOCK_ACCESS_FS_READ_METADATA, \"read_metadata\"), \\\n+\t_LANDLOCK_NAME_ENTRY(LANDLOCK_ACCESS_FS_WRITE_METADATA, \"write_metadata\")\n \n #define _LANDLOCK_ACCESS_NET_NAMES \\\n \t_LANDLOCK_NAME_ENTRY(LANDLOCK_ACCESS_NET_BIND_TCP, \"bind_tcp\"), \\\ndiff --git a/include/linux/lsm_hook_defs.h b/include/linux/lsm_hook_defs.h\nindex ef16e5343e099..9ea096505ef1f 100644\n--- a/include/linux/lsm_hook_defs.h\n+++ b/include/linux/lsm_hook_defs.h\n@@ -142,33 +142,34 @@ LSM_HOOK(int, 0, inode_follow_link, struct dentry *dentry, struct inode *inode,\n \t bool rcu)\n LSM_HOOK(int, 0, inode_permission, const struct mnt_idmap *idmap,\n \t struct inode *inode, int mask)\n-LSM_HOOK(int, 0, inode_setattr, const struct mnt_idmap *idmap, struct dentry *dentry,\n+LSM_HOOK(int, 0, path_setattr, const struct path *path,\n \t struct iattr *attr)\n LSM_HOOK(void, LSM_RET_VOID, inode_post_setattr, const struct mnt_idmap *idmap,\n \t struct dentry *dentry, int ia_valid)\n-LSM_HOOK(int, 0, inode_getattr, const struct path *path)\n+LSM_HOOK(int, 0, path_getattr, const struct path *path)\n LSM_HOOK(int, 0, inode_xattr_skipcap, const char *name)\n-LSM_HOOK(int, 0, inode_setxattr, const struct mnt_idmap *idmap,\n-\t struct dentry *dentry, const char *name, const void *value,\n-\t size_t size, int flags)\n+LSM_HOOK(int, 0, path_setxattr, const struct path *path,\n+\t const char *name, const void *value, size_t size, int flags)\n LSM_HOOK(void, LSM_RET_VOID, inode_post_setxattr, struct dentry *dentry,\n \t const char *name, const void *value, size_t size, int flags)\n-LSM_HOOK(int, 0, inode_getxattr, struct dentry *dentry, const char *name)\n-LSM_HOOK(int, 0, inode_listxattr, struct dentry *dentry)\n-LSM_HOOK(int, 0, inode_removexattr, const struct mnt_idmap *idmap,\n-\t struct dentry *dentry, const char *name)\n+LSM_HOOK(int, 0, path_getxattr, const struct path *path, const char *name)\n+LSM_HOOK(int, 0, path_listxattr, const struct path *path)\n+LSM_HOOK(int, 0, path_removexattr, const struct path *path,\n+\t const char *name)\n LSM_HOOK(void, LSM_RET_VOID, inode_post_removexattr, struct dentry *dentry,\n \t const char *name)\n-LSM_HOOK(int, 0, inode_file_setattr, struct dentry *dentry, struct file_kattr *fa)\n-LSM_HOOK(int, 0, inode_file_getattr, struct dentry *dentry, struct file_kattr *fa)\n-LSM_HOOK(int, 0, inode_set_acl, const struct mnt_idmap *idmap,\n-\t struct dentry *dentry, const char *acl_name, struct posix_acl *kacl)\n+LSM_HOOK(int, 0, path_file_setattr, const struct path *path,\n+\t struct file_kattr *fa)\n+LSM_HOOK(int, 0, path_file_getattr, const struct path *path,\n+\t struct file_kattr *fa)\n+LSM_HOOK(int, 0, path_set_acl, const struct path *path,\n+\t const char *acl_name, struct posix_acl *kacl)\n LSM_HOOK(void, LSM_RET_VOID, inode_post_set_acl, struct dentry *dentry,\n \t const char *acl_name, struct posix_acl *kacl)\n-LSM_HOOK(int, 0, inode_get_acl, const struct mnt_idmap *idmap,\n-\t struct dentry *dentry, const char *acl_name)\n-LSM_HOOK(int, 0, inode_remove_acl, const struct mnt_idmap *idmap,\n-\t struct dentry *dentry, const char *acl_name)\n+LSM_HOOK(int, 0, path_get_acl, const struct path *path,\n+\t const char *acl_name)\n+LSM_HOOK(int, 0, path_remove_acl, const struct path *path,\n+\t const char *acl_name)\n LSM_HOOK(void, LSM_RET_VOID, inode_post_remove_acl, const struct mnt_idmap *idmap,\n \t struct dentry *dentry, const char *acl_name)\n LSM_HOOK(int, 0, inode_need_killpriv, struct dentry *dentry)\n@@ -314,7 +315,7 @@ LSM_HOOK(int, 0, secctx_to_secid, const char *secdata, u32 seclen, u32 *secid)\n LSM_HOOK(void, LSM_RET_VOID, release_secctx, struct lsm_context *cp)\n LSM_HOOK(void, LSM_RET_VOID, inode_invalidate_secctx, struct inode *inode)\n LSM_HOOK(int, 0, inode_notifysecctx, struct inode *inode, void *ctx, u32 ctxlen)\n-LSM_HOOK(int, 0, inode_setsecctx, struct dentry *dentry, void *ctx, u32 ctxlen)\n+LSM_HOOK(int, 0, path_setsecctx, const struct path *path, void *ctx, u32 ctxlen)\n LSM_HOOK(int, -EOPNOTSUPP, inode_getsecctx, struct inode *inode,\n \t struct lsm_context *cp)\n \ndiff --git a/include/linux/posix_acl.h b/include/linux/posix_acl.h\nindex caf500bed9933..44c23c4e9f946 100644\n--- a/include/linux/posix_acl.h\n+++ b/include/linux/posix_acl.h\n@@ -105,12 +105,11 @@ static inline void cache_no_acl(struct inode *inode)\n \tinode-\u003ei_default_acl = NULL;\n }\n \n-int vfs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,\n-\t\tconst char *acl_name, struct posix_acl *kacl);\n-struct posix_acl *vfs_get_acl(const struct mnt_idmap *idmap,\n-\t\t\t      struct dentry *dentry, const char *acl_name);\n-int vfs_remove_acl(const struct mnt_idmap *idmap, struct dentry *dentry,\n-\t\t   const char *acl_name);\n+int vfs_set_acl(const struct path *path, const char *acl_name,\n+\t\tstruct posix_acl *kacl);\n+struct posix_acl *vfs_get_acl(const struct path *path,\n+\t\t\t      const char *acl_name);\n+int vfs_remove_acl(const struct path *path, const char *acl_name);\n int posix_acl_listxattr(struct inode *inode, char **buffer,\n \t\t\tssize_t *remaining_size);\n #else\n@@ -141,22 +140,20 @@ static inline void forget_all_cached_acls(struct inode *inode)\n {\n }\n \n-static inline int vfs_set_acl(const struct mnt_idmap *idmap,\n-\t\t\t      struct dentry *dentry, const char *name,\n+static inline int vfs_set_acl(const struct path *path, const char *name,\n \t\t\t      struct posix_acl *acl)\n {\n \treturn -EOPNOTSUPP;\n }\n \n-static inline struct posix_acl *vfs_get_acl(const struct mnt_idmap *idmap,\n-\t\t\t\t\t    struct dentry *dentry,\n+static inline struct posix_acl *vfs_get_acl(const struct path *path,\n \t\t\t\t\t    const char *acl_name)\n {\n \treturn ERR_PTR(-EOPNOTSUPP);\n }\n \n-static inline int vfs_remove_acl(const struct mnt_idmap *idmap,\n-\t\t\t\t struct dentry *dentry, const char *acl_name)\n+static inline int vfs_remove_acl(const struct path *path,\n+\t\t\t\t const char *acl_name)\n {\n \treturn -EOPNOTSUPP;\n }\ndiff --git a/include/linux/security.h b/include/linux/security.h\nindex 8b8d6b8b802f1..c99a050595c5b 100644\n--- a/include/linux/security.h\n+++ b/include/linux/security.h\n@@ -185,10 +185,9 @@ extern int cap_capset(struct cred *new, const struct cred *old,\n \t\t      const kernel_cap_t *inheritable,\n \t\t      const kernel_cap_t *permitted);\n extern int cap_bprm_creds_from_file(struct linux_binprm *bprm, const struct file *file);\n-int cap_inode_setxattr(struct dentry *dentry, const char *name,\n+int cap_inode_setxattr(const struct path *path, const char *name,\n \t\t       const void *value, size_t size, int flags);\n-int cap_inode_removexattr(const struct mnt_idmap *idmap,\n-\t\t\t  struct dentry *dentry, const char *name);\n+int cap_inode_removexattr(const struct path *path, const char *name);\n int cap_inode_need_killpriv(struct dentry *dentry);\n int cap_inode_killpriv(const struct mnt_idmap *idmap, struct dentry *dentry);\n int cap_inode_getsecurity(const struct mnt_idmap *idmap,\n@@ -429,36 +428,32 @@ int security_inode_follow_link(struct dentry *dentry, struct inode *inode,\n \t\t\t       bool rcu);\n int security_inode_permission(const struct mnt_idmap *idmap, struct inode *inode,\n \t\t\t      int mask);\n-int security_inode_setattr(const struct mnt_idmap *idmap,\n-\t\t\t   struct dentry *dentry, struct iattr *attr);\n+int security_path_setattr(const struct path *path, struct iattr *attr);\n void security_inode_post_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,\n \t\t\t\t int ia_valid);\n-int security_inode_getattr(const struct path *path);\n-int security_inode_setxattr(const struct mnt_idmap *idmap,\n-\t\t\t    struct dentry *dentry, const char *name,\n-\t\t\t    const void *value, size_t size, int flags);\n-int security_inode_set_acl(const struct mnt_idmap *idmap,\n-\t\t\t   struct dentry *dentry, const char *acl_name,\n-\t\t\t   struct posix_acl *kacl);\n+int security_path_getattr(const struct path *path);\n+int security_path_setxattr(const struct path *path,\n+\t\t\t    const char *name, const void *value,\n+\t\t\t    size_t size, int flags);\n+int security_path_set_acl(const struct path *path,\n+\t\t\t   const char *acl_name, struct posix_acl *kacl);\n void security_inode_post_set_acl(struct dentry *dentry, const char *acl_name,\n \t\t\t\t struct posix_acl *kacl);\n-int security_inode_get_acl(const struct mnt_idmap *idmap,\n-\t\t\t   struct dentry *dentry, const char *acl_name);\n-int security_inode_remove_acl(const struct mnt_idmap *idmap,\n-\t\t\t      struct dentry *dentry, const char *acl_name);\n+int security_path_get_acl(const struct path *path, const char *acl_name);\n+int security_path_remove_acl(const struct path *path, const char *acl_name);\n void security_inode_post_remove_acl(const struct mnt_idmap *idmap,\n \t\t\t\t    struct dentry *dentry,\n \t\t\t\t    const char *acl_name);\n void security_inode_post_setxattr(struct dentry *dentry, const char *name,\n \t\t\t\t  const void *value, size_t size, int flags);\n-int security_inode_getxattr(struct dentry *dentry, const char *name);\n-int security_inode_listxattr(struct dentry *dentry);\n-int security_inode_removexattr(const struct mnt_idmap *idmap,\n-\t\t\t       struct dentry *dentry, const char *name);\n+int security_path_getxattr(const struct path *path, const char *name);\n+int security_path_listxattr(const struct path *path);\n+int security_path_removexattr(const struct path *path,\n+\t\t\t       const char *name);\n void security_inode_post_removexattr(struct dentry *dentry, const char *name);\n-int security_inode_file_setattr(struct dentry *dentry,\n+int security_path_file_setattr(const struct path *path,\n \t\t\t      struct file_kattr *fa);\n-int security_inode_file_getattr(struct dentry *dentry,\n+int security_path_file_getattr(const struct path *path,\n \t\t\t      struct file_kattr *fa);\n int security_inode_need_killpriv(struct dentry *dentry);\n int security_inode_killpriv(const struct mnt_idmap *idmap, struct dentry *dentry);\n@@ -589,7 +584,7 @@ int security_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid);\n void security_release_secctx(struct lsm_context *cp);\n void security_inode_invalidate_secctx(struct inode *inode);\n int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen);\n-int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen);\n+int security_path_setsecctx(const struct path *path, void *ctx, u32 ctxlen);\n int security_inode_getsecctx(struct inode *inode, struct lsm_context *cp);\n int security_locked_down(enum lockdown_reason what);\n int lsm_fill_user_ctx(struct lsm_ctx __user *uctx, u32 *uctx_len,\n@@ -1001,8 +996,7 @@ static inline int security_inode_permission(const struct mnt_idmap *idmap,\n \treturn 0;\n }\n \n-static inline int security_inode_setattr(const struct mnt_idmap *idmap,\n-\t\t\t\t\t struct dentry *dentry,\n+static inline int security_path_setattr(const struct path *path,\n \t\t\t\t\t struct iattr *attr)\n {\n \treturn 0;\n@@ -1013,20 +1007,18 @@ security_inode_post_setattr(const struct mnt_idmap *idmap, struct dentry *dentry\n \t\t\t    int ia_valid)\n { }\n \n-static inline int security_inode_getattr(const struct path *path)\n+static inline int security_path_getattr(const struct path *path)\n {\n \treturn 0;\n }\n \n-static inline int security_inode_setxattr(const struct mnt_idmap *idmap,\n-\t\tstruct dentry *dentry, const char *name, const void *value,\n-\t\tsize_t size, int flags)\n+static inline int security_path_setxattr(const struct path *path,\n+\t\tconst char *name, const void *value, size_t size, int flags)\n {\n-\treturn cap_inode_setxattr(dentry, name, value, size, flags);\n+\treturn cap_inode_setxattr(path, name, value, size, flags);\n }\n \n-static inline int security_inode_set_acl(const struct mnt_idmap *idmap,\n-\t\t\t\t\t struct dentry *dentry,\n+static inline int security_path_set_acl(const struct path *path,\n \t\t\t\t\t const char *acl_name,\n \t\t\t\t\t struct posix_acl *kacl)\n {\n@@ -1038,15 +1030,13 @@ static inline void security_inode_post_set_acl(struct dentry *dentry,\n \t\t\t\t\t       struct posix_acl *kacl)\n { }\n \n-static inline int security_inode_get_acl(const struct mnt_idmap *idmap,\n-\t\t\t\t\t struct dentry *dentry,\n+static inline int security_path_get_acl(const struct path *path,\n \t\t\t\t\t const char *acl_name)\n {\n \treturn 0;\n }\n \n-static inline int security_inode_remove_acl(const struct mnt_idmap *idmap,\n-\t\t\t\t\t    struct dentry *dentry,\n+static inline int security_path_remove_acl(const struct path *path,\n \t\t\t\t\t    const char *acl_name)\n {\n \treturn 0;\n@@ -1061,35 +1051,34 @@ static inline void security_inode_post_setxattr(struct dentry *dentry,\n \t\tconst char *name, const void *value, size_t size, int flags)\n { }\n \n-static inline int security_inode_getxattr(struct dentry *dentry,\n+static inline int security_path_getxattr(const struct path *path,\n \t\t\tconst char *name)\n {\n \treturn 0;\n }\n \n-static inline int security_inode_listxattr(struct dentry *dentry)\n+static inline int security_path_listxattr(const struct path *path)\n {\n \treturn 0;\n }\n \n-static inline int security_inode_removexattr(const struct mnt_idmap *idmap,\n-\t\t\t\t\t     struct dentry *dentry,\n+static inline int security_path_removexattr(const struct path *path,\n \t\t\t\t\t     const char *name)\n {\n-\treturn cap_inode_removexattr(idmap, dentry, name);\n+\treturn cap_inode_removexattr(path, name);\n }\n \n static inline void security_inode_post_removexattr(struct dentry *dentry,\n \t\t\t\t\t\t   const char *name)\n { }\n \n-static inline int security_inode_file_setattr(struct dentry *dentry,\n+static inline int security_path_file_setattr(const struct path *path,\n \t\t\t\t\t      struct file_kattr *fa)\n {\n \treturn 0;\n }\n \n-static inline int security_inode_file_getattr(struct dentry *dentry,\n+static inline int security_path_file_getattr(const struct path *path,\n \t\t\t\t\t      struct file_kattr *fa)\n {\n \treturn 0;\n@@ -1637,7 +1626,7 @@ static inline int security_inode_notifysecctx(struct inode *inode, void *ctx, u3\n {\n \treturn -EOPNOTSUPP;\n }\n-static inline int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen)\n+static inline int security_path_setsecctx(const struct path *path, void *ctx, u32 ctxlen)\n {\n \treturn -EOPNOTSUPP;\n }\ndiff --git a/include/linux/xattr.h b/include/linux/xattr.h\nindex 4cc4257de084e..b0c980c7c3361 100644\n--- a/include/linux/xattr.h\n+++ b/include/linux/xattr.h\n@@ -77,22 +77,22 @@ struct xattr {\n };\n \n ssize_t __vfs_getxattr(struct dentry *, struct inode *, const char *, void *, size_t);\n-ssize_t vfs_getxattr(const struct mnt_idmap *, struct dentry *, const char *,\n-\t\t     void *, size_t);\n-ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);\n+ssize_t vfs_getxattr(const struct path *path, const char *name, void *value,\n+\t\t     size_t size);\n+ssize_t vfs_listxattr(const struct path *path, char *list, size_t size);\n int __vfs_setxattr(const struct mnt_idmap *, struct dentry *, struct inode *,\n \t\t   const char *, const void *, size_t, int);\n int __vfs_setxattr_noperm(const struct mnt_idmap *, struct dentry *,\n \t\t\t  const char *, const void *, size_t, int);\n-int __vfs_setxattr_locked(const struct mnt_idmap *, struct dentry *,\n-\t\t\t  const char *, const void *, size_t, int,\n-\t\t\t  struct delegated_inode *);\n-int vfs_setxattr(const struct mnt_idmap *, struct dentry *, const char *,\n-\t\t const void *, size_t, int);\n+int __vfs_setxattr_locked(const struct path *path, const char *name,\n+\t\t\t  const void *value, size_t size, int flags,\n+\t\t\t  struct delegated_inode *delegated_inode);\n+int vfs_setxattr(const struct path *path, const char *name,\n+\t\t const void *value, size_t size, int flags);\n int __vfs_removexattr(const struct mnt_idmap *, struct dentry *, const char *);\n-int __vfs_removexattr_locked(const struct mnt_idmap *, struct dentry *,\n-\t\t\t     const char *, struct delegated_inode *);\n-int vfs_removexattr(const struct mnt_idmap *, struct dentry *, const char *);\n+int __vfs_removexattr_locked(const struct path *path, const char *name,\n+\t\t\t     struct delegated_inode *delegated_inode);\n+int vfs_removexattr(const struct path *path, const char *name);\n \n ssize_t generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size);\n int vfs_getxattr_alloc(const struct mnt_idmap *idmap,\ndiff --git a/include/uapi/linux/landlock.h b/include/uapi/linux/landlock.h\nindex 24510e5d8479a..36dfb499e48e1 100644\n--- a/include/uapi/linux/landlock.h\n+++ b/include/uapi/linux/landlock.h\n@@ -429,6 +429,25 @@ struct landlock_capability_attr {\n  *\n  *   The rationale for this design is described in\n  *   :ref:`Documentation/security/landlock.rst \u003cscoped-flags-interaction\u003e`.\n+ * - %LANDLOCK_ACCESS_FS_READ_METADATA: Read file or directory metadata (e.g.\n+ *   inode attributes, extended attributes, and POSIX ACLs) through\n+ *   :manpage:`stat(2)`, :manpage:`fstat(2)`, :manpage:`lstat(2)`,\n+ *   :manpage:`newfstatat(2)`, :manpage:`getxattr(2)`, and\n+ *   :manpage:`listxattr(2)`.\n+ *\n+ *   This access right is available since the thirteenth version of the\n+ *   Landlock ABI.\n+ * - %LANDLOCK_ACCESS_FS_WRITE_METADATA: Change file or directory metadata\n+ *   (e.g. inode attributes, extended attributes, and POSIX ACLs) through\n+ *   :manpage:`chmod(2)`, :manpage:`chown(2)`, :manpage:`utimensat(2)`,\n+ *   :manpage:`setxattr(2)`, and :manpage:`removexattr(2)`, as well as related\n+ *   system calls.  Implicit metadata changes performed by the kernel (e.g.\n+ *   timestamp updates with :manpage:`write(2)`, or set-user-ID and\n+ *   set-group-ID bit clearing with :manpage:`write(2)` or\n+ *   :manpage:`truncate(2)`) are not restricted by this access right.\n+ *\n+ *   This access right is available since the thirteenth version of the\n+ *   Landlock ABI.\n  *\n  * Whether an opened file can be truncated with :manpage:`ftruncate(2)` or used\n  * with `ioctl(2)` is determined during :manpage:`open(2)`, in the same way as\n@@ -493,9 +512,7 @@ struct landlock_capability_attr {\n  *\n  *   It is currently not possible to restrict some file-related actions\n  *   accessible through these syscall families: :manpage:`chdir(2)`,\n- *   :manpage:`stat(2)`, :manpage:`flock(2)`, :manpage:`chmod(2)`,\n- *   :manpage:`chown(2)`, :manpage:`setxattr(2)`, :manpage:`utime(2)`,\n- *   :manpage:`fcntl(2)`, :manpage:`access(2)`.\n+ *   :manpage:`flock(2)`, :manpage:`fcntl(2)`, :manpage:`access(2)`.\n  *   Future Landlock evolutions will enable to restrict them.\n  */\n /* clang-format off */\n@@ -516,6 +533,8 @@ struct landlock_capability_attr {\n #define LANDLOCK_ACCESS_FS_TRUNCATE\t\t\t(1ULL \u003c\u003c 14)\n #define LANDLOCK_ACCESS_FS_IOCTL_DEV\t\t\t(1ULL \u003c\u003c 15)\n #define LANDLOCK_ACCESS_FS_RESOLVE_UNIX\t\t\t(1ULL \u003c\u003c 16)\n+#define LANDLOCK_ACCESS_FS_READ_METADATA\t\t(1ULL \u003c\u003c 17)\n+#define LANDLOCK_ACCESS_FS_WRITE_METADATA\t\t(1ULL \u003c\u003c 18)\n /* clang-format on */\n \n /**\ndiff --git a/kernel/bpf/bpf_lsm.c b/kernel/bpf/bpf_lsm.c\nindex f58dce888ff4a..9d77714178127 100644\n--- a/kernel/bpf/bpf_lsm.c\n+++ b/kernel/bpf/bpf_lsm.c\n@@ -335,18 +335,18 @@ BTF_ID(func, bpf_lsm_file_receive)\n \n BTF_ID(func, bpf_lsm_inode_create)\n BTF_ID(func, bpf_lsm_inode_free_security)\n-BTF_ID(func, bpf_lsm_inode_getattr)\n-BTF_ID(func, bpf_lsm_inode_getxattr)\n+BTF_ID(func, bpf_lsm_path_getattr)\n+BTF_ID(func, bpf_lsm_path_getxattr)\n BTF_ID(func, bpf_lsm_inode_mknod)\n BTF_ID(func, bpf_lsm_inode_need_killpriv)\n BTF_ID(func, bpf_lsm_inode_post_setxattr)\n BTF_ID(func, bpf_lsm_inode_post_removexattr)\n BTF_ID(func, bpf_lsm_inode_readlink)\n-BTF_ID(func, bpf_lsm_inode_removexattr)\n+BTF_ID(func, bpf_lsm_path_removexattr)\n BTF_ID(func, bpf_lsm_inode_rename)\n BTF_ID(func, bpf_lsm_inode_rmdir)\n-BTF_ID(func, bpf_lsm_inode_setattr)\n-BTF_ID(func, bpf_lsm_inode_setxattr)\n+BTF_ID(func, bpf_lsm_path_setattr)\n+BTF_ID(func, bpf_lsm_path_setxattr)\n BTF_ID(func, bpf_lsm_inode_symlink)\n BTF_ID(func, bpf_lsm_inode_unlink)\n BTF_ID(func, bpf_lsm_kernel_module_request)\ndiff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c\nindex 195f78db9bdaf..6f36647188429 100644\n--- a/kernel/trace/bpf_trace.c\n+++ b/kernel/trace/bpf_trace.c\n@@ -961,7 +961,7 @@ BPF_CALL_3(bpf_d_path, const struct path *, path, char *, buf, u32, sz)\n BTF_SET_START(btf_allowlist_d_path)\n #ifdef CONFIG_SECURITY\n BTF_ID(func, security_file_permission)\n-BTF_ID(func, security_inode_getattr)\n+BTF_ID(func, security_path_getattr)\n BTF_ID(func, security_file_open)\n #endif\n #ifdef CONFIG_SECURITY_PATH\ndiff --git a/samples/landlock/sandboxer.c b/samples/landlock/sandboxer.c\nindex 1362f08ff14b9..29965ef90bed6 100644\n--- a/samples/landlock/sandboxer.c\n+++ b/samples/landlock/sandboxer.c\n@@ -137,6 +137,8 @@ static int parse_path(char *env_path, const char ***const path_list)\n \tLANDLOCK_ACCESS_FS_EXECUTE | \\\n \tLANDLOCK_ACCESS_FS_WRITE_FILE | \\\n \tLANDLOCK_ACCESS_FS_READ_FILE | \\\n+\tLANDLOCK_ACCESS_FS_READ_METADATA | \\\n+\tLANDLOCK_ACCESS_FS_WRITE_METADATA | \\\n \tLANDLOCK_ACCESS_FS_TRUNCATE | \\\n \tLANDLOCK_ACCESS_FS_IOCTL_DEV | \\\n \tLANDLOCK_ACCESS_FS_RESOLVE_UNIX)\n@@ -487,7 +489,8 @@ static bool check_ruleset_scope(const char *const env_var,\n #define ACCESS_FS_ROUGHLY_READ ( \\\n \tLANDLOCK_ACCESS_FS_EXECUTE | \\\n \tLANDLOCK_ACCESS_FS_READ_FILE | \\\n-\tLANDLOCK_ACCESS_FS_READ_DIR)\n+\tLANDLOCK_ACCESS_FS_READ_DIR | \\\n+\tLANDLOCK_ACCESS_FS_READ_METADATA)\n \n #define ACCESS_FS_ROUGHLY_WRITE ( \\\n \tLANDLOCK_ACCESS_FS_WRITE_FILE | \\\n@@ -503,7 +506,8 @@ static bool check_ruleset_scope(const char *const env_var,\n \tLANDLOCK_ACCESS_FS_REFER | \\\n \tLANDLOCK_ACCESS_FS_TRUNCATE | \\\n \tLANDLOCK_ACCESS_FS_IOCTL_DEV | \\\n-\tLANDLOCK_ACCESS_FS_RESOLVE_UNIX)\n+\tLANDLOCK_ACCESS_FS_RESOLVE_UNIX | \\\n+\tLANDLOCK_ACCESS_FS_WRITE_METADATA)\n \n /* clang-format on */\n \n@@ -570,7 +574,7 @@ static int add_quiet_access(const char *const env_var,\n \treturn 0;\n }\n \n-#define LANDLOCK_ABI_LAST 12\n+#define LANDLOCK_ABI_LAST 13\n \n #define XSTR(s) #s\n #define STR(s) XSTR(s)\n@@ -780,6 +784,12 @@ int main(const int argc, char *const argv[], char *const *const envp)\n \t\truleset_attr.handled_permissions \u0026=\n \t\t\t~(LANDLOCK_PERMISSION_NAMESPACE_USE |\n \t\t\t  LANDLOCK_PERMISSION_CAPABILITY_USE);\n+\t\t__attribute__((fallthrough));\n+\tcase 12:\n+\t\t/* Removes metadata rights for ABI \u003c 13 */\n+\t\truleset_attr.handled_access_fs \u0026=\n+\t\t\t~(LANDLOCK_ACCESS_FS_READ_METADATA |\n+\t\t\t  LANDLOCK_ACCESS_FS_WRITE_METADATA);\n \t\t/* Must be printed for any ABI \u003c LANDLOCK_ABI_LAST. */\n \t\tfprintf(stderr,\n \t\t\t\"Hint: You should update the running kernel \"\ndiff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c\nindex 9d572cf8486b2..a2886f6ece786 100644\n--- a/security/apparmor/lsm.c\n+++ b/security/apparmor/lsm.c\n@@ -456,7 +456,7 @@ static int apparmor_path_chown(const struct path *path, kuid_t uid, kgid_t gid)\n \treturn common_perm_cond(OP_CHOWN, path, AA_MAY_CHOWN);\n }\n \n-static int apparmor_inode_getattr(const struct path *path)\n+static int apparmor_path_getattr(const struct path *path)\n {\n \treturn common_perm_cond(OP_GETATTR, path, AA_MAY_GETATTR);\n }\n@@ -1785,7 +1785,7 @@ static struct security_hook_list apparmor_hooks[] __ro_after_init = {\n \tLSM_HOOK_INIT(path_chmod, apparmor_path_chmod),\n \tLSM_HOOK_INIT(path_chown, apparmor_path_chown),\n \tLSM_HOOK_INIT(path_truncate, apparmor_path_truncate),\n-\tLSM_HOOK_INIT(inode_getattr, apparmor_inode_getattr),\n+\tLSM_HOOK_INIT(path_getattr, apparmor_path_getattr),\n \n \tLSM_HOOK_INIT(file_open, apparmor_file_open),\n \tLSM_HOOK_INIT(file_receive, apparmor_file_receive),\ndiff --git a/security/commoncap.c b/security/commoncap.c\nindex 565c893c6d4b4..971994e9553e6 100644\n--- a/security/commoncap.c\n+++ b/security/commoncap.c\n@@ -14,6 +14,7 @@\n #include \u003clinux/netlink.h\u003e\n #include \u003clinux/ptrace.h\u003e\n #include \u003clinux/xattr.h\u003e\n+#include \u003clinux/path.h\u003e\n #include \u003clinux/mount.h\u003e\n #include \u003clinux/sched.h\u003e\n #include \u003clinux/prctl.h\u003e\n@@ -1007,7 +1008,7 @@ int cap_bprm_creds_from_file(struct linux_binprm *bprm, const struct file *file)\n \n /**\n  * cap_inode_setxattr - Determine whether an xattr may be altered\n- * @dentry: The inode/dentry being altered\n+ * @path: The inode/path being altered\n  * @name: The name of the xattr to be changed\n  * @value: The value that the xattr will be changed to\n  * @size: The size of value\n@@ -1019,9 +1020,10 @@ int cap_bprm_creds_from_file(struct linux_binprm *bprm, const struct file *file)\n  * This is used to make sure security xattrs don't get updated or set by those\n  * who aren't privileged to do so.\n  */\n-int cap_inode_setxattr(struct dentry *dentry, const char *name,\n+int cap_inode_setxattr(const struct path *path, const char *name,\n \t\t       const void *value, size_t size, int flags)\n {\n+\tstruct dentry *dentry = path-\u003edentry;\n \tstruct user_namespace *user_ns = dentry-\u003ed_sb-\u003es_user_ns;\n \n \t/* Ignore non-security xattrs */\n@@ -1044,25 +1046,18 @@ int cap_inode_setxattr(struct dentry *dentry, const char *name,\n /**\n  * cap_inode_removexattr - Determine whether an xattr may be removed\n  *\n- * @idmap:\tidmap of the mount the inode was found from\n- * @dentry:\tThe inode/dentry being altered\n+ * @path:\tThe inode/path being altered\n  * @name:\tThe name of the xattr to be changed\n  *\n  * Determine whether an xattr may be removed from an inode, returning 0 if\n  * permission is granted, -ve if denied.\n  *\n- * If the inode has been found through an idmapped mount the idmap of\n- * the vfsmount must be passed through @idmap. This function will then\n- * take care to map the inode according to @idmap before checking\n- * permissions. On non-idmapped mounts or if permission checking is to be\n- * performed on the raw inode simply pass @nop_mnt_idmap.\n- *\n  * This is used to make sure security xattrs don't get removed by those who\n  * aren't privileged to remove them.\n  */\n-int cap_inode_removexattr(const struct mnt_idmap *idmap,\n-\t\t\t  struct dentry *dentry, const char *name)\n+int cap_inode_removexattr(const struct path *path, const char *name)\n {\n+\tstruct dentry *dentry = path-\u003edentry;\n \tstruct user_namespace *user_ns = dentry-\u003ed_sb-\u003es_user_ns;\n \n \t/* Ignore non-security xattrs */\n@@ -1075,7 +1070,8 @@ int cap_inode_removexattr(const struct mnt_idmap *idmap,\n \t\tstruct inode *inode = d_backing_inode(dentry);\n \t\tif (!inode)\n \t\t\treturn -EINVAL;\n-\t\tif (!capable_wrt_inode_uidgid(idmap, inode, CAP_SETFCAP))\n+\t\tif (!capable_wrt_inode_uidgid(mnt_idmap(path-\u003emnt), inode,\n+\t\t\t\t\t      CAP_SETFCAP))\n \t\t\treturn -EPERM;\n \t\treturn 0;\n \t}\ndiff --git a/security/integrity/evm/evm_crypto.c b/security/integrity/evm/evm_crypto.c\nindex 1c41af2f91a60..3d759efd3c6c3 100644\n--- a/security/integrity/evm/evm_crypto.c\n+++ b/security/integrity/evm/evm_crypto.c\n@@ -237,7 +237,7 @@ static int evm_calc_hmac_or_hash(struct dentry *dentry,\n \tsize_t xattr_size = 0;\n \tchar *xattr_value = NULL;\n \tint error;\n-\tint size, user_space_size;\n+\tint size;\n \tbool ima_present = false;\n \tu64 i_version = 0;\n \n@@ -287,12 +287,6 @@ static int evm_calc_hmac_or_hash(struct dentry *dentry,\n \t\tif (size \u003c 0)\n \t\t\tcontinue;\n \n-\t\tuser_space_size = vfs_getxattr(\u0026nop_mnt_idmap, dentry,\n-\t\t\t\t\t       xattr-\u003ename, NULL, 0);\n-\t\tif (user_space_size != size)\n-\t\t\tpr_debug(\"file %s: xattr %s size mismatch (kernel: %d, user: %d)\\n\",\n-\t\t\t\t dentry-\u003ed_name.name, xattr-\u003ename, size,\n-\t\t\t\t user_space_size);\n \t\terror = 0;\n \t\txattr_size = size;\n \t\tcrypto_shash_update(desc, (const u8 *)xattr_value, xattr_size);\ndiff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c\nindex ac8328812e6ef..5c2ce1d00fb88 100644\n--- a/security/integrity/evm/evm_main.c\n+++ b/security/integrity/evm/evm_main.c\n@@ -7,8 +7,8 @@\n  * Kylene Hall \u003ckjhall@us.ibm.com\u003e\n  *\n  * File: evm_main.c\n- *\timplements evm_inode_setxattr, evm_inode_post_setxattr,\n- *\tevm_inode_removexattr, evm_verifyxattr, and evm_inode_set_acl.\n+ *\timplements evm_path_setxattr, evm_inode_post_setxattr,\n+ *\tevm_path_removexattr, evm_verifyxattr, and evm_path_set_acl.\n  */\n \n #define pr_fmt(fmt) \"EVM: \"fmt\n@@ -593,9 +593,8 @@ static int evm_protect_xattr(const struct mnt_idmap *idmap,\n }\n \n /**\n- * evm_inode_setxattr - protect the EVM extended attribute\n- * @idmap: idmap of the mount\n- * @dentry: pointer to the affected dentry\n+ * evm_path_setxattr - protect the EVM extended attribute\n+ * @path: pointer to the affected object\n  * @xattr_name: pointer to the affected extended attribute name\n  * @xattr_value: pointer to the new extended attribute value\n  * @xattr_value_len: pointer to the new extended attribute value length\n@@ -607,11 +606,13 @@ static int evm_protect_xattr(const struct mnt_idmap *idmap,\n  * userspace from writing HMAC value.  Writing 'security.evm' requires\n  * requires CAP_SYS_ADMIN privileges.\n  */\n-static int evm_inode_setxattr(const struct mnt_idmap *idmap, struct dentry *dentry,\n+static int evm_path_setxattr(const struct path *path,\n \t\t\t      const char *xattr_name, const void *xattr_value,\n \t\t\t      size_t xattr_value_len, int flags)\n {\n \tconst struct evm_ima_xattr_data *xattr_data = xattr_value;\n+\tstruct dentry *dentry = path-\u003edentry;\n+\tconst struct mnt_idmap *idmap = mnt_idmap(path-\u003emnt);\n \n \t/* Policy permits modification of the protected xattrs even though\n \t * there's no HMAC key loaded\n@@ -631,17 +632,19 @@ static int evm_inode_setxattr(const struct mnt_idmap *idmap, struct dentry *dent\n }\n \n /**\n- * evm_inode_removexattr - protect the EVM extended attribute\n- * @idmap: idmap of the mount\n- * @dentry: pointer to the affected dentry\n+ * evm_path_removexattr - protect the EVM extended attribute\n+ * @path: pointer to the affected object\n  * @xattr_name: pointer to the affected extended attribute name\n  *\n  * Removing 'security.evm' requires CAP_SYS_ADMIN privileges and that\n  * the current value is valid.\n  */\n-static int evm_inode_removexattr(const struct mnt_idmap *idmap, struct dentry *dentry,\n+static int evm_path_removexattr(const struct path *path,\n \t\t\t\t const char *xattr_name)\n {\n+\tstruct dentry *dentry = path-\u003edentry;\n+\tconst struct mnt_idmap *idmap = mnt_idmap(path-\u003emnt);\n+\n \t/* Policy permits modification of the protected xattrs even though\n \t * there's no HMAC key loaded\n \t */\n@@ -681,9 +684,8 @@ static inline int evm_inode_set_acl_change(const struct mnt_idmap *idmap,\n #endif\n \n /**\n- * evm_inode_set_acl - protect the EVM extended attribute from posix acls\n- * @idmap: idmap of the idmapped mount\n- * @dentry: pointer to the affected dentry\n+ * evm_path_set_acl - protect the EVM extended attribute from posix acls\n+ * @path: pointer to the affected object\n  * @acl_name: name of the posix acl\n  * @kacl: pointer to the posix acls\n  *\n@@ -693,10 +695,12 @@ static inline int evm_inode_set_acl_change(const struct mnt_idmap *idmap,\n  *\n  * Return: zero on success, -EPERM on failure.\n  */\n-static int evm_inode_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,\n+static int evm_path_set_acl(const struct path *path,\n \t\t\t     const char *acl_name, struct posix_acl *kacl)\n {\n \tenum integrity_status evm_status;\n+\tstruct dentry *dentry = path-\u003edentry;\n+\tconst struct mnt_idmap *idmap = mnt_idmap(path-\u003emnt);\n \n \t/* Policy permits modification of the protected xattrs even though\n \t * there's no HMAC key loaded\n@@ -734,9 +738,8 @@ static int evm_inode_set_acl(const struct mnt_idmap *idmap, struct dentry *dentr\n }\n \n /**\n- * evm_inode_remove_acl - Protect the EVM extended attribute from posix acls\n- * @idmap: idmap of the mount\n- * @dentry: pointer to the affected dentry\n+ * evm_path_remove_acl - Protect the EVM extended attribute from posix acls\n+ * @path: pointer to the affected object\n  * @acl_name: name of the posix acl\n  *\n  * Prevent removing posix acls causing the EVM HMAC to be re-calculated\n@@ -745,10 +748,10 @@ static int evm_inode_set_acl(const struct mnt_idmap *idmap, struct dentry *dentr\n  *\n  * Return: zero on success, -EPERM on failure.\n  */\n-static int evm_inode_remove_acl(const struct mnt_idmap *idmap, struct dentry *dentry,\n+static int evm_path_remove_acl(const struct path *path,\n \t\t\t\tconst char *acl_name)\n {\n-\treturn evm_inode_set_acl(idmap, dentry, acl_name, NULL);\n+\treturn evm_path_set_acl(path, acl_name, NULL);\n }\n \n static void evm_reset_status(struct inode *inode)\n@@ -948,19 +951,20 @@ static int evm_attr_change(const struct mnt_idmap *idmap,\n }\n \n /**\n- * evm_inode_setattr - prevent updating an invalid EVM extended attribute\n- * @idmap: idmap of the mount\n- * @dentry: pointer to the affected dentry\n+ * evm_path_setattr - prevent updating an invalid EVM extended attribute\n+ * @path: pointer to the affected object\n  * @attr: iattr structure containing the new file attributes\n  *\n  * Permit update of file attributes when files have a valid EVM signature,\n  * except in the case of them having an immutable portable signature.\n  */\n-static int evm_inode_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,\n+static int evm_path_setattr(const struct path *path,\n \t\t\t     struct iattr *attr)\n {\n \tunsigned int ia_valid = attr-\u003eia_valid;\n \tenum integrity_status evm_status;\n+\tstruct dentry *dentry = path-\u003edentry;\n+\tconst struct mnt_idmap *idmap = mnt_idmap(path-\u003emnt);\n \n \t/* Policy permits modification of the protected attrs even though\n \t * there's no HMAC key loaded\n@@ -1195,16 +1199,16 @@ static int __init init_evm(void)\n }\n \n static struct security_hook_list evm_hooks[] __ro_after_init = {\n-\tLSM_HOOK_INIT(inode_setattr, evm_inode_setattr),\n+\tLSM_HOOK_INIT(path_setattr, evm_path_setattr),\n \tLSM_HOOK_INIT(inode_post_setattr, evm_inode_post_setattr),\n \tLSM_HOOK_INIT(inode_copy_up_xattr, evm_inode_copy_up_xattr),\n-\tLSM_HOOK_INIT(inode_setxattr, evm_inode_setxattr),\n+\tLSM_HOOK_INIT(path_setxattr, evm_path_setxattr),\n \tLSM_HOOK_INIT(inode_post_setxattr, evm_inode_post_setxattr),\n-\tLSM_HOOK_INIT(inode_set_acl, evm_inode_set_acl),\n+\tLSM_HOOK_INIT(path_set_acl, evm_path_set_acl),\n \tLSM_HOOK_INIT(inode_post_set_acl, evm_inode_post_set_acl),\n-\tLSM_HOOK_INIT(inode_remove_acl, evm_inode_remove_acl),\n+\tLSM_HOOK_INIT(path_remove_acl, evm_path_remove_acl),\n \tLSM_HOOK_INIT(inode_post_remove_acl, evm_inode_post_remove_acl),\n-\tLSM_HOOK_INIT(inode_removexattr, evm_inode_removexattr),\n+\tLSM_HOOK_INIT(path_removexattr, evm_path_removexattr),\n \tLSM_HOOK_INIT(inode_post_removexattr, evm_inode_post_removexattr),\n \tLSM_HOOK_INIT(inode_init_security, evm_inode_init_security),\n \tLSM_HOOK_INIT(inode_alloc_security, evm_inode_alloc_security),\ndiff --git a/security/integrity/ima/ima_appraise.c b/security/integrity/ima/ima_appraise.c\nindex 134174d2e3f0e..f5068f881a245 100644\n--- a/security/integrity/ima/ima_appraise.c\n+++ b/security/integrity/ima/ima_appraise.c\n@@ -759,11 +759,12 @@ static int validate_hash_algo(struct dentry *dentry,\n \treturn -EACCES;\n }\n \n-static int ima_inode_setxattr(const struct mnt_idmap *idmap, struct dentry *dentry,\n+static int ima_path_setxattr(const struct path *path,\n \t\t\t      const char *xattr_name, const void *xattr_value,\n \t\t\t      size_t xattr_value_len, int flags)\n {\n \tconst struct evm_ima_xattr_data *xvalue = xattr_value;\n+\tstruct dentry *dentry = path-\u003edentry;\n \tint digsig = 0;\n \tint result;\n \tint err;\n@@ -792,43 +793,43 @@ static int ima_inode_setxattr(const struct mnt_idmap *idmap, struct dentry *dent\n \treturn result;\n }\n \n-static int ima_inode_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,\n+static int ima_path_set_acl(const struct path *path,\n \t\t\t     const char *acl_name, struct posix_acl *kacl)\n {\n \tif (evm_revalidate_status(acl_name))\n-\t\tima_reset_appraise_flags(d_backing_inode(dentry), -1);\n+\t\tima_reset_appraise_flags(d_backing_inode(path-\u003edentry), -1);\n \n \treturn 0;\n }\n \n-static int ima_inode_removexattr(const struct mnt_idmap *idmap, struct dentry *dentry,\n+static int ima_path_removexattr(const struct path *path,\n \t\t\t\t const char *xattr_name)\n {\n \tint result, digsig = -1;\n \n-\tresult = ima_protect_xattr(dentry, xattr_name, NULL, 0);\n+\tresult = ima_protect_xattr(path-\u003edentry, xattr_name, NULL, 0);\n \tif (result == 1 || evm_revalidate_status(xattr_name)) {\n \t\tif (!strcmp(xattr_name, XATTR_NAME_IMA))\n \t\t\tdigsig = 0;\n-\t\tima_reset_appraise_flags(d_backing_inode(dentry), digsig);\n+\t\tima_reset_appraise_flags(d_backing_inode(path-\u003edentry), digsig);\n \t\tif (result == 1)\n \t\t\tresult = 0;\n \t}\n \treturn result;\n }\n \n-static int ima_inode_remove_acl(const struct mnt_idmap *idmap, struct dentry *dentry,\n+static int ima_path_remove_acl(const struct path *path,\n \t\t\t\tconst char *acl_name)\n {\n-\treturn ima_inode_set_acl(idmap, dentry, acl_name, NULL);\n+\treturn ima_path_set_acl(path, acl_name, NULL);\n }\n \n static struct security_hook_list ima_appraise_hooks[] __ro_after_init = {\n \tLSM_HOOK_INIT(inode_post_setattr, ima_inode_post_setattr),\n-\tLSM_HOOK_INIT(inode_setxattr, ima_inode_setxattr),\n-\tLSM_HOOK_INIT(inode_set_acl, ima_inode_set_acl),\n-\tLSM_HOOK_INIT(inode_removexattr, ima_inode_removexattr),\n-\tLSM_HOOK_INIT(inode_remove_acl, ima_inode_remove_acl),\n+\tLSM_HOOK_INIT(path_setxattr, ima_path_setxattr),\n+\tLSM_HOOK_INIT(path_set_acl, ima_path_set_acl),\n+\tLSM_HOOK_INIT(path_removexattr, ima_path_removexattr),\n+\tLSM_HOOK_INIT(path_remove_acl, ima_path_remove_acl),\n };\n \n void __init init_ima_appraise_lsm(const struct lsm_id *lsmid)\ndiff --git a/security/landlock/fs.c b/security/landlock/fs.c\nindex a8fa8f77e775d..1bca7558ea9f9 100644\n--- a/security/landlock/fs.c\n+++ b/security/landlock/fs.c\n@@ -318,6 +318,8 @@ static struct landlock_object *get_inode_object(struct inode *const inode)\n \tLANDLOCK_ACCESS_FS_EXECUTE | \\\n \tLANDLOCK_ACCESS_FS_WRITE_FILE | \\\n \tLANDLOCK_ACCESS_FS_READ_FILE | \\\n+\tLANDLOCK_ACCESS_FS_READ_METADATA | \\\n+\tLANDLOCK_ACCESS_FS_WRITE_METADATA | \\\n \tLANDLOCK_ACCESS_FS_TRUNCATE | \\\n \tLANDLOCK_ACCESS_FS_IOCTL_DEV | \\\n \tLANDLOCK_ACCESS_FS_RESOLVE_UNIX)\n@@ -1676,6 +1678,119 @@ static int hook_path_truncate(const struct path *const path)\n \treturn current_check_access_path(path, LANDLOCK_ACCESS_FS_TRUNCATE);\n }\n \n+static int hook_path_getattr(const struct path *const path)\n+{\n+\treturn current_check_access_path(path,\n+\t\t\t\t\tLANDLOCK_ACCESS_FS_READ_METADATA);\n+}\n+\n+static int hook_path_file_getattr(const struct path *const path,\n+\t\t\t\t   struct file_kattr *const fa)\n+{\n+\treturn current_check_access_path(path,\n+\t\t\t\t\tLANDLOCK_ACCESS_FS_READ_METADATA);\n+}\n+\n+static int hook_path_setattr(const struct path *const path,\n+\t\t\t      struct iattr *const attr)\n+{\n+\tunsigned int ia_valid = attr-\u003eia_valid;\n+\n+\t/*\n+\t * Only explicit metadata changes are checked: implicit\n+\t * timestamp updates never go through notify_change(), and size\n+\t * changes (ATTR_SIZE) are governed by the truncate hooks\n+\t * instead.  See the \"File metadata\" section in the user space\n+\t * documentation for the full semantics.\n+\t *\n+\t * Clearing the setuid and setgid bits on write(2) or\n+\t * truncate(2) is also an implicit change: callers request it\n+\t * with ATTR_KILL_S[UG]ID, and do_notify_change() then adds a\n+\t * synthesized ATTR_MODE (with these bits removed) before\n+\t * calling this hook.  As do_notify_change() makes it a bug for\n+\t * callers to pass ATTR_MODE together with a kill flag, an\n+\t * ATTR_MODE seen along with ATTR_KILL_S[UG]ID is always\n+\t * kernel-synthesized and must not be checked.  An explicit\n+\t * chmod(2) never sets a kill flag, and an explicit chown(2) on\n+\t * a privileged file is still checked thanks to ATTR_UID and\n+\t * ATTR_GID.\n+\t */\n+\tif (ia_valid \u0026 (ATTR_KILL_SUID | ATTR_KILL_SGID))\n+\t\tia_valid \u0026= ~ATTR_MODE;\n+\n+\tif (!(ia_valid \u0026 (ATTR_MODE | ATTR_UID | ATTR_GID |\n+\t\t\t  ATTR_TIMES_SET | ATTR_TOUCH)))\n+\t\treturn 0;\n+\n+\treturn current_check_access_path(path,\n+\t\t\t\t\tLANDLOCK_ACCESS_FS_WRITE_METADATA);\n+}\n+\n+static int hook_path_file_setattr(const struct path *const path,\n+\t\t\t\t   struct file_kattr *const fa)\n+{\n+\t/*\n+\t * The chattr(2) style flags (e.g. FS_IMMUTABLE_FL) and fsxattr\n+\t * fields are metadata: writing them requires WRITE_METADATA.  The\n+\t * user-facing path is checked here; stacking filesystems skip this\n+\t * hook on their internal forwards because they were already\n+\t * checked on the user-facing path.\n+\t */\n+\treturn current_check_access_path(path,\n+\t\t\t\t\tLANDLOCK_ACCESS_FS_WRITE_METADATA);\n+}\n+\n+static int hook_path_setxattr(const struct path *const path,\n+\t\t\t       const char *const name,\n+\t\t\t       const void *const value, const size_t size,\n+\t\t\t       const int flags)\n+{\n+\treturn current_check_access_path(path,\n+\t\t\t\t\tLANDLOCK_ACCESS_FS_WRITE_METADATA);\n+}\n+\n+static int hook_path_getxattr(const struct path *const path,\n+\t\t\t       const char *const name)\n+{\n+\treturn current_check_access_path(path,\n+\t\t\t\t\tLANDLOCK_ACCESS_FS_READ_METADATA);\n+}\n+\n+static int hook_path_listxattr(const struct path *const path)\n+{\n+\treturn current_check_access_path(path,\n+\t\t\t\t\tLANDLOCK_ACCESS_FS_READ_METADATA);\n+}\n+\n+static int hook_path_removexattr(const struct path *const path,\n+\t\t\t\t  const char *const name)\n+{\n+\treturn current_check_access_path(path,\n+\t\t\t\t\tLANDLOCK_ACCESS_FS_WRITE_METADATA);\n+}\n+\n+static int hook_path_set_acl(const struct path *const path,\n+\t\t\t      const char *const acl_name,\n+\t\t\t      struct posix_acl *const kacl)\n+{\n+\treturn current_check_access_path(path,\n+\t\t\t\t\tLANDLOCK_ACCESS_FS_WRITE_METADATA);\n+}\n+\n+static int hook_path_get_acl(const struct path *const path,\n+\t\t\t      const char *const acl_name)\n+{\n+\treturn current_check_access_path(path,\n+\t\t\t\t\tLANDLOCK_ACCESS_FS_READ_METADATA);\n+}\n+\n+static int hook_path_remove_acl(const struct path *const path,\n+\t\t\t\t const char *const acl_name)\n+{\n+\treturn current_check_access_path(path,\n+\t\t\t\t\tLANDLOCK_ACCESS_FS_WRITE_METADATA);\n+}\n+\n /**\n  * unmask_scoped_access - Remove access right bits in @masks in all layers\n  *                        where @client and @server have the same domain\n@@ -2100,6 +2215,17 @@ static struct security_hook_list landlock_hooks[] __ro_after_init = {\n \tLSM_HOOK_INIT(path_unlink, hook_path_unlink),\n \tLSM_HOOK_INIT(path_rmdir, hook_path_rmdir),\n \tLSM_HOOK_INIT(path_truncate, hook_path_truncate),\n+\tLSM_HOOK_INIT(path_getattr, hook_path_getattr),\n+\tLSM_HOOK_INIT(path_file_getattr, hook_path_file_getattr),\n+\tLSM_HOOK_INIT(path_setattr, hook_path_setattr),\n+\tLSM_HOOK_INIT(path_file_setattr, hook_path_file_setattr),\n+\tLSM_HOOK_INIT(path_setxattr, hook_path_setxattr),\n+\tLSM_HOOK_INIT(path_getxattr, hook_path_getxattr),\n+\tLSM_HOOK_INIT(path_listxattr, hook_path_listxattr),\n+\tLSM_HOOK_INIT(path_removexattr, hook_path_removexattr),\n+\tLSM_HOOK_INIT(path_set_acl, hook_path_set_acl),\n+\tLSM_HOOK_INIT(path_get_acl, hook_path_get_acl),\n+\tLSM_HOOK_INIT(path_remove_acl, hook_path_remove_acl),\n \tLSM_HOOK_INIT(unix_find, hook_unix_find),\n \n \tLSM_HOOK_INIT(file_alloc_security, hook_file_alloc_security),\ndiff --git a/security/landlock/limits.h b/security/landlock/limits.h\nindex ddd300e10689f..ed606ee3102f4 100644\n--- a/security/landlock/limits.h\n+++ b/security/landlock/limits.h\n@@ -21,7 +21,7 @@\n #define LANDLOCK_MAX_NUM_LAYERS\t\t16\n #define LANDLOCK_MAX_NUM_RULES\t\tU32_MAX\n \n-#define LANDLOCK_LAST_ACCESS_FS\t\tLANDLOCK_ACCESS_FS_RESOLVE_UNIX\n+#define LANDLOCK_LAST_ACCESS_FS\t\tLANDLOCK_ACCESS_FS_WRITE_METADATA\n #define LANDLOCK_MASK_ACCESS_FS\t\t((LANDLOCK_LAST_ACCESS_FS \u003c\u003c 1) - 1)\n #define LANDLOCK_NUM_ACCESS_FS\t\t__const_hweight64(LANDLOCK_MASK_ACCESS_FS)\n \ndiff --git a/security/landlock/syscalls.c b/security/landlock/syscalls.c\nindex fb5af318b69bb..11d3a2abcec13 100644\n--- a/security/landlock/syscalls.c\n+++ b/security/landlock/syscalls.c\n@@ -191,7 +191,7 @@ static const struct file_operations ruleset_fops = {\n  * If the change involves a fix that requires userspace awareness, also update\n  * the errata documentation in Documentation/userspace-api/landlock.rst .\n  */\n-const int landlock_abi_version = 12;\n+const int landlock_abi_version = 13;\n \n /**\n  * sys_landlock_create_ruleset - Create a new ruleset\ndiff --git a/security/security.c b/security/security.c\nindex da8d48cd0a2a4..7c17300989b67 100644\n--- a/security/security.c\n+++ b/security/security.c\n@@ -1890,9 +1890,8 @@ int security_inode_permission(const struct mnt_idmap *idmap, struct inode *inode\n }\n \n /**\n- * security_inode_setattr() - Check if setting file attributes is allowed\n- * @idmap: idmap of the mount\n- * @dentry: file\n+ * security_path_setattr() - Check if setting file attributes is allowed\n+ * @path: file\n  * @attr: new attributes\n  *\n  * Check permission before setting file attributes.  Note that the kernel call\n@@ -1902,14 +1901,13 @@ int security_inode_permission(const struct mnt_idmap *idmap, struct inode *inode\n  *\n  * Return: Returns 0 if permission is granted.\n  */\n-int security_inode_setattr(const struct mnt_idmap *idmap,\n-\t\t\t   struct dentry *dentry, struct iattr *attr)\n+int security_path_setattr(const struct path *path, struct iattr *attr)\n {\n-\tif (unlikely(IS_PRIVATE(d_backing_inode(dentry))))\n+\tif (unlikely(IS_PRIVATE(d_backing_inode(path-\u003edentry))))\n \t\treturn 0;\n-\treturn call_int_hook(inode_setattr, idmap, dentry, attr);\n+\treturn call_int_hook(path_setattr, path, attr);\n }\n-EXPORT_SYMBOL_GPL(security_inode_setattr);\n+EXPORT_SYMBOL_GPL(security_path_setattr);\n \n /**\n  * security_inode_post_setattr() - Update the inode after a setattr operation\n@@ -1928,31 +1926,30 @@ void security_inode_post_setattr(const struct mnt_idmap *idmap, struct dentry *d\n }\n \n /**\n- * security_inode_getattr() - Check if getting file attributes is allowed\n+ * security_path_getattr() - Check if getting file attributes is allowed\n  * @path: file\n  *\n  * Check permission before obtaining file attributes.\n  *\n  * Return: Returns 0 if permission is granted.\n  */\n-int security_inode_getattr(const struct path *path)\n+int security_path_getattr(const struct path *path)\n {\n \tif (unlikely(IS_PRIVATE(d_backing_inode(path-\u003edentry))))\n \t\treturn 0;\n-\treturn call_int_hook(inode_getattr, path);\n+\treturn call_int_hook(path_getattr, path);\n }\n \n /**\n- * security_inode_setxattr() - Check if setting file xattrs is allowed\n- * @idmap: idmap of the mount\n- * @dentry: file\n+ * security_path_setxattr() - Check if setting file xattrs is allowed\n+ * @path: file\n  * @name: xattr name\n  * @value: xattr value\n  * @size: size of xattr value\n  * @flags: flags\n  *\n  * This hook performs the desired permission checks before setting the extended\n- * attributes (xattrs) on @dentry.  It is important to note that we have some\n+ * attributes (xattrs) on @path.  It is important to note that we have some\n  * additional logic before the main LSM implementation calls to detect if we\n  * need to perform an additional capability check at the LSM layer.\n  *\n@@ -1968,30 +1965,29 @@ int security_inode_getattr(const struct path *path)\n  *\n  * Return: Returns 0 if permission is granted.\n  */\n-int security_inode_setxattr(const struct mnt_idmap *idmap,\n-\t\t\t    struct dentry *dentry, const char *name,\n-\t\t\t    const void *value, size_t size, int flags)\n+int security_path_setxattr(const struct path *path,\n+\t\t\t    const char *name, const void *value,\n+\t\t\t    size_t size, int flags)\n {\n \tint rc;\n \n-\tif (unlikely(IS_PRIVATE(d_backing_inode(dentry))))\n+\tif (unlikely(IS_PRIVATE(d_backing_inode(path-\u003edentry))))\n \t\treturn 0;\n \n \t/* enforce the capability checks at the lsm layer, if needed */\n \tif (!call_int_hook(inode_xattr_skipcap, name)) {\n-\t\trc = cap_inode_setxattr(dentry, name, value, size, flags);\n+\t\trc = cap_inode_setxattr(path, name, value, size, flags);\n \t\tif (rc)\n \t\t\treturn rc;\n \t}\n \n-\treturn call_int_hook(inode_setxattr, idmap, dentry, name, value, size,\n+\treturn call_int_hook(path_setxattr, path, name, value, size,\n \t\t\t     flags);\n }\n \n /**\n- * security_inode_set_acl() - Check if setting posix acls is allowed\n- * @idmap: idmap of the mount\n- * @dentry: file\n+ * security_path_set_acl() - Check if setting posix acls is allowed\n+ * @path: file\n  * @acl_name: acl name\n  * @kacl: acl struct\n  *\n@@ -2000,13 +1996,12 @@ int security_inode_setxattr(const struct mnt_idmap *idmap,\n  *\n  * Return: Returns 0 if permission is granted.\n  */\n-int security_inode_set_acl(const struct mnt_idmap *idmap,\n-\t\t\t   struct dentry *dentry, const char *acl_name,\n-\t\t\t   struct posix_acl *kacl)\n+int security_path_set_acl(const struct path *path,\n+\t\t\t   const char *acl_name, struct posix_acl *kacl)\n {\n-\tif (unlikely(IS_PRIVATE(d_backing_inode(dentry))))\n+\tif (unlikely(IS_PRIVATE(d_backing_inode(path-\u003edentry))))\n \t\treturn 0;\n-\treturn call_int_hook(inode_set_acl, idmap, dentry, acl_name, kacl);\n+\treturn call_int_hook(path_set_acl, path, acl_name, kacl);\n }\n \n /**\n@@ -2027,9 +2022,8 @@ void security_inode_post_set_acl(struct dentry *dentry, const char *acl_name,\n }\n \n /**\n- * security_inode_get_acl() - Check if reading posix acls is allowed\n- * @idmap: idmap of the mount\n- * @dentry: file\n+ * security_path_get_acl() - Check if reading posix acls is allowed\n+ * @path: file\n  * @acl_name: acl name\n  *\n  * Check permission before getting osix acls, the posix acls are identified by\n@@ -2037,18 +2031,16 @@ void security_inode_post_set_acl(struct dentry *dentry, const char *acl_name,\n  *\n  * Return: Returns 0 if permission is granted.\n  */\n-int security_inode_get_acl(const struct mnt_idmap *idmap,\n-\t\t\t   struct dentry *dentry, const char *acl_name)\n+int security_path_get_acl(const struct path *path, const char *acl_name)\n {\n-\tif (unlikely(IS_PRIVATE(d_backing_inode(dentry))))\n+\tif (unlikely(IS_PRIVATE(d_backing_inode(path-\u003edentry))))\n \t\treturn 0;\n-\treturn call_int_hook(inode_get_acl, idmap, dentry, acl_name);\n+\treturn call_int_hook(path_get_acl, path, acl_name);\n }\n \n /**\n- * security_inode_remove_acl() - Check if removing a posix acl is allowed\n- * @idmap: idmap of the mount\n- * @dentry: file\n+ * security_path_remove_acl() - Check if removing a posix acl is allowed\n+ * @path: file\n  * @acl_name: acl name\n  *\n  * Check permission before removing posix acls, the posix acls are identified\n@@ -2056,12 +2048,11 @@ int security_inode_get_acl(const struct mnt_idmap *idmap,\n  *\n  * Return: Returns 0 if permission is granted.\n  */\n-int security_inode_remove_acl(const struct mnt_idmap *idmap,\n-\t\t\t      struct dentry *dentry, const char *acl_name)\n+int security_path_remove_acl(const struct path *path, const char *acl_name)\n {\n-\tif (unlikely(IS_PRIVATE(d_backing_inode(dentry))))\n+\tif (unlikely(IS_PRIVATE(d_backing_inode(path-\u003edentry))))\n \t\treturn 0;\n-\treturn call_int_hook(inode_remove_acl, idmap, dentry, acl_name);\n+\treturn call_int_hook(path_remove_acl, path, acl_name);\n }\n \n /**\n@@ -2100,46 +2091,45 @@ void security_inode_post_setxattr(struct dentry *dentry, const char *name,\n }\n \n /**\n- * security_inode_getxattr() - Check if xattr access is allowed\n- * @dentry: file\n+ * security_path_getxattr() - Check if xattr access is allowed\n+ * @path: file\n  * @name: xattr name\n  *\n  * Check permission before obtaining the extended attributes identified by\n- * @name for @dentry.\n+ * @name for @path.\n  *\n  * Return: Returns 0 if permission is granted.\n  */\n-int security_inode_getxattr(struct dentry *dentry, const char *name)\n+int security_path_getxattr(const struct path *path, const char *name)\n {\n-\tif (unlikely(IS_PRIVATE(d_backing_inode(dentry))))\n+\tif (unlikely(IS_PRIVATE(d_backing_inode(path-\u003edentry))))\n \t\treturn 0;\n-\treturn call_int_hook(inode_getxattr, dentry, name);\n+\treturn call_int_hook(path_getxattr, path, name);\n }\n \n /**\n- * security_inode_listxattr() - Check if listing xattrs is allowed\n- * @dentry: file\n+ * security_path_listxattr() - Check if listing xattrs is allowed\n+ * @path: file\n  *\n  * Check permission before obtaining the list of extended attribute names for\n- * @dentry.\n+ * @path.\n  *\n  * Return: Returns 0 if permission is granted.\n  */\n-int security_inode_listxattr(struct dentry *dentry)\n+int security_path_listxattr(const struct path *path)\n {\n-\tif (unlikely(IS_PRIVATE(d_backing_inode(dentry))))\n+\tif (unlikely(IS_PRIVATE(d_backing_inode(path-\u003edentry))))\n \t\treturn 0;\n-\treturn call_int_hook(inode_listxattr, dentry);\n+\treturn call_int_hook(path_listxattr, path);\n }\n \n /**\n- * security_inode_removexattr() - Check if removing an xattr is allowed\n- * @idmap: idmap of the mount\n- * @dentry: file\n+ * security_path_removexattr() - Check if removing an xattr is allowed\n+ * @path: file\n  * @name: xattr name\n  *\n  * This hook performs the desired permission checks before setting the extended\n- * attributes (xattrs) on @dentry.  It is important to note that we have some\n+ * attributes (xattrs) on @path.  It is important to note that we have some\n  * additional logic before the main LSM implementation calls to detect if we\n  * need to perform an additional capability check at the LSM layer.\n  *\n@@ -2155,22 +2145,21 @@ int security_inode_listxattr(struct dentry *dentry)\n  *\n  * Return: Returns 0 if permission is granted.\n  */\n-int security_inode_removexattr(const struct mnt_idmap *idmap,\n-\t\t\t       struct dentry *dentry, const char *name)\n+int security_path_removexattr(const struct path *path, const char *name)\n {\n \tint rc;\n \n-\tif (unlikely(IS_PRIVATE(d_backing_inode(dentry))))\n+\tif (unlikely(IS_PRIVATE(d_backing_inode(path-\u003edentry))))\n \t\treturn 0;\n \n \t/* enforce the capability checks at the lsm layer, if needed */\n \tif (!call_int_hook(inode_xattr_skipcap, name)) {\n-\t\trc = cap_inode_removexattr(idmap, dentry, name);\n+\t\trc = cap_inode_removexattr(path, name);\n \t\tif (rc)\n \t\t\treturn rc;\n \t}\n \n-\treturn call_int_hook(inode_removexattr, idmap, dentry, name);\n+\treturn call_int_hook(path_removexattr, path, name);\n }\n \n /**\n@@ -2188,8 +2177,8 @@ void security_inode_post_removexattr(struct dentry *dentry, const char *name)\n }\n \n /**\n- * security_inode_file_setattr() - check if setting fsxattr is allowed\n- * @dentry: file to set filesystem extended attributes on\n+ * security_path_file_setattr() - check if setting fsxattr is allowed\n+ * @path: file to set filesystem extended attributes on\n  * @fa: extended attributes to set on the inode\n  *\n  * Called when file_setattr() syscall or FS_IOC_FSSETXATTR ioctl() is called on\n@@ -2197,14 +2186,14 @@ void security_inode_post_removexattr(struct dentry *dentry, const char *name)\n  *\n  * Return: Returns 0 if permission is granted.\n  */\n-int security_inode_file_setattr(struct dentry *dentry, struct file_kattr *fa)\n+int security_path_file_setattr(const struct path *path, struct file_kattr *fa)\n {\n-\treturn call_int_hook(inode_file_setattr, dentry, fa);\n+\treturn call_int_hook(path_file_setattr, path, fa);\n }\n \n /**\n- * security_inode_file_getattr() - check if retrieving fsxattr is allowed\n- * @dentry: file to retrieve filesystem extended attributes from\n+ * security_path_file_getattr() - check if retrieving fsxattr is allowed\n+ * @path: file to retrieve filesystem extended attributes from\n  * @fa: extended attributes to get\n  *\n  * Called when file_getattr() syscall or FS_IOC_FSGETXATTR ioctl() is called on\n@@ -2212,9 +2201,9 @@ int security_inode_file_setattr(struct dentry *dentry, struct file_kattr *fa)\n  *\n  * Return: Returns 0 if permission is granted.\n  */\n-int security_inode_file_getattr(struct dentry *dentry, struct file_kattr *fa)\n+int security_path_file_getattr(const struct path *path, struct file_kattr *fa)\n {\n-\treturn call_int_hook(inode_file_getattr, dentry, fa);\n+\treturn call_int_hook(path_file_getattr, path, fa);\n }\n \n /**\n@@ -4133,8 +4122,8 @@ int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen)\n EXPORT_SYMBOL(security_inode_notifysecctx);\n \n /**\n- * security_inode_setsecctx() - Change the security label of an inode\n- * @dentry: inode\n+ * security_path_setsecctx() - Change the security label of an inode\n+ * @path: inode\n  * @ctx: secctx\n  * @ctxlen: length of secctx\n  *\n@@ -4148,11 +4137,11 @@ EXPORT_SYMBOL(security_inode_notifysecctx);\n  *\n  * Return: Returns 0 on success, error on failure.\n  */\n-int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen)\n+int security_path_setsecctx(const struct path *path, void *ctx, u32 ctxlen)\n {\n-\treturn call_int_hook(inode_setsecctx, dentry, ctx, ctxlen);\n+\treturn call_int_hook(path_setsecctx, path, ctx, ctxlen);\n }\n-EXPORT_SYMBOL(security_inode_setsecctx);\n+EXPORT_SYMBOL(security_path_setsecctx);\n \n /**\n  * security_inode_getsecctx() - Get the security label of an inode\ndiff --git a/security/selinux/hooks.c b/security/selinux/hooks.c\nindex 51454c411a038..81b7be7181e79 100644\n--- a/security/selinux/hooks.c\n+++ b/security/selinux/hooks.c\n@@ -3346,10 +3346,11 @@ static int selinux_inode_permission(const struct mnt_idmap *idmap,\n \treturn rc;\n }\n \n-static int selinux_inode_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,\n+static int selinux_path_setattr(const struct path *path,\n \t\t\t\t struct iattr *iattr)\n {\n \tconst struct cred *cred = current_cred();\n+\tstruct dentry *dentry = path-\u003edentry;\n \tstruct inode *inode = d_backing_inode(dentry);\n \tunsigned int ia_valid = iattr-\u003eia_valid;\n \tu32 av = FILE__WRITE;\n@@ -3375,7 +3376,7 @@ static int selinux_inode_setattr(const struct mnt_idmap *idmap, struct dentry *d\n \treturn dentry_has_perm(cred, dentry, av);\n }\n \n-static int selinux_inode_getattr(const struct path *path)\n+static int selinux_path_getattr(const struct path *path)\n {\n \tstruct task_security_struct *tsec;\n \n@@ -3416,10 +3417,12 @@ static int selinux_inode_xattr_skipcap(const char *name)\n \treturn !strcmp(name, XATTR_NAME_SELINUX);\n }\n \n-static int selinux_inode_setxattr(const struct mnt_idmap *idmap,\n-\t\t\t\t  struct dentry *dentry, const char *name,\n-\t\t\t\t  const void *value, size_t size, int flags)\n+static int selinux_path_setxattr(const struct path *path,\n+\t\t\t\t  const char *name, const void *value,\n+\t\t\t\t  size_t size, int flags)\n {\n+\tstruct dentry *dentry = path-\u003edentry;\n+\tconst struct mnt_idmap *idmap = mnt_idmap(path-\u003emnt);\n \tstruct inode *inode = d_backing_inode(dentry);\n \tstruct inode_security_struct *isec;\n \tstruct superblock_security_struct *sbsec;\n@@ -3502,23 +3505,22 @@ static int selinux_inode_setxattr(const struct mnt_idmap *idmap,\n \t\t\t    \u0026ad);\n }\n \n-static int selinux_inode_set_acl(const struct mnt_idmap *idmap,\n-\t\t\t\t struct dentry *dentry, const char *acl_name,\n-\t\t\t\t struct posix_acl *kacl)\n+static int selinux_path_set_acl(const struct path *path,\n+\t\t\t\t const char *acl_name, struct posix_acl *kacl)\n {\n-\treturn dentry_has_perm(current_cred(), dentry, FILE__SETATTR);\n+\treturn dentry_has_perm(current_cred(), path-\u003edentry, FILE__SETATTR);\n }\n \n-static int selinux_inode_get_acl(const struct mnt_idmap *idmap,\n-\t\t\t\t struct dentry *dentry, const char *acl_name)\n+static int selinux_path_get_acl(const struct path *path,\n+\t\t\t\t const char *acl_name)\n {\n-\treturn dentry_has_perm(current_cred(), dentry, FILE__GETATTR);\n+\treturn dentry_has_perm(current_cred(), path-\u003edentry, FILE__GETATTR);\n }\n \n-static int selinux_inode_remove_acl(const struct mnt_idmap *idmap,\n-\t\t\t\t    struct dentry *dentry, const char *acl_name)\n+static int selinux_path_remove_acl(const struct path *path,\n+\t\t\t\t    const char *acl_name)\n {\n-\treturn dentry_has_perm(current_cred(), dentry, FILE__SETATTR);\n+\treturn dentry_has_perm(current_cred(), path-\u003edentry, FILE__SETATTR);\n }\n \n static void selinux_inode_post_setxattr(struct dentry *dentry, const char *name,\n@@ -3561,26 +3563,27 @@ static void selinux_inode_post_setxattr(struct dentry *dentry, const char *name,\n \tspin_unlock(\u0026isec-\u003elock);\n }\n \n-static int selinux_inode_getxattr(struct dentry *dentry, const char *name)\n+static int selinux_path_getxattr(const struct path *path, const char *name)\n {\n \tconst struct cred *cred = current_cred();\n \n-\treturn dentry_has_perm(cred, dentry, FILE__GETATTR);\n+\treturn dentry_has_perm(cred, path-\u003edentry, FILE__GETATTR);\n }\n \n-static int selinux_inode_listxattr(struct dentry *dentry)\n+static int selinux_path_listxattr(const struct path *path)\n {\n \tconst struct cred *cred = current_cred();\n \n-\treturn dentry_has_perm(cred, dentry, FILE__GETATTR);\n+\treturn dentry_has_perm(cred, path-\u003edentry, FILE__GETATTR);\n }\n \n-static int selinux_inode_removexattr(const struct mnt_idmap *idmap,\n-\t\t\t\t     struct dentry *dentry, const char *name)\n+static int selinux_path_removexattr(const struct path *path,\n+\t\t\t\t     const char *name)\n {\n \t/* if not a selinux xattr, only check the ordinary setattr perm */\n \tif (strcmp(name, XATTR_NAME_SELINUX))\n-\t\treturn dentry_has_perm(current_cred(), dentry, FILE__SETATTR);\n+\t\treturn dentry_has_perm(current_cred(), path-\u003edentry,\n+\t\t\t\t       FILE__SETATTR);\n \n \tif (!selinux_initialized())\n \t\treturn 0;\n@@ -3590,16 +3593,16 @@ static int selinux_inode_removexattr(const struct mnt_idmap *idmap,\n \treturn -EACCES;\n }\n \n-static int selinux_inode_file_setattr(struct dentry *dentry,\n+static int selinux_path_file_setattr(const struct path *path,\n \t\t\t\t      struct file_kattr *fa)\n {\n-\treturn dentry_has_perm(current_cred(), dentry, FILE__SETATTR);\n+\treturn dentry_has_perm(current_cred(), path-\u003edentry, FILE__SETATTR);\n }\n \n-static int selinux_inode_file_getattr(struct dentry *dentry,\n+static int selinux_path_file_getattr(const struct path *path,\n \t\t\t\t      struct file_kattr *fa)\n {\n-\treturn dentry_has_perm(current_cred(), dentry, FILE__GETATTR);\n+\treturn dentry_has_perm(current_cred(), path-\u003edentry, FILE__GETATTR);\n }\n \n static int selinux_path_notify(const struct path *path, u64 mask,\n@@ -3653,7 +3656,7 @@ static int selinux_path_notify(const struct path *path, u64 mask,\n /*\n  * Copy the inode security context value to the user.\n  *\n- * Permission check is handled by selinux_inode_getxattr hook.\n+ * Permission check is handled by selinux_path_getxattr hook.\n  */\n static int selinux_inode_getsecurity(const struct mnt_idmap *idmap,\n \t\t\t\t     struct inode *inode, const char *name,\n@@ -7173,9 +7176,9 @@ static int selinux_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen\n /*\n  *\tcalled with inode-\u003ei_mutex locked\n  */\n-static int selinux_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen)\n+static int selinux_path_setsecctx(const struct path *path, void *ctx, u32 ctxlen)\n {\n-\treturn __vfs_setxattr_locked(\u0026nop_mnt_idmap, dentry, XATTR_NAME_SELINUX,\n+\treturn __vfs_setxattr_locked(path, XATTR_NAME_SELINUX,\n \t\t\t\t     ctx, ctxlen, 0, NULL);\n }\n \n@@ -7752,19 +7755,19 @@ static struct security_hook_list selinux_hooks[] __ro_after_init = {\n \tLSM_HOOK_INIT(inode_readlink, selinux_inode_readlink),\n \tLSM_HOOK_INIT(inode_follow_link, selinux_inode_follow_link),\n \tLSM_HOOK_INIT(inode_permission, selinux_inode_permission),\n-\tLSM_HOOK_INIT(inode_setattr, selinux_inode_setattr),\n-\tLSM_HOOK_INIT(inode_getattr, selinux_inode_getattr),\n+\tLSM_HOOK_INIT(path_setattr, selinux_path_setattr),\n+\tLSM_HOOK_INIT(path_getattr, selinux_path_getattr),\n \tLSM_HOOK_INIT(inode_xattr_skipcap, selinux_inode_xattr_skipcap),\n-\tLSM_HOOK_INIT(inode_setxattr, selinux_inode_setxattr),\n+\tLSM_HOOK_INIT(path_setxattr, selinux_path_setxattr),\n \tLSM_HOOK_INIT(inode_post_setxattr, selinux_inode_post_setxattr),\n-\tLSM_HOOK_INIT(inode_getxattr, selinux_inode_getxattr),\n-\tLSM_HOOK_INIT(inode_listxattr, selinux_inode_listxattr),\n-\tLSM_HOOK_INIT(inode_removexattr, selinux_inode_removexattr),\n-\tLSM_HOOK_INIT(inode_file_getattr, selinux_inode_file_getattr),\n-\tLSM_HOOK_INIT(inode_file_setattr, selinux_inode_file_setattr),\n-\tLSM_HOOK_INIT(inode_set_acl, selinux_inode_set_acl),\n-\tLSM_HOOK_INIT(inode_get_acl, selinux_inode_get_acl),\n-\tLSM_HOOK_INIT(inode_remove_acl, selinux_inode_remove_acl),\n+\tLSM_HOOK_INIT(path_getxattr, selinux_path_getxattr),\n+\tLSM_HOOK_INIT(path_listxattr, selinux_path_listxattr),\n+\tLSM_HOOK_INIT(path_removexattr, selinux_path_removexattr),\n+\tLSM_HOOK_INIT(path_file_getattr, selinux_path_file_getattr),\n+\tLSM_HOOK_INIT(path_file_setattr, selinux_path_file_setattr),\n+\tLSM_HOOK_INIT(path_set_acl, selinux_path_set_acl),\n+\tLSM_HOOK_INIT(path_get_acl, selinux_path_get_acl),\n+\tLSM_HOOK_INIT(path_remove_acl, selinux_path_remove_acl),\n \tLSM_HOOK_INIT(inode_getsecurity, selinux_inode_getsecurity),\n \tLSM_HOOK_INIT(inode_setsecurity, selinux_inode_setsecurity),\n \tLSM_HOOK_INIT(inode_listsecurity, selinux_inode_listsecurity),\n@@ -7848,7 +7851,7 @@ static struct security_hook_list selinux_hooks[] __ro_after_init = {\n \tLSM_HOOK_INIT(release_secctx, selinux_release_secctx),\n \tLSM_HOOK_INIT(inode_invalidate_secctx, selinux_inode_invalidate_secctx),\n \tLSM_HOOK_INIT(inode_notifysecctx, selinux_inode_notifysecctx),\n-\tLSM_HOOK_INIT(inode_setsecctx, selinux_inode_setsecctx),\n+\tLSM_HOOK_INIT(path_setsecctx, selinux_path_setsecctx),\n \n \tLSM_HOOK_INIT(unix_stream_connect, selinux_socket_unix_stream_connect),\n \tLSM_HOOK_INIT(unix_may_send, selinux_socket_unix_may_send),\ndiff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c\nindex 3524649f402da..43f407ae007fe 100644\n--- a/security/smack/smack_lsm.c\n+++ b/security/smack/smack_lsm.c\n@@ -1265,17 +1265,18 @@ static int smack_inode_permission(const struct mnt_idmap *idmap, struct inode *i\n }\n \n /**\n- * smack_inode_setattr - Smack check for setting attributes\n+ * smack_path_setattr - Smack check for setting attributes\n  * @idmap: idmap of the mount\n  * @dentry: the object\n  * @iattr: for the force flag\n  *\n  * Returns 0 if access is permitted, an error code otherwise\n  */\n-static int smack_inode_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,\n+static int smack_path_setattr(const struct path *path,\n \t\t\t       struct iattr *iattr)\n {\n \tstruct smk_audit_info ad;\n+\tstruct dentry *dentry = path-\u003edentry;\n \tint rc;\n \n \t/*\n@@ -1292,12 +1293,12 @@ static int smack_inode_setattr(const struct mnt_idmap *idmap, struct dentry *den\n }\n \n /**\n- * smack_inode_getattr - Smack check for getting attributes\n+ * smack_path_getattr - Smack check for getting attributes\n  * @path: path to extract the info from\n  *\n  * Returns 0 if access is permitted, an error code otherwise\n  */\n-static int smack_inode_getattr(const struct path *path)\n+static int smack_path_getattr(const struct path *path)\n {\n \tstruct smk_audit_info ad;\n \tstruct inode *inode = d_backing_inode(path-\u003edentry);\n@@ -1338,7 +1339,7 @@ static int smack_inode_xattr_skipcap(const char *name)\n }\n \n /**\n- * smack_inode_setxattr - Smack check for setting xattrs\n+ * smack_path_setxattr - Smack check for setting xattrs\n  * @idmap: idmap of the mount\n  * @dentry: the object\n  * @name: name of the attribute\n@@ -1350,11 +1351,12 @@ static int smack_inode_xattr_skipcap(const char *name)\n  *\n  * Returns 0 if access is permitted, an error code otherwise\n  */\n-static int smack_inode_setxattr(const struct mnt_idmap *idmap,\n-\t\t\t\tstruct dentry *dentry, const char *name,\n-\t\t\t\tconst void *value, size_t size, int flags)\n+static int smack_path_setxattr(const struct path *path,\n+\t\t\t\tconst char *name, const void *value,\n+\t\t\t\tsize_t size, int flags)\n {\n \tstruct smk_audit_info ad;\n+\tstruct dentry *dentry = path-\u003edentry;\n \tstruct smack_known *skp;\n \tint check_priv = 0;\n \tint check_import = 0;\n@@ -1455,15 +1457,16 @@ static void smack_inode_post_setxattr(struct dentry *dentry, const char *name,\n }\n \n /**\n- * smack_inode_getxattr - Smack check on getxattr\n+ * smack_path_getxattr - Smack check on getxattr\n  * @dentry: the object\n  * @name: unused\n  *\n  * Returns 0 if access is permitted, an error code otherwise\n  */\n-static int smack_inode_getxattr(struct dentry *dentry, const char *name)\n+static int smack_path_getxattr(const struct path *path, const char *name)\n {\n \tstruct smk_audit_info ad;\n+\tstruct dentry *dentry = path-\u003edentry;\n \tint rc;\n \n \tsmk_ad_init(\u0026ad, __func__, LSM_AUDIT_DATA_DENTRY);\n@@ -1475,20 +1478,20 @@ static int smack_inode_getxattr(struct dentry *dentry, const char *name)\n }\n \n /**\n- * smack_inode_removexattr - Smack check on removexattr\n- * @idmap: idmap of the mount\n- * @dentry: the object\n+ * smack_path_removexattr - Smack check on removexattr\n+ * @path: the object\n  * @name: name of the attribute\n  *\n  * Removing the Smack attribute requires CAP_MAC_ADMIN\n  *\n  * Returns 0 if access is permitted, an error code otherwise\n  */\n-static int smack_inode_removexattr(const struct mnt_idmap *idmap,\n-\t\t\t\t   struct dentry *dentry, const char *name)\n+static int smack_path_removexattr(const struct path *path,\n+\t\t\t\t   const char *name)\n {\n \tstruct inode_smack *isp;\n \tstruct smk_audit_info ad;\n+\tstruct dentry *dentry = path-\u003edentry;\n \tint rc = 0;\n \n \tif (strcmp(name, XATTR_NAME_SMACK) == 0 ||\n@@ -1537,7 +1540,7 @@ static int smack_inode_removexattr(const struct mnt_idmap *idmap,\n }\n \n /**\n- * smack_inode_set_acl - Smack check for setting posix acls\n+ * smack_path_set_acl - Smack check for setting posix acls\n  * @idmap: idmap of the mnt this request came from\n  * @dentry: the object\n  * @acl_name: name of the posix acl\n@@ -1545,62 +1548,59 @@ static int smack_inode_removexattr(const struct mnt_idmap *idmap,\n  *\n  * Returns 0 if access is permitted, an error code otherwise\n  */\n-static int smack_inode_set_acl(const struct mnt_idmap *idmap,\n-\t\t\t       struct dentry *dentry, const char *acl_name,\n-\t\t\t       struct posix_acl *kacl)\n+static int smack_path_set_acl(const struct path *path,\n+\t\t\t       const char *acl_name, struct posix_acl *kacl)\n {\n \tstruct smk_audit_info ad;\n \tint rc;\n \n \tsmk_ad_init(\u0026ad, __func__, LSM_AUDIT_DATA_DENTRY);\n-\tsmk_ad_setfield_u_fs_path_dentry(\u0026ad, dentry);\n+\tsmk_ad_setfield_u_fs_path_dentry(\u0026ad, path-\u003edentry);\n \n-\trc = smk_curacc(smk_of_inode(d_backing_inode(dentry)), MAY_WRITE, \u0026ad);\n-\trc = smk_bu_inode(d_backing_inode(dentry), MAY_WRITE, rc);\n+\trc = smk_curacc(smk_of_inode(d_backing_inode(path-\u003edentry)), MAY_WRITE, \u0026ad);\n+\trc = smk_bu_inode(d_backing_inode(path-\u003edentry), MAY_WRITE, rc);\n \treturn rc;\n }\n \n /**\n- * smack_inode_get_acl - Smack check for getting posix acls\n- * @idmap: idmap of the mnt this request came from\n- * @dentry: the object\n+ * smack_path_get_acl - Smack check for getting posix acls\n+ * @path: the object\n  * @acl_name: name of the posix acl\n  *\n  * Returns 0 if access is permitted, an error code otherwise\n  */\n-static int smack_inode_get_acl(const struct mnt_idmap *idmap,\n-\t\t\t       struct dentry *dentry, const char *acl_name)\n+static int smack_path_get_acl(const struct path *path,\n+\t\t\t       const char *acl_name)\n {\n \tstruct smk_audit_info ad;\n \tint rc;\n \n \tsmk_ad_init(\u0026ad, __func__, LSM_AUDIT_DATA_DENTRY);\n-\tsmk_ad_setfield_u_fs_path_dentry(\u0026ad, dentry);\n+\tsmk_ad_setfield_u_fs_path_dentry(\u0026ad, path-\u003edentry);\n \n-\trc = smk_curacc(smk_of_inode(d_backing_inode(dentry)), MAY_READ, \u0026ad);\n-\trc = smk_bu_inode(d_backing_inode(dentry), MAY_READ, rc);\n+\trc = smk_curacc(smk_of_inode(d_backing_inode(path-\u003edentry)), MAY_READ, \u0026ad);\n+\trc = smk_bu_inode(d_backing_inode(path-\u003edentry), MAY_READ, rc);\n \treturn rc;\n }\n \n /**\n- * smack_inode_remove_acl - Smack check for getting posix acls\n- * @idmap: idmap of the mnt this request came from\n- * @dentry: the object\n+ * smack_path_remove_acl - Smack check for getting posix acls\n+ * @path: the object\n  * @acl_name: name of the posix acl\n  *\n  * Returns 0 if access is permitted, an error code otherwise\n  */\n-static int smack_inode_remove_acl(const struct mnt_idmap *idmap,\n-\t\t\t\t  struct dentry *dentry, const char *acl_name)\n+static int smack_path_remove_acl(const struct path *path,\n+\t\t\t\t  const char *acl_name)\n {\n \tstruct smk_audit_info ad;\n \tint rc;\n \n \tsmk_ad_init(\u0026ad, __func__, LSM_AUDIT_DATA_DENTRY);\n-\tsmk_ad_setfield_u_fs_path_dentry(\u0026ad, dentry);\n+\tsmk_ad_setfield_u_fs_path_dentry(\u0026ad, path-\u003edentry);\n \n-\trc = smk_curacc(smk_of_inode(d_backing_inode(dentry)), MAY_WRITE, \u0026ad);\n-\trc = smk_bu_inode(d_backing_inode(dentry), MAY_WRITE, rc);\n+\trc = smk_curacc(smk_of_inode(d_backing_inode(path-\u003edentry)), MAY_WRITE, \u0026ad);\n+\trc = smk_bu_inode(d_backing_inode(path-\u003edentry), MAY_WRITE, rc);\n \treturn rc;\n }\n \n@@ -4978,9 +4978,9 @@ static int smack_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen)\n \t\t\t\t       ctxlen, 0);\n }\n \n-static int smack_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen)\n+static int smack_path_setsecctx(const struct path *path, void *ctx, u32 ctxlen)\n {\n-\treturn __vfs_setxattr_locked(\u0026nop_mnt_idmap, dentry, XATTR_NAME_SMACK,\n+\treturn __vfs_setxattr_locked(path, XATTR_NAME_SMACK,\n \t\t\t\t     ctx, ctxlen, 0, NULL);\n }\n \n@@ -5178,16 +5178,16 @@ static struct security_hook_list smack_hooks[] __ro_after_init = {\n \tLSM_HOOK_INIT(inode_rmdir, smack_inode_rmdir),\n \tLSM_HOOK_INIT(inode_rename, smack_inode_rename),\n \tLSM_HOOK_INIT(inode_permission, smack_inode_permission),\n-\tLSM_HOOK_INIT(inode_setattr, smack_inode_setattr),\n-\tLSM_HOOK_INIT(inode_getattr, smack_inode_getattr),\n+\tLSM_HOOK_INIT(path_setattr, smack_path_setattr),\n+\tLSM_HOOK_INIT(path_getattr, smack_path_getattr),\n \tLSM_HOOK_INIT(inode_xattr_skipcap, smack_inode_xattr_skipcap),\n-\tLSM_HOOK_INIT(inode_setxattr, smack_inode_setxattr),\n+\tLSM_HOOK_INIT(path_setxattr, smack_path_setxattr),\n \tLSM_HOOK_INIT(inode_post_setxattr, smack_inode_post_setxattr),\n-\tLSM_HOOK_INIT(inode_getxattr, smack_inode_getxattr),\n-\tLSM_HOOK_INIT(inode_removexattr, smack_inode_removexattr),\n-\tLSM_HOOK_INIT(inode_set_acl, smack_inode_set_acl),\n-\tLSM_HOOK_INIT(inode_get_acl, smack_inode_get_acl),\n-\tLSM_HOOK_INIT(inode_remove_acl, smack_inode_remove_acl),\n+\tLSM_HOOK_INIT(path_getxattr, smack_path_getxattr),\n+\tLSM_HOOK_INIT(path_removexattr, smack_path_removexattr),\n+\tLSM_HOOK_INIT(path_set_acl, smack_path_set_acl),\n+\tLSM_HOOK_INIT(path_get_acl, smack_path_get_acl),\n+\tLSM_HOOK_INIT(path_remove_acl, smack_path_remove_acl),\n \tLSM_HOOK_INIT(inode_getsecurity, smack_inode_getsecurity),\n \tLSM_HOOK_INIT(inode_setsecurity, smack_inode_setsecurity),\n \tLSM_HOOK_INIT(inode_listsecurity, smack_inode_listsecurity),\n@@ -5303,7 +5303,7 @@ static struct security_hook_list smack_hooks[] __ro_after_init = {\n \tLSM_HOOK_INIT(lsmprop_to_secctx, smack_lsmprop_to_secctx),\n \tLSM_HOOK_INIT(secctx_to_secid, smack_secctx_to_secid),\n \tLSM_HOOK_INIT(inode_notifysecctx, smack_inode_notifysecctx),\n-\tLSM_HOOK_INIT(inode_setsecctx, smack_inode_setsecctx),\n+\tLSM_HOOK_INIT(path_setsecctx, smack_path_setsecctx),\n \tLSM_HOOK_INIT(inode_getsecctx, smack_inode_getsecctx),\n \tLSM_HOOK_INIT(inode_copy_up, smack_inode_copy_up),\n \tLSM_HOOK_INIT(inode_copy_up_xattr, smack_inode_copy_up_xattr),\ndiff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c\nindex c66e02ed8ee3b..901eefa84ea6c 100644\n--- a/security/tomoyo/tomoyo.c\n+++ b/security/tomoyo/tomoyo.c\n@@ -112,13 +112,13 @@ static int tomoyo_bprm_check_security(struct linux_binprm *bprm)\n }\n \n /**\n- * tomoyo_inode_getattr - Target for security_inode_getattr().\n+ * tomoyo_path_getattr - Target for security_path_getattr().\n  *\n  * @path: Pointer to \"struct path\".\n  *\n  * Returns 0 on success, negative value otherwise.\n  */\n-static int tomoyo_inode_getattr(const struct path *path)\n+static int tomoyo_path_getattr(const struct path *path)\n {\n \treturn tomoyo_path_perm(TOMOYO_TYPE_GETATTR, path, NULL);\n }\n@@ -570,7 +570,7 @@ static struct security_hook_list tomoyo_hooks[] __ro_after_init = {\n \tLSM_HOOK_INIT(path_mknod, tomoyo_path_mknod),\n \tLSM_HOOK_INIT(path_link, tomoyo_path_link),\n \tLSM_HOOK_INIT(path_rename, tomoyo_path_rename),\n-\tLSM_HOOK_INIT(inode_getattr, tomoyo_inode_getattr),\n+\tLSM_HOOK_INIT(path_getattr, tomoyo_path_getattr),\n \tLSM_HOOK_INIT(file_ioctl, tomoyo_file_ioctl),\n \tLSM_HOOK_INIT(file_ioctl_compat, tomoyo_file_ioctl),\n \tLSM_HOOK_INIT(path_chmod, tomoyo_path_chmod),\ndiff --git a/tools/testing/selftests/bpf/prog_tests/d_path.c b/tools/testing/selftests/bpf/prog_tests/d_path.c\nindex 1a2a2f1abf033..9877c098e5c14 100644\n--- a/tools/testing/selftests/bpf/prog_tests/d_path.c\n+++ b/tools/testing/selftests/bpf/prog_tests/d_path.c\n@@ -160,7 +160,7 @@ static void test_d_path_basic(void)\n \n \tif (CHECK(!bss-\u003ecalled_stat,\n \t\t  \"stat\",\n-\t\t  \"trampoline for security_inode_getattr was not called\\n\"))\n+\t\t  \"trampoline for security_path_getattr was not called\\n\"))\n \t\tgoto cleanup;\n \n \tif (CHECK(!bss-\u003ecalled_close,\ndiff --git a/tools/testing/selftests/bpf/prog_tests/fs_kfuncs.c b/tools/testing/selftests/bpf/prog_tests/fs_kfuncs.c\nindex 43a26ec69a8e3..5145b1f03cac2 100644\n--- a/tools/testing/selftests/bpf/prog_tests/fs_kfuncs.c\n+++ b/tools/testing/selftests/bpf/prog_tests/fs_kfuncs.c\n@@ -53,7 +53,7 @@ static void test_get_xattr(const char *name, const char *value, bool allow_acces\n \tif (!ASSERT_GE(fd, 0, \"open_file\"))\n \t\tgoto out;\n \n-\t/* Trigger security_inode_getxattr */\n+\t/* Trigger security_path_getxattr */\n \terr = getxattr(testfile, name, v, sizeof(v));\n \n \tif (allow_access) {\n@@ -148,13 +148,13 @@ static void test_set_remove_xattr(void)\n \n \t/* First, test not _locked version of the kfuncs with getxattr. */\n \n-\t/* Read security.bpf.foo and trigger test_inode_getxattr. This\n+\t/* Read security.bpf.foo and trigger test_path_getxattr. This\n \t * bpf program will set security.bpf.bar to \"world\".\n \t */\n \tread_and_validate_foo(skel);\n \tvalidate_bar_match(skel);\n \n-\t/* Read security.bpf.foo and trigger test_inode_getxattr again.\n+\t/* Read security.bpf.foo and trigger test_path_getxattr again.\n \t * This will remove xattr security.bpf.bar.\n \t */\n \tread_and_validate_foo(skel);\n@@ -167,13 +167,13 @@ static void test_set_remove_xattr(void)\n \n \t/* Second, test _locked version of the kfuncs, with setxattr */\n \n-\t/* Set security.bpf.foo and trigger test_inode_setxattr. This\n+\t/* Set security.bpf.foo and trigger test_path_setxattr. This\n \t * bpf program will set security.bpf.bar to \"world\".\n \t */\n \tset_foo(skel);\n \tvalidate_bar_match(skel);\n \n-\t/* Set security.bpf.foo and trigger test_inode_setxattr again.\n+\t/* Set security.bpf.foo and trigger test_path_setxattr again.\n \t * This will remove xattr security.bpf.bar.\n \t */\n \tset_foo(skel);\ndiff --git a/tools/testing/selftests/bpf/progs/test_d_path.c b/tools/testing/selftests/bpf/progs/test_d_path.c\nindex 561b2f861808e..b97c203e3992d 100644\n--- a/tools/testing/selftests/bpf/progs/test_d_path.c\n+++ b/tools/testing/selftests/bpf/progs/test_d_path.c\n@@ -19,7 +19,7 @@ int called_stat = 0;\n int called_close = 0;\n int path_match_fallocate = 0;\n \n-SEC(\"fentry/security_inode_getattr\")\n+SEC(\"fentry/security_path_getattr\")\n int BPF_PROG(prog_stat, struct path *path, struct kstat *stat,\n \t     __u32 request_mask, unsigned int query_flags)\n {\ndiff --git a/tools/testing/selftests/bpf/progs/test_d_path_check_rdonly_mem.c b/tools/testing/selftests/bpf/progs/test_d_path_check_rdonly_mem.c\nindex 27c27cff6a3aa..5e0e3d4828d79 100644\n--- a/tools/testing/selftests/bpf/progs/test_d_path_check_rdonly_mem.c\n+++ b/tools/testing/selftests/bpf/progs/test_d_path_check_rdonly_mem.c\n@@ -7,7 +7,7 @@\n \n extern const int bpf_prog_active __ksym;\n \n-SEC(\"fentry/security_inode_getattr\")\n+SEC(\"fentry/security_path_getattr\")\n int BPF_PROG(d_path_check_rdonly_mem, struct path *path, struct kstat *stat,\n \t     __u32 request_mask, unsigned int query_flags)\n {\ndiff --git a/tools/testing/selftests/bpf/progs/test_d_path_check_types.c b/tools/testing/selftests/bpf/progs/test_d_path_check_types.c\nindex 7e02b7361307c..fba3d527b4df6 100644\n--- a/tools/testing/selftests/bpf/progs/test_d_path_check_types.c\n+++ b/tools/testing/selftests/bpf/progs/test_d_path_check_types.c\n@@ -11,7 +11,7 @@ struct {\n \t__uint(max_entries, 1 \u003c\u003c 12);\n } ringbuf SEC(\".maps\");\n \n-SEC(\"fentry/security_inode_getattr\")\n+SEC(\"fentry/security_path_getattr\")\n int BPF_PROG(d_path_check_rdonly_mem, struct path *path, struct kstat *stat,\n \t     __u32 request_mask, unsigned int query_flags)\n {\ndiff --git a/tools/testing/selftests/bpf/progs/test_get_xattr.c b/tools/testing/selftests/bpf/progs/test_get_xattr.c\nindex 54305f4c9f2dd..eea89016f96f1 100644\n--- a/tools/testing/selftests/bpf/progs/test_get_xattr.c\n+++ b/tools/testing/selftests/bpf/progs/test_get_xattr.c\n@@ -55,8 +55,8 @@ int BPF_PROG(test_file_open, struct file *f)\n \treturn 0;\n }\n \n-SEC(\"lsm.s/inode_getxattr\")\n-int BPF_PROG(test_inode_getxattr, struct dentry *dentry, char *name)\n+SEC(\"lsm.s/path_getxattr\")\n+int BPF_PROG(test_path_getxattr, const struct path *path, char *name)\n {\n \tstruct bpf_dynptr value_ptr;\n \t__u32 pid;\n@@ -69,7 +69,7 @@ int BPF_PROG(test_inode_getxattr, struct dentry *dentry, char *name)\n \tbpf_dynptr_from_mem(value2, sizeof(value2), 0, \u0026value_ptr);\n \n \tfor (i = 0; i \u003c ARRAY_SIZE(xattr_names); i++) {\n-\t\tret = bpf_get_dentry_xattr(dentry, xattr_names[i], \u0026value_ptr);\n+\t\tret = bpf_get_dentry_xattr(path-\u003edentry, xattr_names[i], \u0026value_ptr);\n \t\tif (ret == sizeof(expected_value))\n \t\t\tbreak;\n \t}\ndiff --git a/tools/testing/selftests/bpf/progs/test_set_remove_xattr.c b/tools/testing/selftests/bpf/progs/test_set_remove_xattr.c\nindex 6a612cf168d3f..f7438081d630e 100644\n--- a/tools/testing/selftests/bpf/progs/test_set_remove_xattr.c\n+++ b/tools/testing/selftests/bpf/progs/test_set_remove_xattr.c\n@@ -32,8 +32,8 @@ static inline bool name_match_foo(const char *name)\n }\n \n /* Test bpf_set_dentry_xattr and bpf_remove_dentry_xattr */\n-SEC(\"lsm.s/inode_getxattr\")\n-int BPF_PROG(test_inode_getxattr, struct dentry *dentry, char *name)\n+SEC(\"lsm.s/path_getxattr\")\n+int BPF_PROG(test_path_getxattr, const struct path *path, char *name)\n {\n \tstruct bpf_dynptr value_ptr;\n \t__u32 pid;\n@@ -50,25 +50,25 @@ int BPF_PROG(test_inode_getxattr, struct dentry *dentry, char *name)\n \tbpf_dynptr_from_mem(read_value, sizeof(read_value), 0, \u0026value_ptr);\n \n \t/* read security.bpf.bar */\n-\tret = bpf_get_dentry_xattr(dentry, xattr_bar, \u0026value_ptr);\n+\tret = bpf_get_dentry_xattr(path-\u003edentry, xattr_bar, \u0026value_ptr);\n \n \tif (ret \u003c 0) {\n \t\t/* If security.bpf.bar doesn't exist, set it */\n \t\tbpf_dynptr_from_mem(value_bar, sizeof(value_bar), 0, \u0026value_ptr);\n \n-\t\tret = bpf_set_dentry_xattr(dentry, xattr_bar, \u0026value_ptr, 0);\n+\t\tret = bpf_set_dentry_xattr(path-\u003edentry, xattr_bar, \u0026value_ptr, 0);\n \t\tif (!ret)\n \t\t\tset_security_bpf_bar_success = true;\n-\t\tret = bpf_set_dentry_xattr(dentry, xattr_selinux, \u0026value_ptr, 0);\n+\t\tret = bpf_set_dentry_xattr(path-\u003edentry, xattr_selinux, \u0026value_ptr, 0);\n \t\tif (ret)\n \t\t\tset_security_selinux_fail = true;\n \t} else {\n \t\t/* If security.bpf.bar exists, remove it */\n-\t\tret = bpf_remove_dentry_xattr(dentry, xattr_bar);\n+\t\tret = bpf_remove_dentry_xattr(path-\u003edentry, xattr_bar);\n \t\tif (!ret)\n \t\t\tremove_security_bpf_bar_success = true;\n \n-\t\tret = bpf_remove_dentry_xattr(dentry, xattr_selinux);\n+\t\tret = bpf_remove_dentry_xattr(path-\u003edentry, xattr_selinux);\n \t\tif (ret)\n \t\t\tremove_security_selinux_fail = true;\n \t}\n@@ -86,10 +86,9 @@ bool locked_remove_security_selinux_fail;\n  * not-_locked version in the BPF program. The verifier will fix them up\n  * properly.\n  */\n-SEC(\"lsm.s/inode_setxattr\")\n-int BPF_PROG(test_inode_setxattr, struct mnt_idmap *idmap,\n-\t     struct dentry *dentry, const char *name,\n-\t     const void *value, size_t size, int flags)\n+SEC(\"lsm.s/path_setxattr\")\n+int BPF_PROG(test_path_setxattr, const struct path *path,\n+\t     const char *name, const void *value, size_t size, int flags)\n {\n \tstruct bpf_dynptr value_ptr;\n \t__u32 pid;\n@@ -106,25 +105,25 @@ int BPF_PROG(test_inode_setxattr, struct mnt_idmap *idmap,\n \tbpf_dynptr_from_mem(read_value, sizeof(read_value), 0, \u0026value_ptr);\n \n \t/* read security.bpf.bar */\n-\tret = bpf_get_dentry_xattr(dentry, xattr_bar, \u0026value_ptr);\n+\tret = bpf_get_dentry_xattr(path-\u003edentry, xattr_bar, \u0026value_ptr);\n \n \tif (ret \u003c 0) {\n \t\t/* If security.bpf.bar doesn't exist, set it */\n \t\tbpf_dynptr_from_mem(value_bar, sizeof(value_bar), 0, \u0026value_ptr);\n \n-\t\tret = bpf_set_dentry_xattr(dentry, xattr_bar, \u0026value_ptr, 0);\n+\t\tret = bpf_set_dentry_xattr(path-\u003edentry, xattr_bar, \u0026value_ptr, 0);\n \t\tif (!ret)\n \t\t\tlocked_set_security_bpf_bar_success = true;\n-\t\tret = bpf_set_dentry_xattr(dentry, xattr_selinux, \u0026value_ptr, 0);\n+\t\tret = bpf_set_dentry_xattr(path-\u003edentry, xattr_selinux, \u0026value_ptr, 0);\n \t\tif (ret)\n \t\t\tlocked_set_security_selinux_fail = true;\n \t} else {\n \t\t/* If security.bpf.bar exists, remove it */\n-\t\tret = bpf_remove_dentry_xattr(dentry, xattr_bar);\n+\t\tret = bpf_remove_dentry_xattr(path-\u003edentry, xattr_bar);\n \t\tif (!ret)\n \t\t\tlocked_remove_security_bpf_bar_success = true;\n \n-\t\tret = bpf_remove_dentry_xattr(dentry, xattr_selinux);\n+\t\tret = bpf_remove_dentry_xattr(path-\u003edentry, xattr_selinux);\n \t\tif (ret)\n \t\t\tlocked_remove_security_selinux_fail = true;\n \t}\ndiff --git a/tools/testing/selftests/bpf/progs/verifier_lsm_init_xattr.c b/tools/testing/selftests/bpf/progs/verifier_lsm_init_xattr.c\nindex b706bf17b5560..a9b09e559d7e4 100644\n--- a/tools/testing/selftests/bpf/progs/verifier_lsm_init_xattr.c\n+++ b/tools/testing/selftests/bpf/progs/verifier_lsm_init_xattr.c\n@@ -232,9 +232,9 @@ int BPF_PROG(reject_lsm_cgroup, struct inode *inode, struct inode *dir,\n \treturn 0;\n }\n \n-SEC(\"lsm/inode_setxattr\")\n+SEC(\"lsm/path_setxattr\")\n __failure __msg(\"calling kernel function bpf_inode_init_xattr is not allowed\")\n-int BPF_PROG(reject_wrong_hook, struct mnt_idmap *idmap, struct dentry *dentry,\n+int BPF_PROG(reject_wrong_hook, const struct path *path,\n \t     const char *name, const void *value, size_t size, int flags)\n {\n \tstruct bpf_dynptr val;\ndiff --git a/tools/testing/selftests/bpf/progs/verifier_vfs_accept.c b/tools/testing/selftests/bpf/progs/verifier_vfs_accept.c\nindex 55398c04290a8..55e292a41d304 100644\n--- a/tools/testing/selftests/bpf/progs/verifier_vfs_accept.c\n+++ b/tools/testing/selftests/bpf/progs/verifier_vfs_accept.c\n@@ -54,7 +54,7 @@ int BPF_PROG(get_task_exe_file_and_put_kfunc_from_argument,\n \treturn 0;\n }\n \n-SEC(\"lsm.s/inode_getattr\")\n+SEC(\"lsm.s/path_getattr\")\n __success\n int BPF_PROG(path_d_path_from_path_argument, struct path *path)\n {\ndiff --git a/tools/testing/selftests/bpf/progs/verifier_vfs_reject.c b/tools/testing/selftests/bpf/progs/verifier_vfs_reject.c\nindex b5f456d57669e..1337effeb46be 100644\n--- a/tools/testing/selftests/bpf/progs/verifier_vfs_reject.c\n+++ b/tools/testing/selftests/bpf/progs/verifier_vfs_reject.c\n@@ -27,7 +27,7 @@ int BPF_PROG(get_task_exe_file_kfunc_null)\n \treturn 0;\n }\n \n-SEC(\"lsm.s/inode_getxattr\")\n+SEC(\"lsm.s/path_getxattr\")\n __failure __msg(\"R1 type=fp expected=ptr_, trusted_ptr_, rcu_ptr_\")\n int BPF_PROG(get_task_exe_file_kfunc_fp)\n {\ndiff --git a/tools/testing/selftests/landlock/base_test.c b/tools/testing/selftests/landlock/base_test.c\nindex 89c0d96607deb..14078ad203d8b 100644\n--- a/tools/testing/selftests/landlock/base_test.c\n+++ b/tools/testing/selftests/landlock/base_test.c\n@@ -76,7 +76,7 @@ TEST(abi_version)\n \tconst struct landlock_ruleset_attr ruleset_attr = {\n \t\t.handled_access_fs = LANDLOCK_ACCESS_FS_READ_FILE,\n \t};\n-\tASSERT_EQ(12, landlock_create_ruleset(NULL, 0,\n+\tASSERT_EQ(13, landlock_create_ruleset(NULL, 0,\n \t\t\t\t\t      LANDLOCK_CREATE_RULESET_VERSION));\n \n \tASSERT_EQ(-1, landlock_create_ruleset(\u0026ruleset_attr, 0,\ndiff --git a/tools/testing/selftests/landlock/fs_test.c b/tools/testing/selftests/landlock/fs_test.c\nindex f725882fa4a78..ce865955c5794 100644\n--- a/tools/testing/selftests/landlock/fs_test.c\n+++ b/tools/testing/selftests/landlock/fs_test.c\n@@ -12,6 +12,7 @@\n #include \u003cfcntl.h\u003e\n #include \u003clibgen.h\u003e\n #include \u003clinux/fiemap.h\u003e\n+#include \u003clinux/fs.h\u003e\n #include \u003clinux/landlock.h\u003e\n #include \u003clinux/magic.h\u003e\n #include \u003csched.h\u003e\n@@ -26,8 +27,10 @@\n #include \u003csys/sendfile.h\u003e\n #include \u003csys/socket.h\u003e\n #include \u003csys/stat.h\u003e\n+#include \u003csys/syscall.h\u003e\n #include \u003csys/sysmacros.h\u003e\n #include \u003csys/un.h\u003e\n+#include \u003csys/xattr.h\u003e\n #include \u003csys/vfs.h\u003e\n #include \u003cunistd.h\u003e\n \n@@ -571,11 +574,13 @@ TEST_F_FORK(layout1, inval)\n \tLANDLOCK_ACCESS_FS_EXECUTE | \\\n \tLANDLOCK_ACCESS_FS_WRITE_FILE | \\\n \tLANDLOCK_ACCESS_FS_READ_FILE | \\\n+\tLANDLOCK_ACCESS_FS_READ_METADATA | \\\n+\tLANDLOCK_ACCESS_FS_WRITE_METADATA | \\\n \tLANDLOCK_ACCESS_FS_TRUNCATE | \\\n \tLANDLOCK_ACCESS_FS_IOCTL_DEV | \\\n \tLANDLOCK_ACCESS_FS_RESOLVE_UNIX)\n \n-#define ACCESS_LAST LANDLOCK_ACCESS_FS_RESOLVE_UNIX\n+#define ACCESS_LAST LANDLOCK_ACCESS_FS_WRITE_METADATA\n \n #define ACCESS_ALL ( \\\n \tACCESS_FILE | \\\n@@ -10916,4 +10921,603 @@ TEST_F(trace_layout1, check_rule_fs_empty_grant)\n \tfree(buf);\n }\n \n+/* Invokes chmod(2) and returns its errno or 0. */\n+static int test_chmod(const char *const path, mode_t mode)\n+{\n+\tif (chmod(path, mode) \u003c 0)\n+\t\treturn errno;\n+\treturn 0;\n+}\n+\n+/* Invokes fchmod(2) and returns its errno or 0. */\n+static int test_fchmod(int fd, mode_t mode)\n+{\n+\tif (fchmod(fd, mode) \u003c 0)\n+\t\treturn errno;\n+\treturn 0;\n+}\n+\n+/* Invokes chown(2) and returns its errno or 0. */\n+static int test_chown(const char *const path, uid_t uid, gid_t gid)\n+{\n+\tif (chown(path, uid, gid) \u003c 0)\n+\t\treturn errno;\n+\treturn 0;\n+}\n+\n+/* Invokes fchown(2) and returns its errno or 0. */\n+static int test_fchown(int fd, uid_t uid, gid_t gid)\n+{\n+\tif (fchown(fd, uid, gid) \u003c 0)\n+\t\treturn errno;\n+\treturn 0;\n+}\n+\n+/* Invokes lchown(2) and returns its errno or 0. */\n+static int test_lchown(const char *const path, uid_t uid, gid_t gid)\n+{\n+\tif (lchown(path, uid, gid) \u003c 0)\n+\t\treturn errno;\n+\treturn 0;\n+}\n+\n+/* Invokes utimensat(2) with explicit times and returns its errno or 0. */\n+static int test_utimensat(const char *const path)\n+{\n+\tconst struct timespec times[] = {\n+\t\t{\n+\t\t\t.tv_sec = 0,\n+\t\t\t.tv_nsec = UTIME_OMIT,\n+\t\t},\n+\t\t{\n+\t\t\t.tv_sec = 1,\n+\t\t\t.tv_nsec = 0,\n+\t\t},\n+\t};\n+\n+\tif (utimensat(AT_FDCWD, path, times, 0) \u003c 0)\n+\t\treturn errno;\n+\treturn 0;\n+}\n+\n+/* Invokes utimensat(2) with UTIME_NOW and returns its errno or 0. */\n+static int test_utimensat_now(const char *const path)\n+{\n+\tif (utimensat(AT_FDCWD, path, NULL, 0) \u003c 0)\n+\t\treturn errno;\n+\treturn 0;\n+}\n+\n+/* Invokes setxattr(2) and returns its errno or 0. */\n+static int test_setxattr(const char *const path, const char *const name,\n+\t\t\t const void *const value, const size_t size)\n+{\n+\tif (setxattr(path, name, value, size, 0) \u003c 0)\n+\t\treturn errno;\n+\treturn 0;\n+}\n+\n+/* Invokes getxattr(2) and returns its errno or 0. */\n+static int test_getxattr(const char *const path, const char *const name,\n+\t\t\t void *const value, const size_t size)\n+{\n+\tif (getxattr(path, name, value, size) \u003c 0)\n+\t\treturn errno;\n+\treturn 0;\n+}\n+\n+/* Invokes listxattr(2) and returns its errno or 0. */\n+static int test_listxattr(const char *const path, void *const list,\n+\t\t\t  const size_t size)\n+{\n+\tif (listxattr(path, list, size) \u003c 0)\n+\t\treturn errno;\n+\treturn 0;\n+}\n+\n+/* Invokes removexattr(2) and returns its errno or 0. */\n+static int test_removexattr(const char *const path, const char *const name)\n+{\n+\tif (removexattr(path, name) \u003c 0)\n+\t\treturn errno;\n+\treturn 0;\n+}\n+\n+/* Invokes stat(2) and returns its errno or 0. */\n+static int test_stat(const char *const path, struct stat *statbuf)\n+{\n+\tif (stat(path, statbuf) \u003c 0)\n+\t\treturn errno;\n+\treturn 0;\n+}\n+\n+/* Invokes fstat(2) and returns its errno or 0. */\n+static int test_fstat(int fd, struct stat *statbuf)\n+{\n+\tif (fstat(fd, statbuf) \u003c 0)\n+\t\treturn errno;\n+\treturn 0;\n+}\n+\n+TEST_F_FORK(layout1, unhandled_metadata)\n+{\n+\tint file_fd;\n+\tint ruleset_fd;\n+\tconst char *const file1 = file1_s1d1;\n+\tconst char *const file2 = file2_s1d1;\n+\tconst char *const dir1 = dir_s1d1;\n+\tstruct stat statbuf;\n+\tconst struct rule rules[] = {\n+\t\t{\n+\t\t\t.path = file1,\n+\t\t\t.access = LANDLOCK_ACCESS_FS_WRITE_FILE,\n+\t\t},\n+\t\t{\n+\t\t\t.path = file2,\n+\t\t\t.access = LANDLOCK_ACCESS_FS_READ_FILE |\n+\t\t\t\t  LANDLOCK_ACCESS_FS_WRITE_FILE,\n+\t\t},\n+\t\t{\n+\t\t\t.path = dir1,\n+\t\t\t.access = ACCESS_RW,\n+\t\t},\n+\t\t{},\n+\t};\n+\n+\t/*\n+\t * READ_METADATA and WRITE_METADATA are not handled, so metadata\n+\t * access should be allowed.\n+\t */\n+\truleset_fd = create_ruleset(_metadata, ACCESS_RW, rules);\n+\tASSERT_LE(0, ruleset_fd);\n+\tfile_fd = open(file1, O_WRONLY | O_CLOEXEC);\n+\tASSERT_LE(0, file_fd);\n+\n+\tenforce_ruleset(_metadata, ruleset_fd);\n+\tASSERT_EQ(0, close(ruleset_fd));\n+\n+\tEXPECT_EQ(0, test_chmod(file1, 0644));\n+\tEXPECT_EQ(0, test_fchmod(file_fd, 0644));\n+\tEXPECT_EQ(0, test_chmod(file2, 0400));\n+\tEXPECT_EQ(0, test_chmod(dir1, 0700));\n+\n+\tEXPECT_EQ(0, test_chown(file1, -1, 0));\n+\tEXPECT_EQ(0, test_fchown(file_fd, -1, 0));\n+\tEXPECT_EQ(0, test_lchown(file1, -1, 0));\n+\n+\tEXPECT_EQ(0, test_utimensat(file1));\n+\tEXPECT_EQ(0, test_utimensat_now(file1));\n+\n+\tEXPECT_EQ(0, test_setxattr(file1, \"user.test\", \"a\", 1));\n+\tEXPECT_EQ(0, test_getxattr(file1, \"user.test\", NULL, 0));\n+\tEXPECT_EQ(0, test_listxattr(file1, NULL, 0));\n+\tEXPECT_EQ(0, test_removexattr(file1, \"user.test\"));\n+\n+\tEXPECT_EQ(0, test_stat(file1, \u0026statbuf));\n+\tEXPECT_EQ(0, test_fstat(file_fd, \u0026statbuf));\n+\tEXPECT_EQ(0, test_stat(dir1, \u0026statbuf));\n+\n+\tASSERT_EQ(0, close(file_fd));\n+}\n+\n+TEST_F_FORK(layout1, write_metadata)\n+{\n+\tint file_fd, file2_fd, trunc_fd;\n+\tint ruleset_fd;\n+\tconst char *const file1 = file1_s1d1;\n+\tconst char *const file2 = file2_s1d1;\n+\tconst char *const trunc_file = file1_s1d2;\n+\tconst char *const dir1 = dir_s1d1;\n+\tstruct stat statbuf;\n+\tconst struct rule rules[] = {\n+\t\t{\n+\t\t\t.path = file1,\n+\t\t\t.access = LANDLOCK_ACCESS_FS_WRITE_FILE |\n+\t\t\t\t  LANDLOCK_ACCESS_FS_WRITE_METADATA,\n+\t\t},\n+\t\t{\n+\t\t\t.path = file2,\n+\t\t\t.access = LANDLOCK_ACCESS_FS_READ_FILE |\n+\t\t\t\t  LANDLOCK_ACCESS_FS_WRITE_FILE,\n+\t\t},\n+\t\t{\n+\t\t\t.path = dir1,\n+\t\t\t.access = ACCESS_RW,\n+\t\t},\n+\t\t{},\n+\t};\n+\n+\truleset_fd = create_ruleset(_metadata, ACCESS_RW |\n+\t\t\t\t    LANDLOCK_ACCESS_FS_WRITE_METADATA, rules);\n+\tASSERT_LE(0, ruleset_fd);\n+\tfile_fd = open(file1, O_WRONLY | O_CLOEXEC);\n+\tASSERT_LE(0, file_fd);\n+\tfile2_fd = open(file2, O_RDWR | O_CLOEXEC);\n+\tASSERT_LE(0, file2_fd);\n+\ttrunc_fd = open(trunc_file, O_RDWR | O_CLOEXEC);\n+\tASSERT_LE(0, trunc_fd);\n+\n+\t/*\n+\t * Arm the setuid bit for the implicit clearing tests below:\n+\t * writing or truncating a setuid file clears that bit when the\n+\t * caller has no CAP_FSETID, which is the case here because\n+\t * tests run without capabilities (see disable_caps() in\n+\t * prepare_layout()).\n+\t */\n+\tASSERT_EQ(0, fchmod(file2_fd, 04666));\n+\tASSERT_EQ(0, fchmod(trunc_fd, 04666));\n+\n+\tenforce_ruleset(_metadata, ruleset_fd);\n+\tASSERT_EQ(0, close(ruleset_fd));\n+\n+\t/* file1 has WRITE_METADATA: allowed */\n+\tEXPECT_EQ(0, test_chmod(file1, 0644));\n+\tEXPECT_EQ(0, test_fchmod(file_fd, 0644));\n+\tEXPECT_EQ(0, test_chown(file1, -1, 0));\n+\tEXPECT_EQ(0, test_fchown(file_fd, -1, 0));\n+\tEXPECT_EQ(0, test_lchown(file1, -1, 0));\n+\tEXPECT_EQ(0, test_utimensat(file1));\n+\tEXPECT_EQ(0, test_utimensat_now(file1));\n+\tEXPECT_EQ(0, test_setxattr(file1, \"user.test\", \"a\", 1));\n+\tEXPECT_EQ(0, test_removexattr(file1, \"user.test\"));\n+\n+\t/*\n+\t * Writing is not an explicit metadata change: implicit timestamp\n+\t * updates and the implicit setuid-bit clearing are allowed\n+\t * without WRITE_METADATA.\n+\t */\n+\tEXPECT_EQ(1, write(file2_fd, \"a\", 1));\n+\tASSERT_EQ(0, fstat(file2_fd, \u0026statbuf));\n+\tEXPECT_EQ(0, statbuf.st_mode \u0026 S_ISUID);\n+\n+\t/* file2 does not have WRITE_METADATA: denied */\n+\tEXPECT_EQ(EACCES, test_chmod(file2, 0400));\n+\tEXPECT_EQ(EACCES, test_chown(file2, -1, 0));\n+\tEXPECT_EQ(EACCES, test_lchown(file2, -1, 0));\n+\tEXPECT_EQ(EACCES, test_utimensat(file2));\n+\tEXPECT_EQ(EACCES, test_utimensat_now(file2));\n+\tEXPECT_EQ(EACCES, test_setxattr(file2, \"user.test\", \"a\", 1));\n+\tEXPECT_EQ(EACCES, test_removexattr(file2, \"user.test\"));\n+\n+\t/* dir1 does not have WRITE_METADATA: denied */\n+\tEXPECT_EQ(EACCES, test_chmod(dir1, 0700));\n+\tEXPECT_EQ(EACCES, test_chown(dir1, -1, 0));\n+\n+\t/*\n+\t * Truncating a setuid file implicitly clears the setuid bit as\n+\t * well: this must not require WRITE_METADATA, which trunc_file\n+\t * does not have.\n+\t */\n+\tEXPECT_EQ(0, ftruncate(trunc_fd, 0));\n+\tASSERT_EQ(0, fstat(trunc_fd, \u0026statbuf));\n+\tEXPECT_EQ(0, statbuf.st_mode \u0026 S_ISUID);\n+\n+\tASSERT_EQ(0, close(file_fd));\n+\tASSERT_EQ(0, close(file2_fd));\n+\tASSERT_EQ(0, close(trunc_fd));\n+}\n+\n+TEST_F_FORK(layout1, read_metadata)\n+{\n+\tint file_fd;\n+\tint ruleset_fd;\n+\tconst char *const file1 = file1_s1d1;\n+\tconst char *const file2 = file2_s1d1;\n+\tconst char *const dir1 = dir_s1d1;\n+\tstruct stat statbuf;\n+\tconst struct rule rules[] = {\n+\t\t{\n+\t\t\t.path = file1,\n+\t\t\t.access = LANDLOCK_ACCESS_FS_READ_FILE |\n+\t\t\t\t  LANDLOCK_ACCESS_FS_READ_METADATA,\n+\t\t},\n+\t\t{\n+\t\t\t.path = file2,\n+\t\t\t.access = LANDLOCK_ACCESS_FS_READ_FILE |\n+\t\t\t\t  LANDLOCK_ACCESS_FS_WRITE_FILE,\n+\t\t},\n+\t\t{\n+\t\t\t.path = dir1,\n+\t\t\t.access = ACCESS_RW,\n+\t\t},\n+\t\t{},\n+\t};\n+\n+\truleset_fd = create_ruleset(_metadata, ACCESS_RW |\n+\t\t\t\t    LANDLOCK_ACCESS_FS_READ_METADATA, rules);\n+\tASSERT_LE(0, ruleset_fd);\n+\n+\tASSERT_EQ(0, setxattr(file1, \"user.test\", \"a\", 1, 0));\n+\tASSERT_EQ(0, setxattr(file2, \"user.test\", \"a\", 1, 0));\n+\n+\tfile_fd = open(file1, O_RDONLY | O_CLOEXEC);\n+\tASSERT_LE(0, file_fd);\n+\n+\tenforce_ruleset(_metadata, ruleset_fd);\n+\tASSERT_EQ(0, close(ruleset_fd));\n+\n+\t/* file1 has READ_METADATA: allowed */\n+\tEXPECT_EQ(0, test_stat(file1, \u0026statbuf));\n+\tEXPECT_EQ(0, test_fstat(file_fd, \u0026statbuf));\n+\tEXPECT_EQ(0, test_getxattr(file1, \"user.test\", NULL, 0));\n+\tEXPECT_EQ(0, test_listxattr(file1, NULL, 0));\n+\n+\t/* file2 does not have READ_METADATA: denied */\n+\tEXPECT_EQ(EACCES, test_stat(file2, \u0026statbuf));\n+\tEXPECT_EQ(EACCES, test_getxattr(file2, \"user.test\", NULL, 0));\n+\tEXPECT_EQ(EACCES, test_listxattr(file2, NULL, 0));\n+\t/* dir1 does not have READ_METADATA: denied */\n+\tEXPECT_EQ(EACCES, test_stat(dir1, \u0026statbuf));\n+\n+\tASSERT_EQ(0, close(file_fd));\n+}\n+\n+/* Invokes ioctl(FS_IOC_GETFLAGS) and returns its errno or 0. */\n+static int test_getflags(int fd, unsigned int *const flags)\n+{\n+\tif (ioctl(fd, FS_IOC_GETFLAGS, flags) \u003c 0)\n+\t\treturn errno;\n+\treturn 0;\n+}\n+\n+/* Invokes ioctl(FS_IOC_SETFLAGS) and returns its errno or 0. */\n+static int test_setflags(int fd, const unsigned int flags)\n+{\n+\tunsigned int flags_ = flags;\n+\n+\tif (ioctl(fd, FS_IOC_SETFLAGS, \u0026flags_) \u003c 0)\n+\t\treturn errno;\n+\treturn 0;\n+}\n+\n+#ifndef __NR_file_getattr\n+#define __NR_file_getattr 468\n+#endif\n+#ifndef __NR_file_setattr\n+#define __NR_file_setattr 469\n+#endif\n+\n+/* Invokes file_getattr(2) and returns its errno or 0. */\n+static int test_file_getattr(int dfd, const char *const path,\n+\t\t\t     struct file_attr *const fattr,\n+\t\t\t     const unsigned int at_flags)\n+{\n+\tif (syscall(__NR_file_getattr, dfd, path, fattr, sizeof(*fattr),\n+\t\t    at_flags) \u003c 0)\n+\t\treturn errno;\n+\treturn 0;\n+}\n+\n+/* Invokes file_setattr(2) and returns its errno or 0. */\n+static int test_file_setattr(int dfd, const char *const path,\n+\t\t\t     struct file_attr *const fattr,\n+\t\t\t     const unsigned int at_flags)\n+{\n+\tif (syscall(__NR_file_setattr, dfd, path, fattr, sizeof(*fattr),\n+\t\t    at_flags) \u003c 0)\n+\t\treturn errno;\n+\treturn 0;\n+}\n+\n+TEST_F_FORK(layout1, fileattr)\n+{\n+\tconst struct rule rules[] = {\n+\t\t{\n+\t\t\t.path = file1_s1d1,\n+\t\t\t.access = LANDLOCK_ACCESS_FS_READ_METADATA |\n+\t\t\t\t  LANDLOCK_ACCESS_FS_WRITE_METADATA,\n+\t\t},\n+\t\t{},\n+\t};\n+\tstruct file_attr fattr;\n+\tunsigned int flags;\n+\tint fd, fd2, ruleset_fd;\n+\n+\truleset_fd = create_ruleset(\n+\t\t_metadata,\n+\t\tLANDLOCK_ACCESS_FS_READ_METADATA |\n+\t\t\tLANDLOCK_ACCESS_FS_WRITE_METADATA,\n+\t\trules);\n+\tASSERT_LE(0, ruleset_fd);\n+\n+\tfd = open(file1_s1d1, O_RDONLY | O_CLOEXEC);\n+\tASSERT_LE(0, fd);\n+\n+\tenforce_ruleset(_metadata, ruleset_fd);\n+\tASSERT_EQ(0, close(ruleset_fd));\n+\n+\t/* Allowed file: FS_IOC_GETFLAGS */\n+\tflags = 0;\n+\tEXPECT_EQ(0, test_getflags(fd, \u0026flags));\n+\tEXPECT_EQ(0, flags \u0026 FS_NODUMP_FL);\n+\n+\t/* Allowed file: FS_IOC_SETFLAGS */\n+\tEXPECT_EQ(0, test_setflags(fd, FS_NODUMP_FL));\n+\tflags = 0;\n+\tEXPECT_EQ(0, test_getflags(fd, \u0026flags));\n+\tEXPECT_EQ(FS_NODUMP_FL, flags \u0026 FS_NODUMP_FL);\n+\tEXPECT_EQ(0, test_setflags(fd, 0));\n+\n+\t/* Allowed file: file_getattr(2), with a path and with AT_EMPTY_PATH */\n+\tmemset(\u0026fattr, 0, sizeof(fattr));\n+\tEXPECT_EQ(0, test_file_getattr(AT_FDCWD, file1_s1d1, \u0026fattr, 0));\n+\tEXPECT_EQ(0, fattr.fa_xflags \u0026 FS_XFLAG_NODUMP);\n+\tmemset(\u0026fattr, 0, sizeof(fattr));\n+\tEXPECT_EQ(0, test_file_getattr(fd, NULL, \u0026fattr, AT_EMPTY_PATH));\n+\n+\t/* Allowed file: file_setattr(2), with a path and with AT_EMPTY_PATH */\n+\tmemset(\u0026fattr, 0, sizeof(fattr));\n+\tfattr.fa_xflags = FS_XFLAG_NODUMP;\n+\tEXPECT_EQ(0, test_file_setattr(AT_FDCWD, file1_s1d1, \u0026fattr, 0));\n+\tmemset(\u0026fattr, 0, sizeof(fattr));\n+\tEXPECT_EQ(0, test_file_getattr(AT_FDCWD, file1_s1d1, \u0026fattr, 0));\n+\tEXPECT_EQ(FS_XFLAG_NODUMP, fattr.fa_xflags \u0026 FS_XFLAG_NODUMP);\n+\tmemset(\u0026fattr, 0, sizeof(fattr));\n+\tfattr.fa_xflags = 0;\n+\tEXPECT_EQ(0, test_file_setattr(fd, NULL, \u0026fattr, AT_EMPTY_PATH));\n+\n+\t/* Non-allowed file: FS_IOC_GETFLAGS and FS_IOC_SETFLAGS */\n+\tfd2 = open(file2_s1d1, O_RDONLY | O_CLOEXEC);\n+\tASSERT_LE(0, fd2);\n+\tEXPECT_EQ(EACCES, test_getflags(fd2, \u0026flags));\n+\tEXPECT_EQ(EACCES, test_setflags(fd2, FS_NODUMP_FL));\n+\n+\t/* Non-allowed file: file_getattr(2) and file_setattr(2) */\n+\tmemset(\u0026fattr, 0, sizeof(fattr));\n+\tEXPECT_EQ(EACCES, test_file_getattr(AT_FDCWD, file2_s1d1, \u0026fattr, 0));\n+\tfattr.fa_xflags = FS_XFLAG_NODUMP;\n+\tEXPECT_EQ(EACCES, test_file_setattr(AT_FDCWD, file2_s1d1, \u0026fattr, 0));\n+\n+\tASSERT_EQ(0, close(fd));\n+\tASSERT_EQ(0, close(fd2));\n+}\n+\n+TEST_F_FORK(layout1, fileattr_write_only)\n+{\n+\tconst struct rule rules[] = {\n+\t\t{\n+\t\t\t.path = file1_s1d1,\n+\t\t\t.access = LANDLOCK_ACCESS_FS_WRITE_METADATA,\n+\t\t},\n+\t\t{},\n+\t};\n+\tunsigned int flags;\n+\tint fd, ruleset_fd;\n+\n+\truleset_fd = create_ruleset(_metadata,\n+\t\t\t\t    LANDLOCK_ACCESS_FS_WRITE_METADATA, rules);\n+\tASSERT_LE(0, ruleset_fd);\n+\n+\tfd = open(file1_s1d1, O_RDONLY | O_CLOEXEC);\n+\tASSERT_LE(0, fd);\n+\n+\tenforce_ruleset(_metadata, ruleset_fd);\n+\tASSERT_EQ(0, close(ruleset_fd));\n+\n+\t/*\n+\t * WRITE_METADATA alone must be enough to set flags: the kernel-side\n+\t * read of the old flags must not require READ_METADATA.\n+\t */\n+\tEXPECT_EQ(0, test_setflags(fd, FS_NODUMP_FL));\n+\tflags = 0;\n+\t/* READ_METADATA is not handled: reading is allowed. */\n+\tEXPECT_EQ(0, test_getflags(fd, \u0026flags));\n+\tEXPECT_EQ(FS_NODUMP_FL, flags \u0026 FS_NODUMP_FL);\n+\tEXPECT_EQ(0, test_setflags(fd, 0));\n+\n+\tASSERT_EQ(0, close(fd));\n+}\n+\n+TEST_F_FORK(layout2_overlay, fileattr)\n+{\n+\tconst struct rule rules[] = {\n+\t\t{\n+\t\t\t.path = MERGE_DATA,\n+\t\t\t.access = LANDLOCK_ACCESS_FS_READ_METADATA |\n+\t\t\t\t  LANDLOCK_ACCESS_FS_WRITE_METADATA,\n+\t\t},\n+\t\t{},\n+\t};\n+\tunsigned int flags;\n+\tint fd, fd2, ruleset_fd;\n+\n+\tif (self-\u003eskip_test)\n+\t\tSKIP(return, \"overlayfs is not supported (test)\");\n+\n+\truleset_fd = create_ruleset(\n+\t\t_metadata,\n+\t\tLANDLOCK_ACCESS_FS_READ_METADATA |\n+\t\t\tLANDLOCK_ACCESS_FS_WRITE_METADATA,\n+\t\trules);\n+\tASSERT_LE(0, ruleset_fd);\n+\n+\tenforce_ruleset(_metadata, ruleset_fd);\n+\tASSERT_EQ(0, close(ruleset_fd));\n+\n+\t/*\n+\t * The overlay mount was created before the ruleset was enforced\n+\t * (i.e. as an administrator): the internal forwards to the real\n+\t * paths must not interfere with the allowed accesses below.\n+\t */\n+\tfd = open(merge_fl1, O_RDONLY | O_CLOEXEC);\n+\tASSERT_LE(0, fd);\n+\n+\tflags = 0;\n+\tEXPECT_EQ(0, test_getflags(fd, \u0026flags));\n+\tEXPECT_EQ(0, flags \u0026 FS_NODUMP_FL);\n+\t/* Copies the file up and sets the flag on the upper real file. */\n+\tEXPECT_EQ(0, test_setflags(fd, FS_NODUMP_FL));\n+\tflags = 0;\n+\tEXPECT_EQ(0, test_getflags(fd, \u0026flags));\n+\tEXPECT_EQ(FS_NODUMP_FL, flags \u0026 FS_NODUMP_FL);\n+\tEXPECT_EQ(0, test_setflags(fd, 0));\n+\n+\tASSERT_EQ(0, close(fd));\n+\n+\t/* Non-allowed path: raw lower tmpfs path, outside of MERGE_DATA. */\n+\tfd2 = open(lower_fl1, O_RDONLY | O_CLOEXEC);\n+\tASSERT_LE(0, fd2);\n+\tEXPECT_EQ(EACCES, test_getflags(fd2, \u0026flags));\n+\tEXPECT_EQ(EACCES, test_setflags(fd2, FS_NODUMP_FL));\n+\tASSERT_EQ(0, close(fd2));\n+\n+\t/*\n+\t * Removes the copied-up file to keep the upper tree in the state\n+\t * expected by FIXTURE_TEARDOWN_PARENT().\n+\t */\n+\tEXPECT_EQ(0, remove_path(merge_fl1));\n+}\n+\n+/*\n+ * A landlocked process cannot change the mount topology with mount(2),\n+ * even with CAP_SYS_ADMIN (see hook_sb_mount()).  An overlay filesystem\n+ * can therefore not be mounted this way by a restricted process.\n+ */\n+TEST_F_FORK(layout1, overlay_mount_denied)\n+{\n+\tconst char lower_dir[] = TMP_DIR \"/ovl-lower\";\n+\tconst char upper_dir[] = TMP_DIR \"/ovl-upper\";\n+\tconst char work_dir[] = TMP_DIR \"/ovl-work\";\n+\tconst char merge_dir[] = TMP_DIR \"/ovl-merge\";\n+\tchar mount_data[256];\n+\tconst struct rule rules[] = {\n+\t\t{\n+\t\t\t.path = merge_dir,\n+\t\t\t.access = LANDLOCK_ACCESS_FS_READ_METADATA |\n+\t\t\t\t  LANDLOCK_ACCESS_FS_WRITE_METADATA,\n+\t\t},\n+\t\t{},\n+\t};\n+\tint ruleset_fd;\n+\n+\tASSERT_EQ(0, mkdir(lower_dir, 0700));\n+\tASSERT_EQ(0, mkdir(upper_dir, 0700));\n+\tASSERT_EQ(0, mkdir(work_dir, 0700));\n+\tASSERT_EQ(0, mkdir(merge_dir, 0700));\n+\n+\tsnprintf(mount_data, sizeof(mount_data),\n+\t\t \"lowerdir=%s,upperdir=%s,workdir=%s\", lower_dir, upper_dir,\n+\t\t work_dir);\n+\n+\truleset_fd = create_ruleset(\n+\t\t_metadata,\n+\t\tLANDLOCK_ACCESS_FS_READ_METADATA |\n+\t\t\tLANDLOCK_ACCESS_FS_WRITE_METADATA,\n+\t\trules);\n+\tASSERT_LE(0, ruleset_fd);\n+\n+\tenforce_ruleset(_metadata, ruleset_fd);\n+\tASSERT_EQ(0, close(ruleset_fd));\n+\n+\tset_cap(_metadata, CAP_SYS_ADMIN);\n+\tEXPECT_EQ(-1, mount(\"overlay\", merge_dir, \"overlay\", 0, mount_data));\n+\tEXPECT_EQ(EPERM, errno);\n+\tclear_cap(_metadata, CAP_SYS_ADMIN);\n+\n+\tEXPECT_EQ(0, rmdir(lower_dir));\n+\tEXPECT_EQ(0, rmdir(upper_dir));\n+\tEXPECT_EQ(0, rmdir(work_dir));\n+\tEXPECT_EQ(0, rmdir(merge_dir));\n+}\n+\n TEST_HARNESS_MAIN\ndiff --git a/tools/testing/selftests/landlock/trace_fs_test.c b/tools/testing/selftests/landlock/trace_fs_test.c\nindex 64014ade3a0e9..97506d249c4f1 100644\n--- a/tools/testing/selftests/landlock/trace_fs_test.c\n+++ b/tools/testing/selftests/landlock/trace_fs_test.c\n@@ -252,7 +252,8 @@ TEST_F(trace_fs, add_rule_path_beneath)\n TEST_F(trace_fs, add_rule_path_beneath_escaped_path_overflow)\n {\n \tstatic const char access_prefix[] = \"execute|write_file|read_file|\";\n-\tstatic const char access_suffix[] = \"|ioctl_dev|resolve_unix\";\n+\tstatic const char access_suffix[] =\n+\t\t\"|ioctl_dev|resolve_unix|read_metadata|write_metadata\";\n \tstruct landlock_ruleset_attr ruleset_attr = {\n \t\t.handled_access_fs = LANDLOCK_ACCESS_FS_READ_FILE,\n \t};\n"
}

2/1 2026/10/15 15:55 agent patch-evaluator
2m Model:
core

Args:
null

Results:
{
  "EnableConfigs": [
    "SECURITY_LANDLOCK",
    "SECURITY_PATH",
    "SECURITY",
    "FS_POSIX_ACL"
  ],
  "FocusSymbols": [
    "hook_path_setattr",
    "hook_path_file_setattr",
    "hook_path_file_getattr",
    "hook_path_setxattr",
    "hook_path_getxattr",
    "hook_path_listxattr",
    "hook_path_removexattr",
    "hook_path_set_acl",
    "hook_path_get_acl",
    "hook_path_remove_acl",
    "vfs_fileattr_set",
    "vfs_fileattr_get",
    "__notify_change"
  ],
  "Reasoning": "The patch series introduces Landlock ABI v13 support for controlling file and directory metadata access via two new access rights (LANDLOCK_ACCESS_FS_READ_METADATA and LANDLOCK_ACCESS_FS_WRITE_METADATA). To support path-based metadata access control, the series refactors multiple core VFS interfaces (notify_change, vfs_setxattr, vfs_getxattr, vfs_fileattr_get/set, posix_acl operations) and transitions LSM hooks from inode-based to struct path-based hooks across core VFS, Landlock, and other LSMs. These changes affect reachable core VFS and security subsystem paths and warrant fuzzing.",
  "WorthFuzzing": true
}

Instruction:
You are an expert Linux kernel maintainer and security engineer.
Your job is to review a provided patch series and evaluate whether it warrants fuzzing with syzkaller.

IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in
your workspace. Do NOT rely on internal assumptions. You must actively use your code access
tools to inspect the actual source code, callers, and surrounding context.

================================================================================
1. CORE TRIAGE PHILOSOPHY
================================================================================
The goal of patch fuzzing is to discover crashes, regressions, exposed latent bugs,
and newly triggered assertions introduced by the patch series.

- REACHABILITY IS THE PRIMARY GATE:
  Fuzzing can only discover bugs in code that can actually execute in standard virtualized
  environments (GCE or QEMU, utilizing software-emulated devices like USB gadgets, netdev, tun/tap).
  If the modified code is structurally unreachable (see Section 2), it MUST NOT be fuzzed,
  regardless of whether it adds assertions or complex logic.

- DO NOT BLINDLY TRUST "NO FUNCTIONAL CHANGE" (NFCI) OR "REFACTORING" CLAIMS:
  Patch authors routinely label changes as "cleanups", "refactorings", or state
  "No functional change intended". Do NOT take these claims at face value.
  Code refactorings that rearrange logic, introduce helper functions, or alter state management
  in core subsystems frequently introduce subtle semantic shifts or uncover latent kernel bugs.
  If reachable executable code is modified or refactored, it MUST be fuzzed.

- NEW OR MODIFIED ASSERTIONS IN REACHABLE CODE MUST BE FUZZED:
  When a patch introduces or modifies runtime checks or assertions (e.g., WARN_ON*, VM_WARN_ON*,
  BUG_ON*, lockdep_assert*) in reachable code paths, it enforces new or stricter invariants.
  Even if the author believes the invariant always holds, fuzzing is essential to verify whether
  an unusual sequence of operations can violate it.

================================================================================
2. WHEN TO RETURN WorthFuzzing=false (NEGATIVE CRITERIA)
================================================================================
Return WorthFuzzing=false ONLY IF all modified code falls strictly into one or more of these categories:

- Non-kernel and non-executable changes:
  * Modifications to Documentation/, comments, or spelling fixes.
  * User-space directories, self-tests, samples, or scripts (e.g., tools/, samples/, scripts/, usr/)
    that do not affect the compiled kernel image (vmlinux) or kernel modules.
  * Purely decorative logging (e.g., message strings in pr_err, printk, dev_info) or tracepoints
    that do not alter control flow or data structures.
  * Build system or Kconfig changes that do not alter compiled C logic.
- Structurally unreachable hardware:
  * Vendor-specific PCIe switches, SmartNICs, or GPU drivers (e.g., mlxsw, pds_core, qed,
    ionic, amdgpu) requiring physical ASIC/PCIe cards not emulated in standard QEMU.
- Unreachable execution paths:
  * Driver teardown callbacks (.remove, .shutdown, pci_unregister_driver) executed only during
    physical PCI hot-unplug or manual sysfs driver unbinding.
  * Code paths exclusive to architectures other than the target architecture.

================================================================================
3. WHEN TO RETURN WorthFuzzing=true (POSITIVE CRITERIA)
================================================================================
Return WorthFuzzing=true whenever the patch touches reachable executable code, including:
- Core Subsystems:
  * Any logic modifications in memory management (mm/), synchronization/locking (kernel/locking/),
    BPF, scheduler, core networking, VFS, or syscall handling.
- Refactorings and Code Cleanups:
  * Any restructuring of reachable data structures, helper abstractions, or algorithm flows.
- Runtime Assertions and Defensive Checks:
  * Any introduction or alteration of assertions (WARN_ON*, VM_WARN_ON*, BUG_ON*, etc.) in reachable paths.
- Reachable Drivers and Protocols:
  * Drivers accessible via virtual buses (virtio, USB gadget, loopback, netlink, binder, sockets, etc.).

================================================================================
4. EXTRACTING FocusSymbols (PREVENTING DILUTION)
================================================================================
When WorthFuzzing=true, you must extract specific kernel functions into FocusSymbols to guide the fuzzer:

- AVOID UBIQUITOUS LIFECYCLE HOT-PATHS:
  Do NOT list generic, ubiquitous functions called by almost every program in the corpus
  (including, but not limited to: general memory allocators and deallocators, page fault
  and trap handlers, or core synchronization primitives; this is not an exhaustive list).
  Listing ubiquitous functions causes the fuzzer to classify thousands of unrelated tests as "focused",
  which severely dilutes fuzzing effort away from the actual changes.

- TARGET SPECIFIC FEATURE LOGIC AND ENTRYPOINTS:
  List functions that specifically implement the logic being added or altered, or direct API entrypoints
  for the subsystem feature under review.

- HANDLING STATIC INLINE FUNCTIONS IN HEADERS (.h):
  Compiler-inlined static functions (such as static inlines in mm/*.h or include/linux/*.h) lack
  distinct symbol addresses in vmlinux and cannot be targeted directly by symbol coverage filters.
  If the changes are primarily in static inline helpers, identify non-static, feature-specific caller
  functions in .c files that exercise them (avoiding ubiquitous lifecycle wrappers).

================================================================================
5. IDENTIFYING EnableConfigs
================================================================================
Identify any specific CONFIG_ options required to properly compile and reach the modified code:
- Inspect Kconfig files and #ifdef guards; do not make assumptions.
- Check "depends on" lines in Kconfig to include any non-standard parent subsystem configs needed.
- Strip any 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4").
Prefer calling several tools at the same time to save round-trips.


Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.

Prompt:
Target architecture: amd64

For your convenience, here is the diff of the changes:
commit 014a9caffbc22fe4a10d9464410d1aade02103dc
Author: syz-cluster <triage@syzkaller.com>
Date:   Thu Oct 15 15:55:15 2026 +0000

    syz-cluster: applied patch under review

diff --git a/Documentation/bpf/fs_kfuncs.rst b/Documentation/bpf/fs_kfuncs.rst
index 8762c3233a3d1..9586dbbbf177c 100644
--- a/Documentation/bpf/fs_kfuncs.rst
+++ b/Documentation/bpf/fs_kfuncs.rst
@@ -18,4 +18,4 @@ To avoid recursions, these kfuncs follow the following rules:
 1. These kfuncs are only permitted from BPF LSM function.
 2. These kfuncs should not call into other LSM hooks, i.e. security_*(). For
    example, ``bpf_get_file_xattr()`` does not use ``vfs_getxattr()``, because
-   the latter calls LSM hook ``security_inode_getxattr``.
+   the latter calls LSM hook ``security_path_getxattr``.
diff --git a/Documentation/userspace-api/landlock.rst b/Documentation/userspace-api/landlock.rst
index 3d45b956b6407..62fe39a8b61e6 100644
--- a/Documentation/userspace-api/landlock.rst
+++ b/Documentation/userspace-api/landlock.rst
@@ -87,7 +87,9 @@ to be explicit about the denied-by-default access rights.
             LANDLOCK_ACCESS_FS_REFER |
             LANDLOCK_ACCESS_FS_TRUNCATE |
             LANDLOCK_ACCESS_FS_IOCTL_DEV |
-            LANDLOCK_ACCESS_FS_RESOLVE_UNIX,
+            LANDLOCK_ACCESS_FS_RESOLVE_UNIX |
+            LANDLOCK_ACCESS_FS_READ_METADATA |
+            LANDLOCK_ACCESS_FS_WRITE_METADATA,
         .handled_access_net =
             LANDLOCK_ACCESS_NET_BIND_TCP |
             LANDLOCK_ACCESS_NET_CONNECT_TCP |
@@ -159,6 +161,10 @@ version, and only use the available subset of access rights:
         ruleset_attr.handled_permissions &=
             ~(LANDLOCK_PERMISSION_NAMESPACE_USE |
               LANDLOCK_PERMISSION_CAPABILITY_USE);
+        /* Removes metadata rights for ABI < 13 */
+        ruleset_attr.handled_access_fs &=
+            ~(LANDLOCK_ACCESS_FS_READ_METADATA |
+              LANDLOCK_ACCESS_FS_WRITE_METADATA);
     }
 
 This enables the creation of an inclusive ruleset that will contain our rules.
@@ -669,6 +675,45 @@ for writing, sidestepping the ``LANDLOCK_ACCESS_FS_TRUNCATE`` right.
 
 The truncate right is associated with the opened file (see below).
 
+File metadata
+-------------
+
+The ``LANDLOCK_ACCESS_FS_READ_METADATA`` right governs reading file and
+directory metadata: :manpage:`stat(2)` and friends,
+:manpage:`getxattr(2)`, :manpage:`listxattr(2)` and friends, and POSIX ACL
+reads.
+
+The ``LANDLOCK_ACCESS_FS_WRITE_METADATA`` right governs explicit changes to
+file and directory metadata: :manpage:`chmod(2)` and friends,
+:manpage:`chown(2)` and friends, :manpage:`utimensat(2)`,
+:manpage:`setxattr(2)`, :manpage:`removexattr(2)` and friends, and POSIX ACL
+changes.  Both rights apply to files and directories alike.
+
+Implicit metadata changes performed by the kernel are not restricted by
+``LANDLOCK_ACCESS_FS_WRITE_METADATA``: reading a file may update its access
+time, writing a file updates its modification and change times and may change
+the file size, and writing to or truncating a file with a set-user-ID or
+set-group-ID bit clears these bits.  File size changes through
+:manpage:`truncate(2)` and friends are governed by
+``LANDLOCK_ACCESS_FS_TRUNCATE`` instead.  Metadata change requests that do
+not change any attribute (e.g. :manpage:`chown(2)` with owner and group
+``-1``) are not restricted either.
+
+.. warning::
+
+   Many programs read metadata as part of reading file contents or listing
+   directories (e.g. calling :manpage:`stat(2)` before or after
+   :manpage:`open(2)`), and do not expect such calls to fail with
+   ``EACCES``.  Most of the time, ``LANDLOCK_ACCESS_FS_READ_METADATA``
+   should therefore be granted together with
+   ``LANDLOCK_ACCESS_FS_READ_FILE`` and ``LANDLOCK_ACCESS_FS_READ_DIR``.
+   Conversely, denying only ``LANDLOCK_ACCESS_FS_READ_FILE`` or
+   ``LANDLOCK_ACCESS_FS_READ_DIR`` does not hide metadata: it remains
+   readable through :manpage:`stat(2)` and friends unless
+   ``LANDLOCK_ACCESS_FS_READ_METADATA`` is denied as well.  Tailored
+   programs that do not read metadata at all can still deny this right to
+   further restrict their sandbox.
+
 Rights associated with file descriptors
 ---------------------------------------
 
diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
index 11c70888f38be..71da9235ed49e 100644
--- a/drivers/base/devtmpfs.c
+++ b/drivers/base/devtmpfs.c
@@ -284,13 +284,14 @@ static int handle_create(const char *nodename, umode_t mode, kuid_t uid,
 			dev->devt, NULL);
 	if (!err) {
 		struct iattr newattrs;
+		struct path attr_path = { .mnt = path.mnt, .dentry = dentry };
 
 		newattrs.ia_mode = mode;
 		newattrs.ia_uid = uid;
 		newattrs.ia_gid = gid;
 		newattrs.ia_valid = ATTR_MODE|ATTR_UID|ATTR_GID;
 		inode_lock(d_inode(dentry));
-		notify_change(&nop_mnt_idmap, dentry, &newattrs, NULL);
+		notify_change(&attr_path, &newattrs, NULL);
 		inode_unlock(d_inode(dentry));
 
 		/* mark as kernel-created inode */
@@ -380,6 +381,7 @@ static int handle_remove(const char *nodename, struct device *dev)
 	inode = d_inode(dentry);
 	if (dev_mynode(dev, inode)) {
 		struct iattr newattrs;
+		struct path attr_path = { .mnt = parent.mnt, .dentry = dentry };
 		/*
 		 * before unlinking this node, reset permissions
 		 * of possible references like hardlinks
@@ -390,7 +392,7 @@ static int handle_remove(const char *nodename, struct device *dev)
 		newattrs.ia_valid =
 			ATTR_UID|ATTR_GID|ATTR_MODE;
 		inode_lock(d_inode(dentry));
-		notify_change(&nop_mnt_idmap, dentry, &newattrs, NULL);
+		notify_change(&attr_path, &newattrs, NULL);
 		inode_unlock(d_inode(dentry));
 		err = vfs_unlink(&nop_mnt_idmap, d_inode(parent.dentry),
 				 dentry, NULL);
diff --git a/drivers/block/zloop.c b/drivers/block/zloop.c
index 8f485ef515577..b385192aacb11 100644
--- a/drivers/block/zloop.c
+++ b/drivers/block/zloop.c
@@ -715,7 +715,7 @@ static int zloop_record_safe_wps(struct zloop_device *zlo)
 
 		if (!zloop_zone_is_active(zone))
 			continue;
-		ret = vfs_setxattr(file_mnt_idmap(file), file_dentry(file),
+		ret = vfs_setxattr(&file->f_path,
 				"user.zloop.wp", &zone->wp, sizeof(zone->wp), 0);
 		if (ret) {
 			pr_err("%pg: failed to record write pointer (%d)\n",
@@ -1417,7 +1417,7 @@ static void zloop_forget_cache(struct zloop_device *zlo)
 		if (!zloop_zone_is_active(zone))
 			continue;
 
-		ret = vfs_getxattr(file_mnt_idmap(file), file_dentry(file),
+		ret = vfs_getxattr(&file->f_path,
 				"user.zloop.wp", &old_wp, sizeof(old_wp));
 		if (ret == -ENODATA) {
 			old_wp = 0;
diff --git a/fs/attr.c b/fs/attr.c
index 9706d370f34af..c8bf69e609713 100644
--- a/fs/attr.c
+++ b/fs/attr.c
@@ -397,35 +397,10 @@ int may_setattr(const struct mnt_idmap *idmap, struct inode *inode,
 }
 EXPORT_SYMBOL(may_setattr);
 
-/**
- * notify_change - modify attributes of a filesystem object
- * @idmap:	idmap of the mount the inode was found from
- * @dentry:	object affected
- * @attr:	new attributes
- * @delegated_inode: returns inode, if the inode is delegated
- *
- * The caller must hold the i_rwsem exclusively on the affected object.
- *
- * If notify_change discovers a delegation in need of breaking,
- * it will return -EWOULDBLOCK and return a reference to the inode in
- * delegated_inode.  The caller should then break the delegation and
- * retry.  Because breaking a delegation may take a long time, the
- * caller should drop the i_rwsem before doing so.
- *
- * Alternatively, a caller may pass NULL for delegated_inode.  This may
- * be appropriate for callers that expect the underlying filesystem not
- * to be NFS exported.  Also, passing NULL is fine for callers holding
- * the file open for write, as there can be no conflicting delegation in
- * that case.
- *
- * If the inode has been found through an idmapped mount the idmap of
- * the vfsmount must be passed through @idmap. This function will then
- * take care to map the inode according to @idmap before checking
- * permissions. On non-idmapped mounts or if permission checking is to be
- * performed on the raw inode simply pass @nop_mnt_idmap.
- */
-int notify_change(const struct mnt_idmap *idmap, struct dentry *dentry,
-		  struct iattr *attr, struct delegated_inode *delegated_inode)
+static int do_notify_change(const struct path *const path,
+			    const struct mnt_idmap *const idmap,
+			    struct dentry *const dentry, struct iattr *attr,
+			    struct delegated_inode *delegated_inode)
 {
 	struct inode *inode = dentry->d_inode;
 	umode_t mode = inode->i_mode;
@@ -537,9 +512,16 @@ int notify_change(const struct mnt_idmap *idmap, struct dentry *dentry,
 	    !vfsgid_valid(i_gid_into_vfsgid(idmap, inode)))
 		return -EOVERFLOW;
 
-	error = security_inode_setattr(idmap, dentry, attr);
-	if (error)
-		return error;
+	/*
+	 * The LSM checks are only performed for user-facing calls (i.e.
+	 * when @path is set): internal forwards, e.g. from a stacking
+	 * filesystem, were already checked on the user-facing path.
+	 */
+	if (path) {
+		error = security_path_setattr(path, attr);
+		if (error)
+			return error;
+	}
 
 	/*
 	 * If ATTR_DELEG is set, then these attributes are being set on
@@ -564,4 +546,65 @@ int notify_change(const struct mnt_idmap *idmap, struct dentry *dentry,
 
 	return error;
 }
+
+/**
+ * __notify_change - modify attributes of a filesystem object, without
+ *                   the LSM check
+ * @idmap:	idmap of the mount the inode was found from
+ * @dentry:	object affected
+ * @attr:	new attributes
+ * @delegated_inode: returns inode, if the inode is delegated
+ *
+ * Like notify_change(), but no security_path_setattr() hook is called:
+ * this is the variant to use for internal forwards, where the LSM
+ * checks were already performed on the user-facing path.
+ *
+ * The caller must hold the i_rwsem exclusively on the affected object.
+ *
+ * If the inode has been found through an idmapped mount, permission
+ * checking is performed based on @idmap.  This function will take care
+ * to map the inode according to the idmap before checking permissions.
+ *
+ * Return: 0 on success, or a negative error on failure.
+ */
+int __notify_change(const struct mnt_idmap *idmap, struct dentry *dentry,
+		    struct iattr *attr, struct delegated_inode *delegated_inode)
+{
+	return do_notify_change(NULL, idmap, dentry, attr, delegated_inode);
+}
+EXPORT_SYMBOL(__notify_change);
+
+/**
+ * notify_change - modify attributes of a filesystem object
+ * @path:	object affected
+ * @attr:	new attributes
+ * @delegated_inode: returns inode, if the inode is delegated
+ *
+ * The caller must hold the i_rwsem exclusively on the affected object.
+ *
+ * If notify_change discovers a delegation in need of breaking,
+ * it will return -EWOULDBLOCK and return a reference to the inode in
+ * delegated_inode.  The caller should then break the delegation and
+ * retry.  Because breaking a delegation may take a long time, the
+ * caller should drop the i_rwsem before doing so.
+ *
+ * Alternatively, a caller may pass NULL for delegated_inode.  This may
+ * be appropriate for callers that expect the underlying filesystem not
+ * to be NFS exported.  Also, passing NULL is fine for callers holding
+ * the file open for write, as there can be no conflicting delegation in
+ * that case.
+ *
+ * If the inode has been found through an idmapped mount, permission
+ * checking is performed based on the idmap of @path->mnt.  This function
+ * will take care to map the inode according to the idmap before
+ * checking permissions.
+ *
+ * Return: 0 on success, or a negative error on failure.
+ */
+int notify_change(const struct path *path, struct iattr *attr,
+		  struct delegated_inode *delegated_inode)
+{
+	return do_notify_change(path, mnt_idmap(path->mnt), path->dentry, attr,
+				delegated_inode);
+}
 EXPORT_SYMBOL(notify_change);
diff --git a/fs/bpf_fs_kfuncs.c b/fs/bpf_fs_kfuncs.c
index 35ccd98a4de64..ab25344e6205d 100644
--- a/fs/bpf_fs_kfuncs.c
+++ b/fs/bpf_fs_kfuncs.c
@@ -566,10 +566,10 @@ BTF_SET_START(d_inode_locked_hooks)
 BTF_ID(func, bpf_lsm_inode_post_removexattr)
 BTF_ID(func, bpf_lsm_inode_post_setattr)
 BTF_ID(func, bpf_lsm_inode_post_setxattr)
-BTF_ID(func, bpf_lsm_inode_removexattr)
+BTF_ID(func, bpf_lsm_path_removexattr)
 BTF_ID(func, bpf_lsm_inode_rmdir)
-BTF_ID(func, bpf_lsm_inode_setattr)
-BTF_ID(func, bpf_lsm_inode_setxattr)
+BTF_ID(func, bpf_lsm_path_setattr)
+BTF_ID(func, bpf_lsm_path_setxattr)
 BTF_ID(func, bpf_lsm_inode_unlink)
 BTF_SET_END(d_inode_locked_hooks)
 
diff --git a/fs/cachefiles/xattr.c b/fs/cachefiles/xattr.c
index 8ebb713482e3e..8bafb4dc1f745 100644
--- a/fs/cachefiles/xattr.c
+++ b/fs/cachefiles/xattr.c
@@ -40,7 +40,6 @@ struct cachefiles_vol_xattr {
 int cachefiles_preset_object_xattr(struct cachefiles_object *object, struct file *file)
 {
 	struct cachefiles_xattr *buf;
-	struct dentry *dentry = file->f_path.dentry;
 	unsigned int len = object->cookie->aux_len;
 	int ret;
 
@@ -55,7 +54,7 @@ int cachefiles_preset_object_xattr(struct cachefiles_object *object, struct file
 	if (ret == 0) {
 		ret = mnt_want_write_file(file);
 		if (ret == 0) {
-			ret = vfs_setxattr(&nop_mnt_idmap, dentry,
+			ret = vfs_setxattr(&file->f_path,
 					   cachefiles_xattr_cache, buf,
 					   sizeof(struct cachefiles_xattr) + len, 0);
 			mnt_drop_write_file(file);
@@ -91,7 +90,6 @@ int cachefiles_preset_object_xattr(struct cachefiles_object *object, struct file
 int cachefiles_set_object_xattr(struct cachefiles_object *object)
 {
 	struct cachefiles_xattr *buf;
-	struct dentry *dentry;
 	struct file *file = object->file;
 	unsigned int len = object->cookie->aux_len;
 	uoff_t object_size = object->cookie->object_size;
@@ -99,7 +97,6 @@ int cachefiles_set_object_xattr(struct cachefiles_object *object)
 
 	if (!file)
 		return -ESTALE;
-	dentry = file->f_path.dentry;
 
 	_enter("%x,#%d", object->debug_id, len);
 
@@ -121,7 +118,7 @@ int cachefiles_set_object_xattr(struct cachefiles_object *object)
 	if (ret == 0) {
 		ret = mnt_want_write_file(file);
 		if (ret == 0) {
-			ret = vfs_setxattr(&nop_mnt_idmap, dentry,
+			ret = vfs_setxattr(&file->f_path,
 					   cachefiles_xattr_cache, buf,
 					   sizeof(struct cachefiles_xattr) + len, 0);
 			mnt_drop_write_file(file);
@@ -160,7 +157,6 @@ int cachefiles_set_object_xattr(struct cachefiles_object *object)
 int cachefiles_check_auxdata(struct cachefiles_object *object, struct file *file)
 {
 	struct cachefiles_xattr *buf;
-	struct dentry *dentry = file->f_path.dentry;
 	struct inode *inode = file_inode(file);
 	unsigned int len = object->cookie->aux_len, tlen;
 	const void *p = fscache_get_aux(object->cookie);
@@ -177,7 +173,7 @@ int cachefiles_check_auxdata(struct cachefiles_object *object, struct file *file
 
 	xlen = cachefiles_inject_read_error();
 	if (xlen == 0)
-		xlen = vfs_getxattr(&nop_mnt_idmap, dentry, cachefiles_xattr_cache, buf, tlen);
+		xlen = vfs_getxattr(&file->f_path, cachefiles_xattr_cache, buf, tlen);
 	if (xlen != tlen) {
 		if (xlen < 0) {
 			ret = xlen;
@@ -226,6 +222,7 @@ int cachefiles_remove_object_xattr(struct cachefiles_cache *cache,
 				   struct cachefiles_object *object,
 				   struct dentry *dentry)
 {
+	struct path path = { .mnt = cache->mnt, .dentry = dentry };
 	int ret;
 
 	trace_cachefiles_coherency(object, d_inode(dentry)->i_ino, 0, NULL, 0,
@@ -235,8 +232,7 @@ int cachefiles_remove_object_xattr(struct cachefiles_cache *cache,
 	if (ret == 0) {
 		ret = mnt_want_write(cache->mnt);
 		if (ret == 0) {
-			ret = vfs_removexattr(&nop_mnt_idmap, dentry,
-					      cachefiles_xattr_cache);
+			ret = vfs_removexattr(&path, cachefiles_xattr_cache);
 			mnt_drop_write(cache->mnt);
 		}
 	}
@@ -282,7 +278,8 @@ bool cachefiles_set_volume_xattr(struct cachefiles_volume *volume)
 	struct cachefiles_vol_xattr *buf;
 	unsigned int len = volume->vcookie->coherency_len;
 	const void *p = volume->vcookie->coherency;
-	struct dentry *dentry = volume->dentry;
+	struct path path = { .mnt = volume->cache->mnt,
+			     .dentry = volume->dentry };
 	int ret;
 
 	_enter("%x,#%d", volume->vcookie->debug_id, len);
@@ -298,22 +295,21 @@ bool cachefiles_set_volume_xattr(struct cachefiles_volume *volume)
 	if (ret == 0) {
 		ret = mnt_want_write(volume->cache->mnt);
 		if (ret == 0) {
-			ret = vfs_setxattr(&nop_mnt_idmap, dentry,
-					   cachefiles_xattr_cache,
+			ret = vfs_setxattr(&path, cachefiles_xattr_cache,
 					   buf, len, 0);
 			mnt_drop_write(volume->cache->mnt);
 		}
 	}
 	if (ret < 0) {
-		trace_cachefiles_vfs_error(NULL, d_inode(dentry), ret,
+		trace_cachefiles_vfs_error(NULL, d_inode(path.dentry), ret,
 					   cachefiles_trace_setxattr_error);
-		trace_cachefiles_vol_coherency(volume, d_inode(dentry)->i_ino,
+		trace_cachefiles_vol_coherency(volume, d_inode(path.dentry)->i_ino,
 					       cachefiles_coherency_vol_set_fail);
 		if (ret != -ENOMEM)
 			cachefiles_io_error(
 				volume->cache, "Failed to set xattr with error %d", ret);
 	} else {
-		trace_cachefiles_vol_coherency(volume, d_inode(dentry)->i_ino,
+		trace_cachefiles_vol_coherency(volume, d_inode(path.dentry)->i_ino,
 					       cachefiles_coherency_vol_set_ok);
 	}
 
@@ -328,9 +324,10 @@ bool cachefiles_set_volume_xattr(struct cachefiles_volume *volume)
 int cachefiles_check_volume_xattr(struct cachefiles_volume *volume)
 {
 	struct cachefiles_vol_xattr *buf;
-	struct dentry *dentry = volume->dentry;
 	unsigned int len = volume->vcookie->coherency_len;
 	const void *p = volume->vcookie->coherency;
+	struct path path = { .mnt = volume->cache->mnt,
+			     .dentry = volume->dentry };
 	enum cachefiles_coherency_trace why;
 	ssize_t xlen;
 	int ret = -ESTALE;
@@ -344,11 +341,11 @@ int cachefiles_check_volume_xattr(struct cachefiles_volume *volume)
 
 	xlen = cachefiles_inject_read_error();
 	if (xlen == 0)
-		xlen = vfs_getxattr(&nop_mnt_idmap, dentry, cachefiles_xattr_cache, buf, len);
+		xlen = vfs_getxattr(&path, cachefiles_xattr_cache, buf, len);
 	if (xlen != len) {
 		if (xlen < 0) {
 			ret = xlen;
-			trace_cachefiles_vfs_error(NULL, d_inode(dentry), xlen,
+			trace_cachefiles_vfs_error(NULL, d_inode(path.dentry), xlen,
 						   cachefiles_trace_getxattr_error);
 			if (xlen == -EIO)
 				cachefiles_io_error(
@@ -365,7 +362,7 @@ int cachefiles_check_volume_xattr(struct cachefiles_volume *volume)
 		ret = 0;
 	}
 
-	trace_cachefiles_vol_coherency(volume, d_inode(dentry)->i_ino, why);
+	trace_cachefiles_vol_coherency(volume, d_inode(path.dentry)->i_ino, why);
 	kfree(buf);
 	_leave(" = %d", ret);
 	return ret;
diff --git a/fs/coredump.c b/fs/coredump.c
index b25ef2ffbdeed..57787e8c699f5 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -1060,7 +1060,7 @@ static bool coredump_file(struct core_name *cn, struct coredump_params *cprm,
 	}
 	if (!(file->f_mode & FMODE_CAN_WRITE))
 		return false;
-	if (do_truncate(idmap, file->f_path.dentry, 0, 0, file))
+	if (do_truncate(&file->f_path, 0, 0, file))
 		return false;
 
 	cprm->file = no_free_ptr(file);
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index 48e520960d665..e894ce435b5bb 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -732,7 +732,8 @@ upper_size_to_lower_size(struct ecryptfs_crypt_stat *crypt_stat,
  */
 static int __ecryptfs_truncate(struct dentry *dentry, const struct iattr *ia)
 {
-	struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry);
+	struct path lower_path = ecryptfs_lower_path(dentry);
+	struct dentry *lower_dentry = lower_path.dentry;
 	struct inode *inode = d_inode(dentry);
 	struct ecryptfs_crypt_stat *crypt_stat;
 	loff_t i_size = i_size_read(inode);
@@ -821,7 +822,7 @@ static int __ecryptfs_truncate(struct dentry *dentry, const struct iattr *ia)
 set_size:
 	lower_ia.ia_valid |= ATTR_SIZE;
 	inode_lock(d_inode(lower_dentry));
-	rc = notify_change(&nop_mnt_idmap, lower_dentry, &lower_ia, NULL);
+	rc = notify_change(&lower_path, &lower_ia, NULL);
 	inode_unlock(d_inode(lower_dentry));
 out:
 	ecryptfs_put_lower_file(inode);
@@ -873,7 +874,6 @@ static int ecryptfs_setattr(const struct mnt_idmap *idmap,
 			    struct dentry *dentry, struct iattr *ia)
 {
 	struct inode *inode = d_inode(dentry);
-	struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry);
 	struct inode *lower_inode = ecryptfs_inode_to_lower(inode);
 	struct ecryptfs_crypt_stat *crypt_stat;
 	int rc;
@@ -925,14 +925,14 @@ static int ecryptfs_setattr(const struct mnt_idmap *idmap,
 	if (ia->ia_valid & ATTR_SIZE) {
 		rc = __ecryptfs_truncate(dentry, ia);
 	} else {
+		struct path lower_path = ecryptfs_lower_path(dentry);
 		struct iattr lower_ia;
 
 		ecryptfs_iattr_to_lower(&lower_ia, ia);
 
-		inode_lock(d_inode(lower_dentry));
-		rc = notify_change(&nop_mnt_idmap, lower_dentry, &lower_ia,
-				NULL);
-		inode_unlock(d_inode(lower_dentry));
+		inode_lock(d_inode(lower_path.dentry));
+		rc = notify_change(&lower_path, &lower_ia, NULL);
+		inode_unlock(d_inode(lower_path.dentry));
 	}
 out:
 	fsstack_copy_attr_all(inode, lower_inode);
@@ -991,17 +991,17 @@ ecryptfs_setxattr(struct dentry *dentry, struct inode *inode,
 		  size_t size, int flags)
 {
 	int rc;
-	struct dentry *lower_dentry;
+	struct path lower_path;
 	struct inode *lower_inode;
 
-	lower_dentry = ecryptfs_dentry_to_lower(dentry);
-	lower_inode = d_inode(lower_dentry);
+	lower_path = ecryptfs_lower_path(dentry);
+	lower_inode = d_inode(lower_path.dentry);
 	if (!(lower_inode->i_opflags & IOP_XATTR)) {
 		rc = -EOPNOTSUPP;
 		goto out;
 	}
 	inode_lock(lower_inode);
-	rc = __vfs_setxattr_locked(&nop_mnt_idmap, lower_dentry, name, value, size, flags, NULL);
+	rc = __vfs_setxattr_locked(&lower_path, name, value, size, flags, NULL);
 	inode_unlock(lower_inode);
 	if (!rc && inode)
 		fsstack_copy_attr_all(inode, lower_inode);
@@ -1075,7 +1075,7 @@ static int ecryptfs_removexattr(struct dentry *dentry, struct inode *inode,
 
 static int ecryptfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
 {
-	return vfs_fileattr_get(ecryptfs_dentry_to_lower(dentry), fa);
+	return __vfs_fileattr_get(ecryptfs_dentry_to_lower(dentry), fa);
 }
 
 static int ecryptfs_fileattr_set(const struct mnt_idmap *idmap,
@@ -1084,7 +1084,7 @@ static int ecryptfs_fileattr_set(const struct mnt_idmap *idmap,
 	struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry);
 	int rc;
 
-	rc = vfs_fileattr_set(&nop_mnt_idmap, lower_dentry, fa);
+	rc = __vfs_fileattr_set(&nop_mnt_idmap, lower_dentry, fa);
 	fsstack_copy_attr_all(d_inode(dentry), d_inode(lower_dentry));
 
 	return rc;
@@ -1093,8 +1093,9 @@ static int ecryptfs_fileattr_set(const struct mnt_idmap *idmap,
 static struct posix_acl *ecryptfs_get_acl(const struct mnt_idmap *idmap,
 					  struct dentry *dentry, int type)
 {
-	return vfs_get_acl(idmap, ecryptfs_dentry_to_lower(dentry),
-			   posix_acl_xattr_name(type));
+	struct path lower_path = ecryptfs_lower_path(dentry);
+
+	return vfs_get_acl(&lower_path, posix_acl_xattr_name(type));
 }
 
 static int ecryptfs_set_acl(const struct mnt_idmap *idmap,
@@ -1102,11 +1103,10 @@ static int ecryptfs_set_acl(const struct mnt_idmap *idmap,
 			    int type)
 {
 	int rc;
-	struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry);
-	struct inode *lower_inode = d_inode(lower_dentry);
+	struct path lower_path = ecryptfs_lower_path(dentry);
+	struct inode *lower_inode = d_inode(lower_path.dentry);
 
-	rc = vfs_set_acl(&nop_mnt_idmap, lower_dentry,
-			 posix_acl_xattr_name(type), acl);
+	rc = vfs_set_acl(&lower_path, posix_acl_xattr_name(type), acl);
 	if (!rc)
 		fsstack_copy_attr_all(d_inode(dentry), lower_inode);
 	return rc;
diff --git a/fs/exfat/file.c b/fs/exfat/file.c
index 1386149916bbe..51ed20e27429b 100644
--- a/fs/exfat/file.c
+++ b/fs/exfat/file.c
@@ -551,8 +551,7 @@ static int exfat_ioctl_set_attributes(struct file *file, u32 __user *user_attr)
 	 * out the RO attribute for checking by the security
 	 * module, just because it maps to a file mode.
 	 */
-	err = security_inode_setattr(file_mnt_idmap(file),
-				     file->f_path.dentry, &ia);
+	err = security_path_setattr(&file->f_path, &ia);
 	if (err)
 		goto out_unlock_inode;
 
diff --git a/fs/fat/file.c b/fs/fat/file.c
index d4f1b360b9743..5178561906dd1 100644
--- a/fs/fat/file.c
+++ b/fs/fat/file.c
@@ -92,8 +92,7 @@ static int fat_ioctl_set_attributes(struct file *file, u32 __user *user_attr)
 	 * out the RO attribute for checking by the security
 	 * module, just because it maps to a file mode.
 	 */
-	err = security_inode_setattr(file_mnt_idmap(file),
-				     file->f_path.dentry, &ia);
+	err = security_path_setattr(&file->f_path, &ia);
 	if (err)
 		goto out_unlock_inode;
 
diff --git a/fs/file_attr.c b/fs/file_attr.c
index 833e03810b24c..ea56843450f70 100644
--- a/fs/file_attr.c
+++ b/fs/file_attr.c
@@ -75,27 +75,46 @@ void fileattr_fill_flags(struct file_kattr *fa, u32 flags)
 EXPORT_SYMBOL(fileattr_fill_flags);
 
 /**
- * vfs_fileattr_get - retrieve miscellaneous file attributes
+ * __vfs_fileattr_get - retrieve miscellaneous file attributes
  * @dentry:	the object to retrieve from
  * @fa:		fileattr pointer
  *
- * Call i_op->fileattr_get() callback, if exists.
+ * Call i_op->fileattr_get() callback, if exists.  Unlike
+ * vfs_fileattr_get(), no security hook is called: this is the variant to
+ * use for internal forwards, where the LSM checks were already performed
+ * on the user-facing path (e.g. by a stacking filesystem).
  *
  * Return: 0 on success, or a negative error on failure.
  */
-int vfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
+int __vfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
 {
 	struct inode *inode = d_inode(dentry);
-	int error;
 
 	if (!inode->i_op->fileattr_get)
 		return -ENOIOCTLCMD;
 
-	error = security_inode_file_getattr(dentry, fa);
+	return inode->i_op->fileattr_get(dentry, fa);
+}
+EXPORT_SYMBOL(__vfs_fileattr_get);
+
+/**
+ * vfs_fileattr_get - retrieve miscellaneous file attributes
+ * @path:	the object to retrieve from
+ * @fa:		fileattr pointer
+ *
+ * Call i_op->fileattr_get() callback, if exists.
+ *
+ * Return: 0 on success, or a negative error on failure.
+ */
+int vfs_fileattr_get(const struct path *path, struct file_kattr *fa)
+{
+	int error;
+
+	error = security_path_file_getattr(path, fa);
 	if (error)
 		return error;
 
-	return inode->i_op->fileattr_get(dentry, fa);
+	return __vfs_fileattr_get(path->dentry, fa);
 }
 EXPORT_SYMBOL(vfs_fileattr_get);
 
@@ -254,24 +273,10 @@ static int fileattr_set_prepare(struct inode *inode,
 	return 0;
 }
 
-/**
- * vfs_fileattr_set - change miscellaneous file attributes
- * @idmap:	idmap of the mount
- * @dentry:	the object to change
- * @fa:		fileattr pointer
- *
- * After verifying permissions, call i_op->fileattr_set() callback, if
- * exists.
- *
- * Verifying attributes involves retrieving current attributes with
- * i_op->fileattr_get(), this also allows initializing attributes that have
- * not been set by the caller to current values.  Inode lock is held
- * thoughout to prevent racing with another instance.
- *
- * Return: 0 on success, or a negative error on failure.
- */
-int vfs_fileattr_set(const struct mnt_idmap *idmap, struct dentry *dentry,
-		     struct file_kattr *fa)
+static int do_vfs_fileattr_set(const struct path *const path,
+			       const struct mnt_idmap *const idmap,
+			       struct dentry *const dentry,
+			       struct file_kattr *const fa)
 {
 	struct inode *inode = d_inode(dentry);
 	struct file_kattr old_ma = {};
@@ -284,7 +289,7 @@ int vfs_fileattr_set(const struct mnt_idmap *idmap, struct dentry *dentry,
 		return -EPERM;
 
 	inode_lock(inode);
-	err = vfs_fileattr_get(dentry, &old_ma);
+	err = __vfs_fileattr_get(dentry, &old_ma);
 	if (!err) {
 		/* initialize missing bits from old_ma */
 		if (fa->flags_valid) {
@@ -300,9 +305,17 @@ int vfs_fileattr_set(const struct mnt_idmap *idmap, struct dentry *dentry,
 		err = fileattr_set_prepare(inode, &old_ma, fa);
 		if (err)
 			goto out;
-		err = security_inode_file_setattr(dentry, fa);
-		if (err)
-			goto out;
+		/*
+		 * The LSM checks are only performed for user-facing calls
+		 * (i.e. when @path is set): internal forwards, e.g. from a
+		 * stacking filesystem, were already checked on the
+		 * user-facing path.
+		 */
+		if (path) {
+			err = security_path_file_setattr(path, fa);
+			if (err)
+				goto out;
+		}
 		err = inode->i_op->fileattr_set(idmap, dentry, fa);
 		if (err)
 			goto out;
@@ -313,6 +326,48 @@ int vfs_fileattr_set(const struct mnt_idmap *idmap, struct dentry *dentry,
 	inode_unlock(inode);
 	return err;
 }
+
+/**
+ * __vfs_fileattr_set - change miscellaneous file attributes
+ * @idmap:	idmap of the mount
+ * @dentry:	the object to change
+ * @fa:		fileattr pointer
+ *
+ * After verifying permissions, call i_op->fileattr_set() callback, if
+ * exists.  Unlike vfs_fileattr_set(), no security hook is called: this is
+ * the variant to use for internal forwards, where the LSM checks were
+ * already performed on the user-facing path (e.g. by a stacking
+ * filesystem).
+ *
+ * Verifying attributes involves retrieving current attributes with
+ * i_op->fileattr_get(), this also allows initializing attributes that have
+ * not been set by the caller to current values.  Inode lock is held
+ * thoughout to prevent racing with another instance.
+ *
+ * Return: 0 on success, or a negative error on failure.
+ */
+int __vfs_fileattr_set(const struct mnt_idmap *idmap, struct dentry *dentry,
+		       struct file_kattr *fa)
+{
+	return do_vfs_fileattr_set(NULL, idmap, dentry, fa);
+}
+EXPORT_SYMBOL(__vfs_fileattr_set);
+
+/**
+ * vfs_fileattr_set - change miscellaneous file attributes
+ * @path:	the object to change
+ * @fa:		fileattr pointer
+ *
+ * After verifying permissions, call i_op->fileattr_set() callback, if
+ * exists.
+ *
+ * Return: 0 on success, or a negative error on failure.
+ */
+int vfs_fileattr_set(const struct path *path, struct file_kattr *fa)
+{
+	return do_vfs_fileattr_set(path, mnt_idmap(path->mnt), path->dentry,
+				   fa);
+}
 EXPORT_SYMBOL(vfs_fileattr_set);
 
 int ioctl_getflags(struct file *file, unsigned int __user *argp)
@@ -320,7 +375,7 @@ int ioctl_getflags(struct file *file, unsigned int __user *argp)
 	struct file_kattr fa = { .flags_valid = true }; /* hint only */
 	int err;
 
-	err = vfs_fileattr_get(file->f_path.dentry, &fa);
+	err = vfs_fileattr_get(&file->f_path, &fa);
 	if (!err)
 		err = put_user(fa.flags, argp);
 	return err;
@@ -328,8 +383,6 @@ int ioctl_getflags(struct file *file, unsigned int __user *argp)
 
 int ioctl_setflags(struct file *file, unsigned int __user *argp)
 {
-	const struct mnt_idmap *idmap = file_mnt_idmap(file);
-	struct dentry *dentry = file->f_path.dentry;
 	struct file_kattr fa = {};
 	unsigned int flags;
 	int err;
@@ -339,7 +392,7 @@ int ioctl_setflags(struct file *file, unsigned int __user *argp)
 		err = mnt_want_write_file(file);
 		if (!err) {
 			fileattr_fill_flags(&fa, flags);
-			err = vfs_fileattr_set(idmap, dentry, &fa);
+			err = vfs_fileattr_set(&file->f_path, &fa);
 			mnt_drop_write_file(file);
 		}
 	}
@@ -351,7 +404,7 @@ int ioctl_fsgetxattr(struct file *file, void __user *argp)
 	struct file_kattr fa = { .fsx_valid = true }; /* hint only */
 	int err;
 
-	err = vfs_fileattr_get(file->f_path.dentry, &fa);
+	err = vfs_fileattr_get(&file->f_path, &fa);
 	if (!err)
 		err = copy_fsxattr_to_user(&fa, argp);
 
@@ -360,8 +413,6 @@ int ioctl_fsgetxattr(struct file *file, void __user *argp)
 
 int ioctl_fssetxattr(struct file *file, void __user *argp)
 {
-	const struct mnt_idmap *idmap = file_mnt_idmap(file);
-	struct dentry *dentry = file->f_path.dentry;
 	struct file_kattr fa = {};
 	int err;
 
@@ -369,7 +420,7 @@ int ioctl_fssetxattr(struct file *file, void __user *argp)
 	if (!err) {
 		err = mnt_want_write_file(file);
 		if (!err) {
-			err = vfs_fileattr_set(idmap, dentry, &fa);
+			err = vfs_fileattr_set(&file->f_path, &fa);
 			mnt_drop_write_file(file);
 		}
 	}
@@ -416,7 +467,7 @@ SYSCALL_DEFINE5(file_getattr, int, dfd, const char __user *, filename,
 			return error;
 	}
 
-	error = vfs_fileattr_get(filepath.dentry, &fa);
+	error = vfs_fileattr_get(&filepath, &fa);
 	if (error == -ENOIOCTLCMD || error == -ENOTTY)
 		error = -EOPNOTSUPP;
 	if (error)
@@ -480,8 +531,7 @@ SYSCALL_DEFINE5(file_setattr, int, dfd, const char __user *, filename,
 
 	error = mnt_want_write(filepath.mnt);
 	if (!error) {
-		error = vfs_fileattr_set(mnt_idmap(filepath.mnt),
-					 filepath.dentry, &fa);
+		error = vfs_fileattr_set(&filepath, &fa);
 		if (error == -ENOIOCTLCMD || error == -ENOTTY)
 			error = -EOPNOTSUPP;
 		mnt_drop_write(filepath.mnt);
diff --git a/fs/inode.c b/fs/inode.c
index 702f2d5ef459c..ea557adbbd203 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -2356,8 +2356,7 @@ int dentry_needs_remove_privs(const struct mnt_idmap *idmap,
 	return mask;
 }
 
-static int __remove_privs(const struct mnt_idmap *idmap,
-			  struct dentry *dentry, int kill)
+static int __remove_privs(const struct path *path, int kill)
 {
 	struct iattr newattrs;
 
@@ -2366,7 +2365,7 @@ static int __remove_privs(const struct mnt_idmap *idmap,
 	 * Note we call this on write, so notify_change will not
 	 * encounter any conflicting delegations:
 	 */
-	return notify_change(idmap, dentry, &newattrs, NULL);
+	return notify_change(path, &newattrs, NULL);
 }
 
 static int file_remove_privs_flags(struct file *file, unsigned int flags)
@@ -2387,7 +2386,7 @@ static int file_remove_privs_flags(struct file *file, unsigned int flags)
 		if (flags & IOCB_NOWAIT)
 			return -EAGAIN;
 
-		error = __remove_privs(file_mnt_idmap(file), dentry, kill);
+		error = __remove_privs(&file->f_path, kill);
 	}
 
 	if (!error)
diff --git a/fs/internal.h b/fs/internal.h
index e833c7e6e14fb..050c35f75d4a7 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -304,20 +304,19 @@ int import_xattr_name(struct xattr_name *kname, const char __user *name);
 int may_write_xattr(const struct mnt_idmap *idmap, struct inode *inode);
 
 #ifdef CONFIG_FS_POSIX_ACL
-int do_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
-	       const char *acl_name, const void *kvalue, size_t size);
-ssize_t do_get_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
-		   const char *acl_name, void *kvalue, size_t size);
+int do_set_acl(const struct path *path, const char *acl_name,
+	       const void *kvalue, size_t size);
+ssize_t do_get_acl(const struct path *path, const char *acl_name,
+		   void *kvalue, size_t size);
 #else
-static inline int do_set_acl(const struct mnt_idmap *idmap,
-			     struct dentry *dentry, const char *acl_name,
+static inline int do_set_acl(const struct path *path, const char *acl_name,
 			     const void *kvalue, size_t size)
 {
 	return -EOPNOTSUPP;
 }
-static inline ssize_t do_get_acl(const struct mnt_idmap *idmap,
-				 struct dentry *dentry, const char *acl_name,
-				 void *kvalue, size_t size)
+static inline ssize_t do_get_acl(const struct path *path,
+				 const char *acl_name, void *kvalue,
+				 size_t size)
 {
 	return -EOPNOTSUPP;
 }
diff --git a/fs/namei.c b/fs/namei.c
index fd160bd7886fa..e43c552e1e96c 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -4335,7 +4335,7 @@ static int may_open(const struct mnt_idmap *idmap, const struct path *path,
 	return 0;
 }
 
-static int handle_truncate(const struct mnt_idmap *idmap, struct file *filp)
+static int handle_truncate(struct file *filp)
 {
 	const struct path *path = &filp->f_path;
 	struct inode *inode = path->dentry->d_inode;
@@ -4345,8 +4345,7 @@ static int handle_truncate(const struct mnt_idmap *idmap, struct file *filp)
 
 	error = security_file_truncate(filp);
 	if (!error) {
-		error = do_truncate(idmap, path->dentry, 0,
-				    ATTR_MTIME|ATTR_CTIME|ATTR_OPEN,
+		error = do_truncate(path, 0, ATTR_MTIME|ATTR_CTIME|ATTR_OPEN,
 				    filp);
 	}
 	put_write_access(inode);
@@ -4894,7 +4893,7 @@ static int do_open(struct nameidata *nd,
 	if (!error)
 		error = security_file_post_open(file, op->acc_mode);
 	if (!error && do_truncate)
-		error = handle_truncate(idmap, file);
+		error = handle_truncate(file);
 	if (unlikely(error > 0)) {
 		WARN_ON(1);
 		error = -EINVAL;
diff --git a/fs/nfsd/nfs4ctl.h b/fs/nfsd/nfs4ctl.h
index bcec4c4ef1d53..97ab3d4212aaa 100644
--- a/fs/nfsd/nfs4ctl.h
+++ b/fs/nfsd/nfs4ctl.h
@@ -38,7 +38,7 @@ int nfsd4_create_laundry_wq(void);
 void nfsd4_destroy_laundry_wq(void);
 bool nfsd_wait_for_delegreturn(struct svc_rqst *rqstp, struct inode *inode);
 
-extern int nfsd4_is_junction(struct dentry *dentry);
+extern int nfsd4_is_junction(const struct path *path);
 extern int register_cld_notifier(void);
 extern void unregister_cld_notifier(void);
 #ifdef CONFIG_NFSD_V4_2_INTER_SSC
@@ -68,7 +68,7 @@ static inline bool nfsd_wait_for_delegreturn(struct svc_rqst *rqstp,
 	return false;
 }
 
-static inline int nfsd4_is_junction(struct dentry *dentry)
+static inline int nfsd4_is_junction(const struct path *path)
 {
 	return 0;
 }
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 1de6c6d757c3e..400a429418794 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -10477,8 +10477,10 @@ bool nfsd4_vet_deleg_time(struct timespec64 *req, const struct timespec64 *orig,
 	return true;
 }
 
-static int cb_getattr_update_times(struct dentry *dentry, struct nfs4_delegation *dp)
+static int cb_getattr_update_times(const struct path *path,
+				   struct nfs4_delegation *dp)
 {
+	struct dentry *dentry = path->dentry;
 	struct inode *inode = d_inode(dentry);
 	struct nfs4_cb_fattr *ncf = &dp->dl_cb_fattr;
 	struct iattr attrs = { };
@@ -10508,7 +10510,7 @@ static int cb_getattr_update_times(struct dentry *dentry, struct nfs4_delegation
 
 	attrs.ia_valid |= ATTR_DELEG;
 	inode_lock(inode);
-	ret = notify_change(&nop_mnt_idmap, dentry, &attrs, NULL);
+	ret = notify_change(path, &attrs, NULL);
 	inode_unlock(inode);
 	return ret;
 }
@@ -10531,7 +10533,7 @@ static int cb_getattr_update_times(struct dentry *dentry, struct nfs4_delegation
  * caller must put the reference.
  */
 __be32
-nfsd4_deleg_getattr_conflict(struct svc_rqst *rqstp, struct dentry *dentry,
+nfsd4_deleg_getattr_conflict(struct svc_rqst *rqstp, const struct path *path,
 			     struct nfs4_delegation **pdp)
 {
 	struct nfsd_thread_local_info *ntli = rqstp->rq_private;
@@ -10539,7 +10541,7 @@ nfsd4_deleg_getattr_conflict(struct svc_rqst *rqstp, struct dentry *dentry,
 	struct nfs4_delegation *dp = NULL;
 	struct file_lease *fl;
 	struct nfs4_cb_fattr *ncf;
-	struct inode *inode = d_inode(dentry);
+	struct inode *inode = d_inode(path->dentry);
 	__be32 status;
 
 	ctx = locks_inode_context(inode);
@@ -10603,7 +10605,7 @@ nfsd4_deleg_getattr_conflict(struct svc_rqst *rqstp, struct dentry *dentry,
 		 * not update the file's metadata with the client's
 		 * modified size
 		 */
-		err = cb_getattr_update_times(dentry, dp);
+		err = cb_getattr_update_times(path, dp);
 		if (err) {
 			status = nfserrno(err);
 			goto out_status;
@@ -10789,7 +10791,7 @@ void nfsd_update_cmtime_attr(struct file *f, unsigned int flags)
 	};
 
 	inode_lock(inode);
-	ret = notify_change(&nop_mnt_idmap, f->f_path.dentry, &attr, NULL);
+	ret = notify_change(&f->f_path, &attr, NULL);
 	inode_unlock(inode);
 	if (ret)
 		pr_notice_ratelimited("nfsd: Unable to update timestamps on "
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 84161dbecd1cb..2a86b69b2ae9b 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -4083,7 +4083,7 @@ nfsd4_encode_fattr4(struct svc_rqst *rqstp, struct xdr_stream *xdr,
 	    (attrmask[1] & (FATTR4_WORD1_TIME_ACCESS |
 			    FATTR4_WORD1_TIME_MODIFY |
 			    FATTR4_WORD1_TIME_METADATA))) {
-		status = nfsd4_deleg_getattr_conflict(rqstp, dentry, &dp);
+		status = nfsd4_deleg_getattr_conflict(rqstp, &path, &dp);
 		if (status)
 			goto out;
 	}
diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h
index cd9294f024bb9..183123f0b91f2 100644
--- a/fs/nfsd/state.h
+++ b/fs/nfsd/state.h
@@ -1018,7 +1018,7 @@ static inline bool try_to_expire_client(struct nfs4_client *clp)
 }
 
 extern __be32 nfsd4_deleg_getattr_conflict(struct svc_rqst *rqstp,
-		struct dentry *dentry, struct nfs4_delegation **pdp);
+		const struct path *path, struct nfs4_delegation **pdp);
 
 struct nfsd4_get_dir_delegation;
 struct nfs4_delegation *nfsd_get_dir_deleg(struct nfsd4_compound_state *cstate,
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 56c49b5bc5bb7..eb7dee641612c 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -233,11 +233,13 @@ static int nfsd_lookup_parent(struct svc_rqst *rqstp, struct dentry *dparent, st
  */
 int nfsd_mountpoint(struct dentry *dentry, struct svc_export *exp)
 {
+	struct path path = { .mnt = exp->ex_path.mnt, .dentry = dentry };
+
 	if (!d_inode(dentry))
 		return 0;
 	if (exp->ex_flags & NFSEXP_V4ROOT)
 		return 1;
-	if (nfsd4_is_junction(dentry))
+	if (nfsd4_is_junction(&path))
 		return 1;
 	if (d_managed(dentry))
 		/*
@@ -455,7 +457,7 @@ nfsd_get_write_access(struct svc_fh *fhp)
 	return nfserrno(get_write_access(d_inode(fhp->fh_dentry)));
 }
 
-static int __nfsd_setattr(struct dentry *dentry, struct iattr *iap)
+static int __nfsd_setattr(const struct path *path, struct iattr *iap)
 {
 	int host_err;
 
@@ -475,7 +477,7 @@ static int __nfsd_setattr(struct dentry *dentry, struct iattr *iap)
 		if (iap->ia_size < 0)
 			return -EFBIG;
 
-		host_err = notify_change(&nop_mnt_idmap, dentry, &size_attr, NULL);
+		host_err = notify_change(path, &size_attr, NULL);
 		if (host_err)
 			return host_err;
 		iap->ia_valid &= ~ATTR_SIZE;
@@ -501,7 +503,7 @@ static int __nfsd_setattr(struct dentry *dentry, struct iattr *iap)
 	if (!(iap->ia_valid & ATTR_DELEG))
 		iap->ia_valid |= ATTR_CTIME;
 
-	return notify_change(&nop_mnt_idmap, dentry, iap, NULL);
+	return notify_change(path, iap, NULL);
 }
 
 /**
@@ -524,6 +526,7 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp,
 {
 	struct dentry	*dentry;
 	struct inode	*inode;
+	struct path	path;
 	struct iattr	*iap = attr->na_iattr;
 	int		accmode = NFSD_MAY_SATTR;
 	umode_t		ftype = 0;
@@ -569,6 +572,11 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp,
 	dentry = fhp->fh_dentry;
 	inode = d_inode(dentry);
 
+	path = (struct path){
+		.mnt	= fhp->fh_export->ex_path.mnt,
+		.dentry	= dentry,
+	};
+
 	nfsd_sanitize_attrs(inode, iap);
 
 	/*
@@ -612,14 +620,14 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp,
 		 * copy for every loop iteration.
 		 */
 		attrs = *iap;
-		host_err = __nfsd_setattr(dentry, &attrs);
+		host_err = __nfsd_setattr(&path, &attrs);
 		if (host_err != -EAGAIN || !retries--)
 			break;
 		if (!nfsd_wait_for_delegreturn(rqstp, inode))
 			break;
 	}
 	if (attr->na_seclabel && attr->na_seclabel->len)
-		attr->na_labelerr = security_inode_setsecctx(dentry,
+		attr->na_labelerr = security_path_setsecctx(&path,
 			attr->na_seclabel->data, attr->na_seclabel->len);
 	if (IS_ENABLED(CONFIG_FS_POSIX_ACL) && attr->na_dpacl) {
 		if (!S_ISDIR(inode->i_mode))
@@ -678,14 +686,14 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp,
 /**
  * nfsd4_is_junction - Test if an object could be an NFS junction
  *
- * @dentry: object to test
+ * @path: object to test
  *
- * Returns 1 if "dentry" appears to contain NFS junction information.
+ * Returns 1 if "path" appears to contain NFS junction information.
  * Otherwise 0 is returned.
  */
-int nfsd4_is_junction(struct dentry *dentry)
+int nfsd4_is_junction(const struct path *path)
 {
-	struct inode *inode = d_inode(dentry);
+	struct inode *inode = d_inode(path->dentry);
 
 	if (inode == NULL)
 		return 0;
@@ -693,8 +701,7 @@ int nfsd4_is_junction(struct dentry *dentry)
 		return 0;
 	if (!(inode->i_mode & S_ISVTX))
 		return 0;
-	if (vfs_getxattr(&nop_mnt_idmap, dentry, NFSD_JUNCTION_XATTR_NAME,
-			 NULL, 0) <= 0)
+	if (vfs_getxattr(path, NFSD_JUNCTION_XATTR_NAME, NULL, 0) <= 0)
 		return 0;
 	return 1;
 }
@@ -2646,19 +2653,20 @@ nfsd_getxattr(struct svc_rqst *rqstp, struct svc_fh *fhp, char *name,
 	__be32 err;
 	char *buf;
 	struct inode *inode;
-	struct dentry *dentry;
+	struct path path;
 
 	err = fh_verify(rqstp, fhp, 0, NFSD_MAY_READ);
 	if (err)
 		return err;
 
 	err = nfs_ok;
-	dentry = fhp->fh_dentry;
-	inode = d_inode(dentry);
+	path.mnt = fhp->fh_export->ex_path.mnt;
+	path.dentry = fhp->fh_dentry;
+	inode = d_inode(path.dentry);
 
 	inode_lock_shared(inode);
 
-	len = vfs_getxattr(&nop_mnt_idmap, dentry, name, NULL, 0);
+	len = vfs_getxattr(&path, name, NULL, 0);
 
 	/*
 	 * Zero-length attribute, just return.
@@ -2685,7 +2693,7 @@ nfsd_getxattr(struct svc_rqst *rqstp, struct svc_fh *fhp, char *name,
 		goto out;
 	}
 
-	len = vfs_getxattr(&nop_mnt_idmap, dentry, name, buf, len);
+	len = vfs_getxattr(&path, name, buf, len);
 	if (len <= 0) {
 		kvfree(buf);
 		buf = NULL;
@@ -2719,19 +2727,20 @@ nfsd_listxattr(struct svc_rqst *rqstp, struct svc_fh *fhp, char **bufp,
 	__be32 err;
 	char *buf;
 	struct inode *inode;
-	struct dentry *dentry;
+	struct path path;
 
 	err = fh_verify(rqstp, fhp, 0, NFSD_MAY_READ);
 	if (err)
 		return err;
 
-	dentry = fhp->fh_dentry;
-	inode = d_inode(dentry);
+	path.mnt = fhp->fh_export->ex_path.mnt;
+	path.dentry = fhp->fh_dentry;
+	inode = d_inode(path.dentry);
 	*lenp = 0;
 
 	inode_lock_shared(inode);
 
-	len = vfs_listxattr(dentry, NULL, 0);
+	len = vfs_listxattr(&path, NULL, 0);
 	if (len <= 0) {
 		err = nfsd_xattr_errno(len);
 		goto out;
@@ -2748,7 +2757,7 @@ nfsd_listxattr(struct svc_rqst *rqstp, struct svc_fh *fhp, char **bufp,
 		goto out;
 	}
 
-	len = vfs_listxattr(dentry, buf, len);
+	len = vfs_listxattr(&path, buf, len);
 	if (len <= 0) {
 		kvfree(buf);
 		err = nfsd_xattr_errno(len);
@@ -2781,6 +2790,7 @@ nfsd_removexattr(struct svc_rqst *rqstp, struct svc_fh *fhp, char *name)
 {
 	__be32 err;
 	int ret;
+	struct path path;
 
 	err = fh_verify(rqstp, fhp, 0, NFSD_MAY_WRITE);
 	if (err)
@@ -2790,16 +2800,17 @@ nfsd_removexattr(struct svc_rqst *rqstp, struct svc_fh *fhp, char *name)
 	if (ret)
 		return nfserrno(ret);
 
-	inode_lock(fhp->fh_dentry->d_inode);
+	path.mnt = fhp->fh_export->ex_path.mnt;
+	path.dentry = fhp->fh_dentry;
+	inode_lock(d_inode(path.dentry));
 	err = fh_fill_pre_attrs(fhp);
 	if (err != nfs_ok)
 		goto out_unlock;
-	ret = __vfs_removexattr_locked(&nop_mnt_idmap, fhp->fh_dentry,
-				       name, NULL);
+	ret = __vfs_removexattr_locked(&path, name, NULL);
 	err = nfsd_xattr_errno(ret);
 	fh_fill_post_attrs(fhp);
 out_unlock:
-	inode_unlock(fhp->fh_dentry->d_inode);
+	inode_unlock(d_inode(path.dentry));
 	fh_drop_write(fhp);
 
 	return err;
@@ -2811,6 +2822,7 @@ nfsd_setxattr(struct svc_rqst *rqstp, struct svc_fh *fhp, char *name,
 {
 	__be32 err;
 	int ret;
+	struct path path;
 
 	err = fh_verify(rqstp, fhp, 0, NFSD_MAY_WRITE);
 	if (err)
@@ -2819,16 +2831,17 @@ nfsd_setxattr(struct svc_rqst *rqstp, struct svc_fh *fhp, char *name,
 	ret = fh_want_write(fhp);
 	if (ret)
 		return nfserrno(ret);
-	inode_lock(fhp->fh_dentry->d_inode);
+	path.mnt = fhp->fh_export->ex_path.mnt;
+	path.dentry = fhp->fh_dentry;
+	inode_lock(d_inode(path.dentry));
 	err = fh_fill_pre_attrs(fhp);
 	if (err != nfs_ok)
 		goto out_unlock;
-	ret = __vfs_setxattr_locked(&nop_mnt_idmap, fhp->fh_dentry,
-				    name, buf, len, flags, NULL);
+	ret = __vfs_setxattr_locked(&path, name, buf, len, flags, NULL);
 	fh_fill_post_attrs(fhp);
 	err = nfsd_xattr_errno(ret);
 out_unlock:
-	inode_unlock(fhp->fh_dentry->d_inode);
+	inode_unlock(d_inode(path.dentry));
 	fh_drop_write(fhp);
 	return err;
 }
@@ -2967,7 +2980,7 @@ nfsd_get_case_info(struct dentry *dentry, bool *case_insensitive,
 	}
 	saved = override_creds(probe);
 
-	err = vfs_fileattr_get(cd, &fa);
+	err = __vfs_fileattr_get(cd, &fa);
 
 	put_cred(revert_creds(saved));
 out:
diff --git a/fs/ntfs/named_stream.c b/fs/ntfs/named_stream.c
index 95a3c05f98211..f0b577a6f7c3e 100644
--- a/fs/ntfs/named_stream.c
+++ b/fs/ntfs/named_stream.c
@@ -897,7 +897,7 @@ static int ntfs_stream_setattr_common(const struct mnt_idmap *idmap,
 			goto out;
 		}
 		if (base_attr.ia_valid)
-			err = notify_change(idmap, base_dentry, &base_attr,
+			err = __notify_change(idmap, base_dentry, &base_attr,
 					NULL);
 		else
 			err = 0;
diff --git a/fs/open.c b/fs/open.c
index bf398105f03a0..97a5f770fa045 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -36,10 +36,12 @@
 
 #include "internal.h"
 
-int do_truncate(const struct mnt_idmap *idmap, struct dentry *dentry,
-		loff_t length, unsigned int time_attrs, struct file *filp)
+int do_truncate(const struct path *path, loff_t length,
+		unsigned int time_attrs, struct file *filp)
 {
 	int ret;
+	const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
+	struct dentry *dentry = path->dentry;
 	struct iattr newattrs;
 
 	/* Not pretty: "inode->i_size" shouldn't really be signed. But it is. */
@@ -65,7 +67,7 @@ int do_truncate(const struct mnt_idmap *idmap, struct dentry *dentry,
 		return ret;
 
 	/* Note any delegations or leases have already been broken: */
-	ret = notify_change(idmap, dentry, &newattrs, NULL);
+	ret = notify_change(path, &newattrs, NULL);
 	inode_unlock(dentry->d_inode);
 	return ret;
 }
@@ -115,7 +117,7 @@ int vfs_truncate(const struct path *path, loff_t length)
 
 	error = security_path_truncate(path);
 	if (!error)
-		error = do_truncate(idmap, path->dentry, length, 0, NULL);
+		error = do_truncate(path, length, 0, NULL);
 
 put_write_and_out:
 	put_write_access(inode);
@@ -191,7 +193,7 @@ int do_ftruncate(struct file *file, loff_t length, unsigned int flags)
 		return error;
 
 	scoped_guard(super_write, inode->i_sb)
-		return do_truncate(file_mnt_idmap(file), dentry, length,
+		return do_truncate(&file->f_path, length,
 				   ATTR_MTIME | ATTR_CTIME, file);
 }
 
@@ -683,8 +685,7 @@ int chmod_common(const struct path *path, umode_t mode)
 		goto out_unlock;
 	newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
 	newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
-	error = notify_change(mnt_idmap(path->mnt), path->dentry,
-			      &newattrs, &delegated_inode);
+	error = notify_change(path, &newattrs, &delegated_inode);
 out_unlock:
 	inode_unlock(inode);
 	if (is_delegated(&delegated_inode)) {
@@ -822,8 +823,7 @@ int chown_common(const struct path *path, uid_t user, gid_t group)
 		from_vfsuid(idmap, fs_userns, newattrs.ia_vfsuid),
 		from_vfsgid(idmap, fs_userns, newattrs.ia_vfsgid));
 	if (!error)
-		error = notify_change(idmap, path->dentry, &newattrs,
-				      &delegated_inode);
+		error = notify_change(path, &newattrs, &delegated_inode);
 	inode_unlock(inode);
 	if (is_delegated(&delegated_inode)) {
 		error = break_deleg_wait(&delegated_inode);
diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c
index e963701b4c877..6dc241f195a66 100644
--- a/fs/overlayfs/copy_up.c
+++ b/fs/overlayfs/copy_up.c
@@ -83,7 +83,7 @@ int ovl_copy_xattr(struct super_block *sb, const struct path *oldpath, struct de
 	if (!old->d_inode->i_op->listxattr || !new->d_inode->i_op->listxattr)
 		return 0;
 
-	list_size = vfs_listxattr(old, NULL, 0);
+	list_size = vfs_listxattr(oldpath, NULL, 0);
 	if (list_size <= 0) {
 		if (list_size == -EOPNOTSUPP)
 			return 0;
@@ -94,7 +94,7 @@ int ovl_copy_xattr(struct super_block *sb, const struct path *oldpath, struct de
 	if (!buf)
 		return -ENOMEM;
 
-	list_size = vfs_listxattr(old, buf, list_size);
+	list_size = vfs_listxattr(oldpath, buf, list_size);
 	if (list_size <= 0) {
 		error = list_size;
 		goto out;
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index 70183d516e5e9..9e89aeabeaa85 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -392,7 +392,7 @@ static void ovl_idmap_posix_acl(const struct inode *realinode,
  * > and following it on overlayfs.
  * >
  * > Applying the same logic to acl: we do need to call the
- * > security_inode_getxattr() on the underlying fs, even if just want to
+ * > security_path_getxattr() on the underlying fs, even if just want to
  * > check permissions on overlay. This is currently not done, which is an
  * > inconsistency.
  * >
@@ -414,7 +414,7 @@ struct posix_acl *ovl_get_acl_path(const struct path *path,
 	if (noperm)
 		real_acl = get_inode_acl(realinode, posix_acl_type(acl_name));
 	else
-		real_acl = vfs_get_acl(idmap, path->dentry, acl_name);
+		real_acl = vfs_get_acl(path, acl_name);
 	if (IS_ERR_OR_NULL(real_acl))
 		return real_acl;
 
@@ -502,7 +502,7 @@ static int ovl_set_or_remove_acl(struct dentry *dentry, struct inode *inode,
 
 		ovl_path_lower(dentry, &realpath);
 		with_ovl_creds(dentry->d_sb)
-			real_acl = vfs_get_acl(mnt_idmap(realpath.mnt), realdentry, acl_name);
+			real_acl = vfs_get_acl(&realpath, acl_name);
 		if (IS_ERR(real_acl)) {
 			err = PTR_ERR(real_acl);
 			goto out;
@@ -607,47 +607,10 @@ static int ovl_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
 		return realinode->i_op->fiemap(realinode, fieinfo, start, len);
 }
 
-/*
- * Work around the fact that security_file_ioctl() takes a file argument.
- * Introducing security_inode_fileattr_get/set() hooks would solve this issue
- * properly.
- */
-static int ovl_security_fileattr(const struct path *realpath, struct file_kattr *fa,
-				 bool set)
-{
-	struct file *file;
-	unsigned int cmd;
-	int err;
-	unsigned int flags;
-
-	flags = O_RDONLY;
-	if (force_o_largefile())
-		flags |= O_LARGEFILE;
-
-	file = dentry_open(realpath, flags, current_cred());
-	if (IS_ERR(file))
-		return PTR_ERR(file);
-
-	if (set)
-		cmd = fa->fsx_valid ? FS_IOC_FSSETXATTR : FS_IOC_SETFLAGS;
-	else
-		cmd = fa->fsx_valid ? FS_IOC_FSGETXATTR : FS_IOC_GETFLAGS;
-
-	err = security_file_ioctl(file, cmd, 0);
-	fput(file);
-
-	return err;
-}
-
 int ovl_real_fileattr_set(const struct path *realpath, struct file_kattr *fa)
 {
-	int err;
-
-	err = ovl_security_fileattr(realpath, fa, true);
-	if (err)
-		return err;
-
-	return vfs_fileattr_set(mnt_idmap(realpath->mnt), realpath->dentry, fa);
+	return __vfs_fileattr_set(mnt_idmap(realpath->mnt), realpath->dentry,
+				  fa);
 }
 
 int ovl_fileattr_set(const struct mnt_idmap *idmap,
@@ -717,11 +680,7 @@ int ovl_real_fileattr_get(const struct path *realpath, struct file_kattr *fa)
 {
 	int err;
 
-	err = ovl_security_fileattr(realpath, fa, false);
-	if (err)
-		return err;
-
-	err = vfs_fileattr_get(realpath->dentry, fa);
+	err = __vfs_fileattr_get(realpath->dentry, fa);
 	if (err == -ENOIOCTLCMD)
 		err = -ENOTTY;
 	return err;
diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
index 53fbbe15c31df..230070f6caa99 100644
--- a/fs/overlayfs/overlayfs.h
+++ b/fs/overlayfs/overlayfs.h
@@ -206,7 +206,12 @@ static inline int ovl_do_notify_change(struct ovl_fs *ofs,
 				       struct dentry *upperdentry,
 				       struct iattr *attr)
 {
-	return notify_change(ovl_upper_mnt_idmap(ofs), upperdentry, attr, NULL);
+	struct path path = {
+		.mnt = ovl_upper_mnt(ofs),
+		.dentry = upperdentry,
+	};
+
+	return notify_change(&path, attr, NULL);
 }
 
 static inline int ovl_do_rmdir(struct ovl_fs *ofs,
@@ -288,8 +293,7 @@ static inline ssize_t ovl_do_getxattr(const struct path *path, const char *name,
 
 	WARN_ON(path->dentry->d_sb != path->mnt->mnt_sb);
 
-	err = vfs_getxattr(mnt_idmap(path->mnt), path->dentry,
-			       name, value, size);
+	err = vfs_getxattr(path, name, value, size);
 	len = (value && err > 0) ? err : 0;
 
 	pr_debug("getxattr(%pd2, \"%s\", \"%*pE\", %zu, 0) = %i\n",
@@ -322,9 +326,13 @@ static inline int ovl_do_setxattr(struct ovl_fs *ofs, struct dentry *dentry,
 				  const char *name, const void *value,
 				  size_t size, int flags)
 {
+	struct path path = {
+		.mnt = ovl_upper_mnt(ofs),
+		.dentry = dentry,
+	};
+
 	/* Use vfs_setxattr(), not __vfs_setxattr(): it idmaps the security.capability rootid. */
-	int err = vfs_setxattr(ovl_upper_mnt_idmap(ofs), dentry, name,
-			       value, size, flags);
+	int err = vfs_setxattr(&path, name, value, size, flags);
 
 	pr_debug("setxattr(%pd2, \"%s\", \"%*pE\", %zu, %d) = %i\n",
 		 dentry, name, min((int)size, 48), value, size, flags, err);
@@ -341,7 +349,12 @@ static inline int ovl_setxattr(struct ovl_fs *ofs, struct dentry *dentry,
 static inline int ovl_do_removexattr(struct ovl_fs *ofs, struct dentry *dentry,
 				     const char *name)
 {
-	int err = vfs_removexattr(ovl_upper_mnt_idmap(ofs), dentry, name);
+	struct path path = {
+		.mnt = ovl_upper_mnt(ofs),
+		.dentry = dentry,
+	};
+
+	int err = vfs_removexattr(&path, name);
 	pr_debug("removexattr(%pd2, \"%s\") = %i\n", dentry, name, err);
 	return err;
 }
@@ -355,13 +368,23 @@ static inline int ovl_removexattr(struct ovl_fs *ofs, struct dentry *dentry,
 static inline int ovl_do_set_acl(struct ovl_fs *ofs, struct dentry *dentry,
 				 const char *acl_name, struct posix_acl *acl)
 {
-	return vfs_set_acl(ovl_upper_mnt_idmap(ofs), dentry, acl_name, acl);
+	struct path path = {
+		.mnt = ovl_upper_mnt(ofs),
+		.dentry = dentry,
+	};
+
+	return vfs_set_acl(&path, acl_name, acl);
 }
 
 static inline int ovl_do_remove_acl(struct ovl_fs *ofs, struct dentry *dentry,
 				    const char *acl_name)
 {
-	return vfs_remove_acl(ovl_upper_mnt_idmap(ofs), dentry, acl_name);
+	struct path path = {
+		.mnt = ovl_upper_mnt(ofs),
+		.dentry = dentry,
+	};
+
+	return vfs_remove_acl(&path, acl_name);
 }
 
 static inline int ovl_do_rename_rd(struct renamedata *rd)
diff --git a/fs/overlayfs/xattrs.c b/fs/overlayfs/xattrs.c
index acc54f6138ef5..6fbd0cbce10d5 100644
--- a/fs/overlayfs/xattrs.c
+++ b/fs/overlayfs/xattrs.c
@@ -45,7 +45,7 @@ static int ovl_xattr_set(struct dentry *dentry, struct inode *inode, const char
 	if (!value && !upperdentry) {
 		ovl_path_lower(dentry, &realpath);
 		with_ovl_creds(dentry->d_sb)
-			err = vfs_getxattr(mnt_idmap(realpath.mnt), realdentry, name, NULL, 0);
+			err = vfs_getxattr(&realpath, name, NULL, 0);
 		if (err < 0)
 			goto out;
 	}
@@ -86,7 +86,7 @@ static int ovl_xattr_get(struct dentry *dentry, struct inode *inode, const char
 	ovl_i_path_real(inode, &realpath);
 	/* Use vfs_getxattr(), not __vfs_getxattr(): it idmaps the security.capability rootid. */
 	with_ovl_creds(dentry->d_sb)
-		return vfs_getxattr(mnt_idmap(realpath.mnt), realpath.dentry, name, value, size);
+		return vfs_getxattr(&realpath, name, value, size);
 }
 
 static bool ovl_can_list(struct super_block *sb, const char *s)
@@ -105,15 +105,17 @@ static bool ovl_can_list(struct super_block *sb, const char *s)
 
 ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size)
 {
-	struct dentry *realdentry = ovl_dentry_real(dentry);
+	struct path realpath;
 	struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
 	ssize_t res;
 	size_t len;
 	char *s;
 	size_t prefix_len, name_len;
 
+	ovl_path_real(dentry, &realpath);
+
 	with_ovl_creds(dentry->d_sb)
-		res = vfs_listxattr(realdentry, list, size);
+		res = vfs_listxattr(&realpath, list, size);
 	if (res <= 0 || size == 0)
 		return res;
 
diff --git a/fs/posix_acl.c b/fs/posix_acl.c
index fe77934ea8f20..d4715c383e041 100644
--- a/fs/posix_acl.c
+++ b/fs/posix_acl.c
@@ -1081,8 +1081,7 @@ static int vfs_set_acl_idmapped_mnt(const struct mnt_idmap *idmap,
 
 /**
  * vfs_set_acl - set posix acls
- * @idmap: idmap of the mount
- * @dentry: the dentry based on which to set the posix acls
+ * @path: the path based on which to set the posix acls
  * @acl_name: the name of the posix acl
  * @kacl: the posix acls in the appropriate VFS format
  *
@@ -1091,9 +1090,11 @@ static int vfs_set_acl_idmapped_mnt(const struct mnt_idmap *idmap,
  *
  * Return: On success 0, on error negative errno.
  */
-int vfs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
-		const char *acl_name, struct posix_acl *kacl)
+int vfs_set_acl(const struct path *path, const char *acl_name,
+		struct posix_acl *kacl)
 {
+	const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
+	struct dentry *dentry = path->dentry;
 	int acl_type;
 	int error;
 	struct inode *inode = d_inode(dentry);
@@ -1127,7 +1128,7 @@ int vfs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
 	if (error)
 		goto out_inode_unlock;
 
-	error = security_inode_set_acl(idmap, dentry, acl_name, kacl);
+	error = security_path_set_acl(path, acl_name, kacl);
 	if (error)
 		goto out_inode_unlock;
 
@@ -1159,8 +1160,7 @@ EXPORT_SYMBOL_GPL(vfs_set_acl);
 
 /**
  * vfs_get_acl - get posix acls
- * @idmap: idmap of the mount
- * @dentry: the dentry based on which to retrieve the posix acls
+ * @path: the path based on which to retrieve the posix acls
  * @acl_name: the name of the posix acl
  *
  * This function retrieves @kacl from the filesystem. The caller must all
@@ -1168,9 +1168,10 @@ EXPORT_SYMBOL_GPL(vfs_set_acl);
  *
  * Return: On success POSIX ACLs in VFS format, on error negative errno.
  */
-struct posix_acl *vfs_get_acl(const struct mnt_idmap *idmap,
-			      struct dentry *dentry, const char *acl_name)
+struct posix_acl *vfs_get_acl(const struct path *path, const char *acl_name)
 {
+	const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
+	struct dentry *dentry = path->dentry;
 	struct inode *inode = d_inode(dentry);
 	struct posix_acl *acl;
 	int acl_type, error;
@@ -1183,7 +1184,7 @@ struct posix_acl *vfs_get_acl(const struct mnt_idmap *idmap,
 	 * The VFS has no restrictions on reading POSIX ACLs so calling
 	 * something like xattr_permission() isn't needed. Only LSMs get a say.
 	 */
-	error = security_inode_get_acl(idmap, dentry, acl_name);
+	error = security_path_get_acl(path, acl_name);
 	if (error)
 		return ERR_PTR(error);
 
@@ -1204,17 +1205,17 @@ EXPORT_SYMBOL_GPL(vfs_get_acl);
 
 /**
  * vfs_remove_acl - remove posix acls
- * @idmap: idmap of the mount
- * @dentry: the dentry based on which to retrieve the posix acls
+ * @path: the path based on which to retrieve the posix acls
  * @acl_name: the name of the posix acl
  *
  * This function removes posix acls.
  *
  * Return: On success 0, on error negative errno.
  */
-int vfs_remove_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
-		   const char *acl_name)
+int vfs_remove_acl(const struct path *path, const char *acl_name)
 {
+	const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
+	struct dentry *dentry = path->dentry;
 	int acl_type;
 	int error;
 	struct inode *inode = d_inode(dentry);
@@ -1235,7 +1236,7 @@ int vfs_remove_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
 	if (error)
 		goto out_inode_unlock;
 
-	error = security_inode_remove_acl(idmap, dentry, acl_name);
+	error = security_path_remove_acl(path, acl_name);
 	if (error)
 		goto out_inode_unlock;
 
@@ -1265,8 +1266,8 @@ int vfs_remove_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
 }
 EXPORT_SYMBOL_GPL(vfs_remove_acl);
 
-int do_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
-	       const char *acl_name, const void *kvalue, size_t size)
+int do_set_acl(const struct path *path, const char *acl_name,
+	       const void *kvalue, size_t size)
 {
 	int error;
 	struct posix_acl *acl = NULL;
@@ -1281,22 +1282,23 @@ int do_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
 			return PTR_ERR(acl);
 	}
 
-	error = vfs_set_acl(idmap, dentry, acl_name, acl);
+	error = vfs_set_acl(path, acl_name, acl);
 	posix_acl_release(acl);
 	return error;
 }
 
-ssize_t do_get_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
-		   const char *acl_name, void *kvalue, size_t size)
+ssize_t do_get_acl(const struct path *path, const char *acl_name,
+		   void *kvalue, size_t size)
 {
 	ssize_t error;
 	struct posix_acl *acl;
 
-	acl = vfs_get_acl(idmap, dentry, acl_name);
+	acl = vfs_get_acl(path, acl_name);
 	if (IS_ERR(acl))
 		return PTR_ERR(acl);
 
-	error = vfs_posix_acl_to_xattr(idmap, d_inode(dentry),
+	error = vfs_posix_acl_to_xattr(mnt_idmap(path->mnt),
+				       d_inode(path->dentry),
 				       acl, kvalue, size);
 	posix_acl_release(acl);
 	return error;
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index b57942263e130..6c8a6f8f27eef 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -3297,7 +3297,6 @@ static bool smb2_is_private_ea(const char *name, size_t name_len)
 static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len,
 		       const struct path *path, bool get_write)
 {
-	const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
 	char *attr_name = NULL, *value;
 	int rc = 0;
 	unsigned int next = 0;
@@ -3337,16 +3336,14 @@ static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len,
 		value = (char *)&eabuf->name + eabuf->EaNameLength + 1;
 
 		if (!eabuf->EaValueLength) {
-			rc = ksmbd_vfs_casexattr_len(idmap,
-						     path->dentry,
+			rc = ksmbd_vfs_casexattr_len(path,
 						     attr_name,
 						     XATTR_USER_PREFIX_LEN +
 						     eabuf->EaNameLength, NULL);
 
 			/* delete the EA only when it exits */
 			if (rc > 0) {
-				rc = ksmbd_vfs_remove_xattr(idmap,
-							    path,
+				rc = ksmbd_vfs_remove_xattr(path,
 							    attr_name,
 							    get_write);
 
@@ -3361,7 +3358,7 @@ static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len,
 			/* if the EA doesn't exist, just do nothing. */
 			rc = 0;
 		} else {
-			rc = ksmbd_vfs_setxattr(idmap, path, attr_name, value,
+			rc = ksmbd_vfs_setxattr(path, attr_name, value,
 						le16_to_cpu(eabuf->EaValueLength),
 						0, get_write);
 			if (rc < 0) {
@@ -3398,7 +3395,6 @@ static noinline int smb2_set_stream_name_xattr(const struct path *path,
 					       struct ksmbd_file *fp,
 					       char *stream_name, int s_type)
 {
-	const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
 	size_t xattr_stream_size;
 	char *xattr_stream_name;
 	int rc;
@@ -3414,8 +3410,7 @@ static noinline int smb2_set_stream_name_xattr(const struct path *path,
 	fp->stream.size = xattr_stream_size;
 
 	/* Keep the existing xattr's case for subsequent writes and removal. */
-	rc = ksmbd_vfs_casexattr_len(idmap,
-				     path->dentry,
+	rc = ksmbd_vfs_casexattr_len(path,
 				     xattr_stream_name,
 				     xattr_stream_size, xattr_stream_name);
 	if (rc >= 0)
@@ -3444,7 +3439,7 @@ static noinline int smb2_set_stream_name_xattr(const struct path *path,
 				0x00, 0x00, 0x01, 0x00,	/* version */
 				[15] = 0x80,		/* backup time */
 			};
-			rc = ksmbd_vfs_setxattr(idmap, path, xattr_stream_name,
+			rc = ksmbd_vfs_setxattr(path, xattr_stream_name,
 						(void *)afpinfo_empty,
 						sizeof(afpinfo_empty), 0, false);
 			return rc < 0 ? rc : 0;
@@ -3453,7 +3448,7 @@ static noinline int smb2_set_stream_name_xattr(const struct path *path,
 		return -EBADF;
 	}
 
-	rc = ksmbd_vfs_setxattr(idmap, path, xattr_stream_name, NULL, 0, 0, false);
+	rc = ksmbd_vfs_setxattr(path, xattr_stream_name, NULL, 0, 0, false);
 	if (rc < 0)
 		pr_err("Failed to store XATTR stream name :%d\n", rc);
 	return 0;
@@ -3468,8 +3463,7 @@ static noinline int smb2_set_stream_name_xattr(const struct path *path,
  */
 static loff_t ksmbd_stream_eof(struct ksmbd_file *fp)
 {
-	ssize_t slen = ksmbd_vfs_casexattr_len(file_mnt_idmap(fp->filp),
-					       fp->filp->f_path.dentry,
+	ssize_t slen = ksmbd_vfs_casexattr_len(&fp->filp->f_path,
 					       fp->stream.name,
 					       fp->stream.size, NULL);
 	return slen < 0 ? 0 : (loff_t)slen;
@@ -3477,12 +3471,11 @@ static loff_t ksmbd_stream_eof(struct ksmbd_file *fp)
 
 static int smb2_remove_smb_xattrs(const struct path *path)
 {
-	const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
 	char *name, *xattr_list = NULL;
 	ssize_t xattr_list_len;
 	int err = 0;
 
-	xattr_list_len = ksmbd_vfs_listxattr(path->dentry, &xattr_list);
+	xattr_list_len = ksmbd_vfs_listxattr(path, &xattr_list);
 	if (xattr_list_len < 0) {
 		goto out;
 	} else if (!xattr_list_len) {
@@ -3497,8 +3490,7 @@ static int smb2_remove_smb_xattrs(const struct path *path)
 		if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN) &&
 		    !strncmp(&name[XATTR_USER_PREFIX_LEN], STREAM_PREFIX,
 			     STREAM_PREFIX_LEN)) {
-			err = ksmbd_vfs_remove_xattr(idmap, path,
-						     name, true);
+			err = ksmbd_vfs_remove_xattr(path, name, true);
 			if (err)
 				ksmbd_debug(SMB, "remove xattr failed : %s\n",
 					    name);
@@ -3544,7 +3536,7 @@ static void smb2_new_xattrs(struct ksmbd_tree_connect *tcon, const struct path *
 	da.flags = XATTR_DOSINFO_ATTRIB | XATTR_DOSINFO_CREATE_TIME |
 		XATTR_DOSINFO_ITIME;
 
-	rc = ksmbd_vfs_set_dos_attrib_xattr(mnt_idmap(path->mnt), path, &da, true);
+	rc = ksmbd_vfs_set_dos_attrib_xattr(path, &da, true);
 	if (rc)
 		ksmbd_debug(SMB, "failed to store file attribute into xattr\n");
 }
@@ -3553,18 +3545,19 @@ static bool smb2_parent_compressed(struct ksmbd_tree_connect *tcon,
 				   const struct path *path)
 {
 	struct dentry *parent = dget_parent(path->dentry);
+	struct path parent_path = { .mnt = path->mnt, .dentry = parent };
 	struct file_kattr fa = { .flags_valid = true };
 	struct xattr_dos_attrib da;
 	bool compressed = false;
 	int rc;
 
-	rc = vfs_fileattr_get(parent, &fa);
+	rc = vfs_fileattr_get(&parent_path, &fa);
 	if (!rc && fa.flags & FS_COMPR_FL) {
 		compressed = true;
 		goto out;
 	}
 
-	rc = ksmbd_vfs_get_dos_attrib_xattr(mnt_idmap(path->mnt), parent, &da);
+	rc = ksmbd_vfs_get_dos_attrib_xattr(&parent_path, &da);
 	if (rc > 0 && da.attr & FILE_ATTRIBUTE_COMPRESSED)
 		compressed = true;
 
@@ -3584,8 +3577,7 @@ static void smb2_update_xattrs(struct ksmbd_tree_connect *tcon,
 	fp->f_ci->m_fattr &= ~(FILE_ATTRIBUTE_HIDDEN_LE | FILE_ATTRIBUTE_SYSTEM_LE);
 
 	/* get FileAttributes from XATTR_NAME_DOS_ATTRIBUTE */
-	rc = ksmbd_vfs_get_dos_attrib_xattr(mnt_idmap(path->mnt),
-					    path->dentry, &da);
+	rc = ksmbd_vfs_get_dos_attrib_xattr(path, &da);
 	if (rc > 0) {
 		if (store_dos_attrs) {
 			fp->f_ci->m_fattr = cpu_to_le32(da.attr);
@@ -4623,8 +4615,7 @@ int smb2_open(struct ksmbd_work *work)
 
 			if (test_share_config_flag(tcon->share_conf,
 						   KSMBD_SHARE_FLAG_STORE_DOS_ATTRS) &&
-			    ksmbd_vfs_get_dos_attrib_xattr(mnt_idmap(path.mnt),
-							 path.dentry, &da) > 0 &&
+			    ksmbd_vfs_get_dos_attrib_xattr(&path, &da) > 0 &&
 			    da.attr & FILE_ATTRIBUTE_READONLY) {
 				rsp->hdr.Status = STATUS_CANNOT_DELETE;
 				rc = -EACCES;
@@ -4962,7 +4953,6 @@ int smb2_open(struct ksmbd_work *work)
 					}
 
 					rc = ksmbd_vfs_set_sd_xattr(conn,
-								    idmap,
 								    &path,
 								    pntsd,
 								    pntsd_size,
@@ -5186,7 +5176,7 @@ int smb2_open(struct ksmbd_work *work)
 		smb2_new_xattrs(tcon, &path, fp);
 	}
 
-	ksmbd_vfs_update_compressed_fattr(path.dentry, &fp->f_ci->m_fattr);
+	ksmbd_vfs_update_compressed_fattr(&path, &fp->f_ci->m_fattr);
 
 	if (created) {
 		if (fp->coption & FILE_NO_COMPRESSION_LE) {
@@ -6163,7 +6153,6 @@ static int process_query_dir_entries(struct smb2_query_dir_private *priv)
 		ksmbd_kstat.kstat = &kstat;
 		if (priv->info_level != FILE_NAMES_INFORMATION) {
 			rc = ksmbd_vfs_fill_dentry_attrs(priv->work,
-							 idmap,
 							 dent,
 							 &ksmbd_kstat);
 			if (rc) {
@@ -6765,7 +6754,6 @@ static int smb2_get_ea(struct ksmbd_work *work, struct ksmbd_file *fp,
 	ssize_t buf_free_len, alignment_bytes, next_offset, rsp_data_cnt = 0;
 	struct smb2_ea_info_req *ea_req = NULL;
 	const struct path *path;
-	const struct mnt_idmap *idmap = file_mnt_idmap(fp->filp);
 
 	if (!(fp->daccess & FILE_READ_EA_LE)) {
 		pr_err("Not permitted to read ext attr : 0x%x\n",
@@ -6802,7 +6790,7 @@ static int smb2_get_ea(struct ksmbd_work *work, struct ksmbd_file *fp,
 	if (buf_free_len < 0)
 		return -EINVAL;
 
-	rc = ksmbd_vfs_listxattr(path->dentry, &xattr_list);
+	rc = ksmbd_vfs_listxattr(path, &xattr_list);
 	if (rc < 0) {
 		rsp->hdr.Status = STATUS_INVALID_HANDLE;
 		goto out;
@@ -6848,8 +6836,7 @@ static int smb2_get_ea(struct ksmbd_work *work, struct ksmbd_file *fp,
 		buf_free_len -= (offsetof(struct smb2_ea_info, name) +
 				name_len + 1);
 		/* bailout if xattr can't fit in buf_free_len */
-		value_len = ksmbd_vfs_getxattr(idmap, path->dentry,
-					       name, &buf);
+		value_len = ksmbd_vfs_getxattr(path, name, &buf);
 		if (value_len <= 0) {
 			rc = -ENOENT;
 			rsp->hdr.Status = STATUS_INVALID_HANDLE;
@@ -7139,7 +7126,7 @@ static char *smb2_get_normalized_stream_name(struct ksmbd_file *fp)
 	if (!ksmbd_stream_fd(fp))
 		return NULL;
 
-	xattr_list_len = ksmbd_vfs_listxattr(fp->filp->f_path.dentry,
+	xattr_list_len = ksmbd_vfs_listxattr(&fp->filp->f_path,
 					     &xattr_list);
 	if (xattr_list_len <= 0)
 		goto out;
@@ -7242,7 +7229,7 @@ static int get_file_stream_info(struct ksmbd_work *work,
 	if (buf_free_len < 0)
 		goto out;
 
-	xattr_list_len = ksmbd_vfs_listxattr(path->dentry, &xattr_list);
+	xattr_list_len = ksmbd_vfs_listxattr(path, &xattr_list);
 	if (xattr_list_len < 0) {
 		goto out;
 	} else if (!xattr_list_len) {
@@ -7287,8 +7274,7 @@ static int get_file_stream_info(struct ksmbd_work *work,
 		streamlen *= 2;
 		kfree(stream_buf);
 		file_info->StreamNameLength = cpu_to_le32(streamlen);
-		slen = ksmbd_vfs_xattr_len(file_mnt_idmap(fp->filp),
-					   path->dentry, stream_name);
+		slen = ksmbd_vfs_xattr_len(path, stream_name);
 		ssize = slen < 0 ? 0 : (loff_t)slen;
 		file_info->StreamSize = cpu_to_le64(ssize);
 		file_info->StreamAllocationSize = cpu_to_le64(ssize);
@@ -7757,7 +7743,7 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work,
 			FILE_SUPPORTS_SPARSE_FILES |
 			FILE_SUPPORTS_BLOCK_REFCOUNTING;
 
-		err = vfs_fileattr_get(path.dentry, &fa);
+		err = vfs_fileattr_get(&path, &fa);
 		/*
 		 * -EINVAL, -EOPNOTSUPP: ntfs-3g and other FUSE
 		 * filesystems that lack FS_IOC_FSGETXATTR support.
@@ -8026,8 +8012,8 @@ static int smb2_get_info_sec(struct ksmbd_work *work,
 
 	if (test_share_config_flag(work->tcon->share_conf,
 				   KSMBD_SHARE_FLAG_ACL_XATTR))
-		ppntsd_size = ksmbd_vfs_get_sd_xattr(work->conn, idmap,
-						     fp->filp->f_path.dentry,
+		ppntsd_size = ksmbd_vfs_get_sd_xattr(work->conn,
+						     &fp->filp->f_path,
 						     &ppntsd);
 
 	/* Check if sd buffer size exceeds response buffer size */
@@ -8388,8 +8374,7 @@ static int smb2_rename(struct ksmbd_work *work,
 				goto out;
 			}
 
-			stream_buf_len = ksmbd_vfs_getcasexattr(file_mnt_idmap(fp->filp),
-								fp->filp->f_path.dentry,
+			stream_buf_len = ksmbd_vfs_getcasexattr(&fp->filp->f_path,
 								fp->stream.name,
 								fp->stream.size,
 								&stream_buf);
@@ -8400,8 +8385,7 @@ static int smb2_rename(struct ksmbd_work *work,
 			}
 		}
 
-		rc = ksmbd_vfs_setxattr(file_mnt_idmap(fp->filp),
-					&fp->filp->f_path,
+		rc = ksmbd_vfs_setxattr(&fp->filp->f_path,
 					xattr_stream_name,
 					stream_buf, stream_buf_len, 0, true);
 		kfree(stream_buf);
@@ -8508,7 +8492,6 @@ static int set_file_basic_info(struct ksmbd_file *fp,
 	struct iattr attrs;
 	struct file *filp;
 	struct inode *inode;
-	const struct mnt_idmap *idmap;
 	__le32 attrs_mask = FILE_ATTRIBUTE_DIRECTORY_LE |
 		FILE_ATTRIBUTE_COMPRESSED_LE;
 	int rc = 0;
@@ -8519,7 +8502,6 @@ static int set_file_basic_info(struct ksmbd_file *fp,
 	attrs.ia_valid = 0;
 	filp = fp->filp;
 	inode = file_inode(filp);
-	idmap = file_mnt_idmap(filp);
 
 	if (file_info->CreationTime)
 		fp->create_time = le64_to_cpu(file_info->CreationTime);
@@ -8564,7 +8546,7 @@ static int set_file_basic_info(struct ksmbd_file *fp,
 		da.flags = XATTR_DOSINFO_ATTRIB | XATTR_DOSINFO_CREATE_TIME |
 			XATTR_DOSINFO_ITIME;
 
-		rc = ksmbd_vfs_set_dos_attrib_xattr(idmap, &filp->f_path, &da,
+		rc = ksmbd_vfs_set_dos_attrib_xattr(&filp->f_path, &da,
 				true);
 		if (rc)
 			ksmbd_debug(SMB,
@@ -8580,7 +8562,7 @@ static int set_file_basic_info(struct ksmbd_file *fp,
 			return -EACCES;
 
 		inode_lock(inode);
-		rc = notify_change(idmap, dentry, &attrs, NULL);
+		rc = notify_change(&filp->f_path, &attrs, NULL);
 		inode_unlock(inode);
 	}
 	return rc;
@@ -11127,7 +11109,6 @@ static inline int fsctl_set_sparse(struct ksmbd_work *work, u64 id,
 				   struct file_sparse *sparse)
 {
 	struct ksmbd_file *fp;
-	const struct mnt_idmap *idmap;
 	int ret = 0;
 	__le32 old_fattr;
 
@@ -11151,8 +11132,6 @@ static inline int fsctl_set_sparse(struct ksmbd_work *work, u64 id,
 		goto out;
 	}
 
-	idmap = file_mnt_idmap(fp->filp);
-
 	old_fattr = fp->f_ci->m_fattr;
 	if (!sparse->SetSparse &&
 	    (old_fattr & FILE_ATTRIBUTE_SPARSE_FILE_LE)) {
@@ -11170,8 +11149,7 @@ static inline int fsctl_set_sparse(struct ksmbd_work *work, u64 id,
 		const struct cred *saved_cred;
 		struct xattr_dos_attrib da = {0};
 
-		ret = ksmbd_vfs_get_dos_attrib_xattr(idmap,
-						     fp->filp->f_path.dentry, &da);
+		ret = ksmbd_vfs_get_dos_attrib_xattr(&fp->filp->f_path, &da);
 		if (ret <= 0) {
 			da.version = 4;
 			da.itime = fp->itime;
@@ -11183,8 +11161,7 @@ static inline int fsctl_set_sparse(struct ksmbd_work *work, u64 id,
 		da.attr = le32_to_cpu(fp->f_ci->m_fattr);
 		da.flags |= XATTR_DOSINFO_ATTRIB;
 		saved_cred = override_creds(fp->filp->f_cred);
-		ret = ksmbd_vfs_set_dos_attrib_xattr(idmap,
-						     &fp->filp->f_path,
+		ret = ksmbd_vfs_set_dos_attrib_xattr(&fp->filp->f_path,
 						     &da, true);
 		revert_creds(saved_cred);
 		if (ret)
diff --git a/fs/smb/server/smb_common.c b/fs/smb/server/smb_common.c
index 7dbcfa658edd5..2cc8e24dcd6cb 100644
--- a/fs/smb/server/smb_common.c
+++ b/fs/smb/server/smb_common.c
@@ -467,7 +467,6 @@ int ksmbd_populate_dot_dotdot_entries(struct ksmbd_work *work, int info_level,
 {
 	int i, rc = 0;
 	struct ksmbd_conn *conn = work->conn;
-	const struct mnt_idmap *idmap = file_mnt_idmap(dir->filp);
 
 	for (i = 0; i < 2; i++) {
 		struct kstat kstat;
@@ -493,7 +492,6 @@ int ksmbd_populate_dot_dotdot_entries(struct ksmbd_work *work, int info_level,
 
 			ksmbd_kstat.kstat = &kstat;
 			rc = ksmbd_vfs_fill_dentry_attrs(work,
-							 idmap,
 							 dentry,
 							 &ksmbd_kstat);
 			if (rc)
diff --git a/fs/smb/server/smbacl.c b/fs/smb/server/smbacl.c
index 96428df33b438..bcc506fca33e5 100644
--- a/fs/smb/server/smbacl.c
+++ b/fs/smb/server/smbacl.c
@@ -1199,8 +1199,8 @@ int smb_inherit_dacl(struct ksmbd_conn *conn,
 	struct smb_acl *parent_pdacl;
 	struct smb_ntsd *parent_pntsd = NULL;
 	struct smb_sid owner_sid, group_sid;
-	struct dentry *parent = path->dentry->d_parent;
-	const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
+	struct path parent_path = { .mnt = path->mnt,
+				    .dentry = path->dentry->d_parent };
 	int inherited_flags = 0, flags = 0, i, nt_size = 0, pdacl_size;
 	int rc = 0, pntsd_type, ppntsd_size, acl_len, aces_size;
 	unsigned int dacloffset;
@@ -1209,8 +1209,8 @@ int smb_inherit_dacl(struct ksmbd_conn *conn,
 	char *aces_base;
 	bool is_dir = S_ISDIR(d_inode(path->dentry)->i_mode);
 
-	ppntsd_size = ksmbd_vfs_get_sd_xattr(conn, idmap,
-					    parent, &parent_pntsd);
+	ppntsd_size = ksmbd_vfs_get_sd_xattr(conn, &parent_path,
+					    &parent_pntsd);
 	if (ppntsd_size <= 0)
 		return -ENOENT;
 
@@ -1427,7 +1427,7 @@ int smb_inherit_dacl(struct ksmbd_conn *conn,
 			pntsd_size += sizeof(struct smb_acl) + nt_size;
 		}
 
-		ksmbd_vfs_set_sd_xattr(conn, idmap, path, pntsd, pntsd_size, false);
+		ksmbd_vfs_set_sd_xattr(conn, path, pntsd, pntsd_size, false);
 		kfree(pntsd);
 	}
 
@@ -1476,8 +1476,7 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path,
 	vfsuid_t vfsuid;
 
 	ksmbd_debug(SMB, "check permission using windows acl\n");
-	pntsd_size = ksmbd_vfs_get_sd_xattr(conn, idmap,
-					    path->dentry, &pntsd);
+	pntsd_size = ksmbd_vfs_get_sd_xattr(conn, path, &pntsd);
 	if (pntsd_size <= 0 || !pntsd)
 		goto err_out;
 
@@ -1701,7 +1700,7 @@ int set_info_sec(struct ksmbd_conn *conn, struct ksmbd_tree_connect *tcon,
 	newattrs.ia_valid |= ATTR_MODE;
 	newattrs.ia_mode = (inode->i_mode & ~0777) | (fattr.cf_mode & 0777);
 
-	ksmbd_vfs_remove_acl_xattrs(idmap, path);
+	ksmbd_vfs_remove_acl_xattrs(path);
 	/* Update posix acls */
 	if (IS_ENABLED(CONFIG_FS_POSIX_ACL) && fattr.cf_dacls) {
 		rc = set_posix_acl(idmap, path->dentry,
@@ -1721,7 +1720,7 @@ int set_info_sec(struct ksmbd_conn *conn, struct ksmbd_tree_connect *tcon,
 	}
 
 	inode_lock(inode);
-	rc = notify_change(idmap, path->dentry, &newattrs, NULL);
+	rc = notify_change(path, &newattrs, NULL);
 	inode_unlock(inode);
 	if (rc)
 		goto out;
@@ -1732,8 +1731,8 @@ int set_info_sec(struct ksmbd_conn *conn, struct ksmbd_tree_connect *tcon,
 
 	if (test_share_config_flag(tcon->share_conf, KSMBD_SHARE_FLAG_ACL_XATTR)) {
 		/* Update WinACL in xattr */
-		ksmbd_vfs_remove_sd_xattrs(idmap, path);
-		ksmbd_vfs_set_sd_xattr(conn, idmap, path, pntsd, ntsd_len,
+		ksmbd_vfs_remove_sd_xattrs(path);
+		ksmbd_vfs_set_sd_xattr(conn, path, pntsd, ntsd_len,
 				get_write);
 	}
 
diff --git a/fs/smb/server/tests/smbacl_kunit.c b/fs/smb/server/tests/smbacl_kunit.c
index 33496b4d31a3e..0e918b72f94fe 100644
--- a/fs/smb/server/tests/smbacl_kunit.c
+++ b/fs/smb/server/tests/smbacl_kunit.c
@@ -221,8 +221,7 @@ static void ksmbd_smb_check_perm_dacl_boundary_test(struct kunit *test)
 				mk_vma_flags(VMA_NORESERVE_BIT));
 	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, file);
 
-	rc = ksmbd_vfs_set_sd_xattr(NULL, mnt_idmap(file->f_path.mnt),
-				    &file->f_path, pntsd, ntsd_size,
+	rc = ksmbd_vfs_set_sd_xattr(NULL, &file->f_path, pntsd, ntsd_size,
 				    false);
 	KUNIT_EXPECT_EQ(test, 0, rc);
 	if (rc)
@@ -263,8 +262,7 @@ ksmbd_smb_check_perm_dacl_maximal_boundary_test(struct kunit *test)
 				mk_vma_flags(VMA_NORESERVE_BIT));
 	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, file);
 
-	rc = ksmbd_vfs_set_sd_xattr(NULL, mnt_idmap(file->f_path.mnt),
-				    &file->f_path, pntsd, ntsd_size,
+	rc = ksmbd_vfs_set_sd_xattr(NULL, &file->f_path, pntsd, ntsd_size,
 				    false);
 	KUNIT_EXPECT_EQ(test, 0, rc);
 	if (rc)
diff --git a/fs/smb/server/vfs.c b/fs/smb/server/vfs.c
index d21ed90454f9a..c27a04dcfe385 100644
--- a/fs/smb/server/vfs.c
+++ b/fs/smb/server/vfs.c
@@ -218,14 +218,14 @@ int ksmbd_vfs_mkdir(struct ksmbd_work *work, const char *name, umode_t mode)
 	return err;
 }
 
-ssize_t ksmbd_vfs_getcasexattr(const struct mnt_idmap *idmap,
-			       struct dentry *dentry, char *attr_name,
+ssize_t ksmbd_vfs_getcasexattr(const struct path *path,
+			       char *attr_name,
 			       int attr_name_len, char **attr_value)
 {
 	char *name, *xattr_list = NULL;
 	ssize_t value_len = -ENOENT, xattr_list_len;
 
-	xattr_list_len = ksmbd_vfs_listxattr(dentry, &xattr_list);
+	xattr_list_len = ksmbd_vfs_listxattr(path, &xattr_list);
 	if (xattr_list_len <= 0)
 		goto out;
 
@@ -235,8 +235,7 @@ ssize_t ksmbd_vfs_getcasexattr(const struct mnt_idmap *idmap,
 		if (strncasecmp(attr_name, name, attr_name_len))
 			continue;
 
-		value_len = ksmbd_vfs_getxattr(idmap,
-					       dentry,
+		value_len = ksmbd_vfs_getxattr(path,
 					       name,
 					       attr_value);
 		if (value_len < 0)
@@ -260,8 +259,7 @@ static int ksmbd_vfs_stream_read(struct ksmbd_file *fp, char *buf, loff_t *pos,
 		    *pos, count);
 
 	saved_cred = override_creds(fp->filp->f_cred);
-	v_len = ksmbd_vfs_getcasexattr(file_mnt_idmap(fp->filp),
-				       fp->filp->f_path.dentry,
+	v_len = ksmbd_vfs_getcasexattr(&fp->filp->f_path,
 				       fp->stream.name,
 				       fp->stream.size,
 				       &stream_buf);
@@ -388,7 +386,6 @@ static int ksmbd_vfs_stream_write(struct ksmbd_file *fp, char *buf, loff_t *pos,
 {
 	const struct cred *saved_cred;
 	char *stream_buf = NULL, *wbuf;
-	const struct mnt_idmap *idmap = file_mnt_idmap(fp->filp);
 	size_t size, write_end;
 	ssize_t v_len;
 	int err = 0;
@@ -406,8 +403,7 @@ static int ksmbd_vfs_stream_write(struct ksmbd_file *fp, char *buf, loff_t *pos,
 	write_end = *pos + count;
 
 	saved_cred = override_creds(fp->filp->f_cred);
-	v_len = ksmbd_vfs_getcasexattr(idmap,
-				       fp->filp->f_path.dentry,
+	v_len = ksmbd_vfs_getcasexattr(&fp->filp->f_path,
 				       fp->stream.name,
 				       fp->stream.size,
 				       &stream_buf);
@@ -434,8 +430,7 @@ static int ksmbd_vfs_stream_write(struct ksmbd_file *fp, char *buf, loff_t *pos,
 
 	memcpy(&stream_buf[*pos], buf, count);
 
-	err = ksmbd_vfs_setxattr(idmap,
-				 &fp->filp->f_path,
+	err = ksmbd_vfs_setxattr(&fp->filp->f_path,
 				 fp->stream.name,
 				 (void *)stream_buf,
 				 size,
@@ -465,7 +460,6 @@ static int ksmbd_vfs_stream_write(struct ksmbd_file *fp, char *buf, loff_t *pos,
 int ksmbd_vfs_stream_truncate(struct ksmbd_file *fp, loff_t newsize)
 {
 	const struct cred *saved_cred;
-	const struct mnt_idmap *idmap = file_mnt_idmap(fp->filp);
 	char *stream_buf = NULL, *new_buf = NULL;
 	ssize_t v_len;
 	int err;
@@ -476,7 +470,7 @@ int ksmbd_vfs_stream_truncate(struct ksmbd_file *fp, loff_t newsize)
 		return -EFBIG;
 
 	saved_cred = override_creds(fp->filp->f_cred);
-	v_len = ksmbd_vfs_getcasexattr(idmap, fp->filp->f_path.dentry,
+	v_len = ksmbd_vfs_getcasexattr(&fp->filp->f_path,
 				       fp->stream.name, fp->stream.size,
 				       &stream_buf);
 	if (v_len < 0) {
@@ -499,7 +493,7 @@ int ksmbd_vfs_stream_truncate(struct ksmbd_file *fp, loff_t newsize)
 			memcpy(new_buf, stream_buf, v_len);
 	}
 
-	err = ksmbd_vfs_setxattr(idmap, &fp->filp->f_path, fp->stream.name,
+	err = ksmbd_vfs_setxattr(&fp->filp->f_path, fp->stream.name,
 				 new_buf, newsize, 0, true);
 	if (new_buf != stream_buf)
 		kvfree(new_buf);
@@ -870,17 +864,17 @@ int ksmbd_vfs_truncate(struct ksmbd_work *work,
 
 /**
  * ksmbd_vfs_listxattr() - vfs helper for smb list extended attributes
- * @dentry:	dentry of file for listing xattrs
+ * @path:	path of file for listing xattrs
  * @list:	destination buffer
  *
  * Return:	xattr list length on success, otherwise error
  */
-ssize_t ksmbd_vfs_listxattr(struct dentry *dentry, char **list)
+ssize_t ksmbd_vfs_listxattr(const struct path *path, char **list)
 {
 	ssize_t size;
 	char *vlist = NULL;
 
-	size = vfs_listxattr(dentry, NULL, 0);
+	size = vfs_listxattr(path, NULL, 0);
 	if (size <= 0)
 		return size;
 
@@ -889,7 +883,7 @@ ssize_t ksmbd_vfs_listxattr(struct dentry *dentry, char **list)
 		return -ENOMEM;
 
 	*list = vlist;
-	size = vfs_listxattr(dentry, vlist, size);
+	size = vfs_listxattr(path, vlist, size);
 	if (size < 0) {
 		ksmbd_debug(VFS, "listxattr failed\n");
 		kvfree(vlist);
@@ -899,30 +893,27 @@ ssize_t ksmbd_vfs_listxattr(struct dentry *dentry, char **list)
 	return size;
 }
 
-ssize_t ksmbd_vfs_xattr_len(const struct mnt_idmap *idmap,
-			    struct dentry *dentry, char *xattr_name)
+ssize_t ksmbd_vfs_xattr_len(const struct path *path, char *xattr_name)
 {
-	return vfs_getxattr(idmap, dentry, xattr_name, NULL, 0);
+	return vfs_getxattr(path, xattr_name, NULL, 0);
 }
 
 /**
  * ksmbd_vfs_getxattr() - vfs helper for smb get extended attributes value
- * @idmap:	idmap
- * @dentry:	dentry of file for getting xattrs
+ * @path:	path of file for getting xattrs
  * @xattr_name:	name of xattr name to query
  * @xattr_buf:	destination buffer xattr value
  *
  * Return:	read xattr value length on success, otherwise error
  */
-ssize_t ksmbd_vfs_getxattr(const struct mnt_idmap *idmap,
-			   struct dentry *dentry,
+ssize_t ksmbd_vfs_getxattr(const struct path *path,
 			   char *xattr_name, char **xattr_buf)
 {
 	ssize_t xattr_len;
 	char *buf;
 
 	*xattr_buf = NULL;
-	xattr_len = ksmbd_vfs_xattr_len(idmap, dentry, xattr_name);
+	xattr_len = ksmbd_vfs_xattr_len(path, xattr_name);
 	if (xattr_len < 0)
 		return xattr_len;
 
@@ -930,8 +921,7 @@ ssize_t ksmbd_vfs_getxattr(const struct mnt_idmap *idmap,
 	if (!buf)
 		return -ENOMEM;
 
-	xattr_len = vfs_getxattr(idmap, dentry, xattr_name,
-				 (void *)buf, xattr_len);
+	xattr_len = vfs_getxattr(path, xattr_name, (void *)buf, xattr_len);
 	if (xattr_len > 0)
 		*xattr_buf = buf;
 	else
@@ -941,7 +931,6 @@ ssize_t ksmbd_vfs_getxattr(const struct mnt_idmap *idmap,
 
 /**
  * ksmbd_vfs_setxattr() - vfs helper for smb set extended attributes value
- * @idmap:	idmap of the relevant mount
  * @path:	path of dentry to set XATTR at
  * @attr_name:	xattr name for setxattr
  * @attr_value:	xattr value to set
@@ -951,8 +940,7 @@ ssize_t ksmbd_vfs_getxattr(const struct mnt_idmap *idmap,
  *
  * Return:	0 on success, otherwise error
  */
-int ksmbd_vfs_setxattr(const struct mnt_idmap *idmap,
-		       const struct path *path, const char *attr_name,
+int ksmbd_vfs_setxattr(const struct path *path, const char *attr_name,
 		       void *attr_value, size_t attr_size, int flags,
 		       bool get_write)
 {
@@ -964,8 +952,7 @@ int ksmbd_vfs_setxattr(const struct mnt_idmap *idmap,
 			return err;
 	}
 
-	err = vfs_setxattr(idmap,
-			   path->dentry,
+	err = vfs_setxattr(path,
 			   attr_name,
 			   attr_value,
 			   attr_size,
@@ -1235,8 +1222,7 @@ int ksmbd_vfs_query_allocated_ranges(struct ksmbd_file *fp, loff_t start,
 	return ret;
 }
 
-int ksmbd_vfs_remove_xattr(const struct mnt_idmap *idmap,
-			   const struct path *path, char *attr_name,
+int ksmbd_vfs_remove_xattr(const struct path *path, char *attr_name,
 			   bool get_write)
 {
 	int err;
@@ -1247,7 +1233,7 @@ int ksmbd_vfs_remove_xattr(const struct mnt_idmap *idmap,
 			return err;
 	}
 
-	err = vfs_removexattr(idmap, path->dentry, attr_name);
+	err = vfs_removexattr(path, attr_name);
 
 	if (get_write == true)
 		mnt_drop_write(path->mnt);
@@ -1529,14 +1515,13 @@ struct dentry *ksmbd_vfs_kern_path_create(struct ksmbd_work *work,
 	return dent;
 }
 
-int ksmbd_vfs_remove_acl_xattrs(const struct mnt_idmap *idmap,
-				const struct path *path)
+int ksmbd_vfs_remove_acl_xattrs(const struct path *path)
 {
 	char *name, *xattr_list = NULL;
 	ssize_t xattr_list_len;
 	int err = 0;
 
-	xattr_list_len = ksmbd_vfs_listxattr(path->dentry, &xattr_list);
+	xattr_list_len = ksmbd_vfs_listxattr(path, &xattr_list);
 	if (xattr_list_len < 0) {
 		goto out;
 	} else if (!xattr_list_len) {
@@ -1556,7 +1541,7 @@ int ksmbd_vfs_remove_acl_xattrs(const struct mnt_idmap *idmap,
 			     sizeof(XATTR_NAME_POSIX_ACL_ACCESS) - 1) ||
 		    !strncmp(name, XATTR_NAME_POSIX_ACL_DEFAULT,
 			     sizeof(XATTR_NAME_POSIX_ACL_DEFAULT) - 1)) {
-			err = vfs_remove_acl(idmap, path->dentry, name);
+			err = vfs_remove_acl(path, name);
 			if (err)
 				ksmbd_debug(SMB,
 					    "remove acl xattr failed : %s\n", name);
@@ -1569,13 +1554,13 @@ int ksmbd_vfs_remove_acl_xattrs(const struct mnt_idmap *idmap,
 	return err;
 }
 
-int ksmbd_vfs_remove_sd_xattrs(const struct mnt_idmap *idmap, const struct path *path)
+int ksmbd_vfs_remove_sd_xattrs(const struct path *path)
 {
 	char *name, *xattr_list = NULL;
 	ssize_t xattr_list_len;
 	int err = 0;
 
-	xattr_list_len = ksmbd_vfs_listxattr(path->dentry, &xattr_list);
+	xattr_list_len = ksmbd_vfs_listxattr(path, &xattr_list);
 	if (xattr_list_len < 0) {
 		goto out;
 	} else if (!xattr_list_len) {
@@ -1588,7 +1573,7 @@ int ksmbd_vfs_remove_sd_xattrs(const struct mnt_idmap *idmap, const struct path
 		ksmbd_debug(SMB, "%s, len %zd\n", name, strlen(name));
 
 		if (!strncmp(name, XATTR_NAME_SD, XATTR_NAME_SD_LEN)) {
-			err = ksmbd_vfs_remove_xattr(idmap, path, name, true);
+			err = ksmbd_vfs_remove_xattr(path, name, true);
 			if (err)
 				ksmbd_debug(SMB, "remove xattr failed : %s\n", name);
 		}
@@ -1664,7 +1649,6 @@ static struct xattr_smb_acl *ksmbd_vfs_make_xattr_posix_acl(const struct mnt_idm
 }
 
 int ksmbd_vfs_set_sd_xattr(struct ksmbd_conn *conn,
-			   const struct mnt_idmap *idmap,
 			   const struct path *path,
 			   struct smb_ntsd *pntsd, int len,
 			   bool get_write)
@@ -1675,6 +1659,7 @@ int ksmbd_vfs_set_sd_xattr(struct ksmbd_conn *conn,
 	struct xattr_smb_acl *smb_acl, *def_smb_acl = NULL;
 	struct dentry *dentry = path->dentry;
 	struct inode *inode = d_inode(dentry);
+	const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
 
 	acl.version = 4;
 	acl.hash_type = XATTR_SD_HASH_TYPE_SHA256;
@@ -1716,7 +1701,7 @@ int ksmbd_vfs_set_sd_xattr(struct ksmbd_conn *conn,
 		goto out;
 	}
 
-	rc = ksmbd_vfs_setxattr(idmap, path,
+	rc = ksmbd_vfs_setxattr(path,
 				XATTR_NAME_SD, sd_ndr.data,
 				sd_ndr.offset, 0, get_write);
 	if (rc < 0)
@@ -1732,19 +1717,19 @@ int ksmbd_vfs_set_sd_xattr(struct ksmbd_conn *conn,
 EXPORT_SYMBOL_IF_KUNIT(ksmbd_vfs_set_sd_xattr);
 
 int ksmbd_vfs_get_sd_xattr(struct ksmbd_conn *conn,
-			   const struct mnt_idmap *idmap,
-			   struct dentry *dentry,
+			   const struct path *path,
 			   struct smb_ntsd **pntsd)
 {
 	int rc;
 	struct ndr n;
-	struct inode *inode = d_inode(dentry);
+	struct inode *inode = d_inode(path->dentry);
 	struct ndr acl_ndr = {0};
 	struct xattr_ntacl acl = {0};
 	struct xattr_smb_acl *smb_acl = NULL, *def_smb_acl = NULL;
+	const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
 	__u8 cmp_hash[XATTR_SD_HASH_SIZE] = {0};
 
-	rc = ksmbd_vfs_getxattr(idmap, dentry, XATTR_NAME_SD, &n.data);
+	rc = ksmbd_vfs_getxattr(path, XATTR_NAME_SD, &n.data);
 	if (rc <= 0)
 		return rc;
 
@@ -1801,8 +1786,7 @@ int ksmbd_vfs_get_sd_xattr(struct ksmbd_conn *conn,
 	return rc;
 }
 
-int ksmbd_vfs_set_dos_attrib_xattr(const struct mnt_idmap *idmap,
-				   const struct path *path,
+int ksmbd_vfs_set_dos_attrib_xattr(const struct path *path,
 				   struct xattr_dos_attrib *da,
 				   bool get_write)
 {
@@ -1813,7 +1797,7 @@ int ksmbd_vfs_set_dos_attrib_xattr(const struct mnt_idmap *idmap,
 	if (err)
 		goto out;
 
-	err = ksmbd_vfs_setxattr(idmap, path, XATTR_NAME_DOS_ATTRIBUTE,
+	err = ksmbd_vfs_setxattr(path, XATTR_NAME_DOS_ATTRIBUTE,
 				 (void *)n.data, n.offset, 0, get_write);
 	if (err)
 		ksmbd_debug(SMB, "failed to store dos attribute in xattr\n");
@@ -1823,14 +1807,13 @@ int ksmbd_vfs_set_dos_attrib_xattr(const struct mnt_idmap *idmap,
 	return err;
 }
 
-int ksmbd_vfs_get_dos_attrib_xattr(const struct mnt_idmap *idmap,
-				   struct dentry *dentry,
+int ksmbd_vfs_get_dos_attrib_xattr(const struct path *path,
 				   struct xattr_dos_attrib *da)
 {
 	struct ndr n;
 	int err;
 
-	err = ksmbd_vfs_getxattr(idmap, dentry, XATTR_NAME_DOS_ATTRIBUTE,
+	err = ksmbd_vfs_getxattr(path, XATTR_NAME_DOS_ATTRIBUTE,
 				 (char **)&n.data);
 	if (err > 0) {
 		n.length = err;
@@ -1879,7 +1862,6 @@ void *ksmbd_vfs_init_kstat(char **p, struct ksmbd_kstat *ksmbd_kstat)
 }
 
 int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work,
-				const struct mnt_idmap *idmap,
 				struct dentry *dentry,
 				struct ksmbd_kstat *ksmbd_kstat)
 {
@@ -1913,7 +1895,7 @@ int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work,
 				   KSMBD_SHARE_FLAG_STORE_DOS_ATTRS)) {
 		struct xattr_dos_attrib da;
 
-		rc = ksmbd_vfs_get_dos_attrib_xattr(idmap, dentry, &da);
+		rc = ksmbd_vfs_get_dos_attrib_xattr(&path, &da);
 		if (rc > 0) {
 			ksmbd_kstat->file_attributes = cpu_to_le32(da.attr);
 			ksmbd_kstat->create_time = da.create_time;
@@ -1936,7 +1918,7 @@ int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work,
 		char *xattr_list = NULL, *name;
 		ssize_t xattr_list_len;
 
-		xattr_list_len = ksmbd_vfs_listxattr(dentry, &xattr_list);
+		xattr_list_len = ksmbd_vfs_listxattr(&path, &xattr_list);
 		if (xattr_list_len > 0) {
 			for (name = xattr_list;
 			     name - xattr_list < xattr_list_len;
@@ -1954,14 +1936,14 @@ int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work,
 	return 0;
 }
 
-ssize_t ksmbd_vfs_casexattr_len(const struct mnt_idmap *idmap,
-				struct dentry *dentry, char *attr_name,
+ssize_t ksmbd_vfs_casexattr_len(const struct path *path,
+				char *attr_name,
 				int attr_name_len, char *actual_name)
 {
 	char *name, *xattr_list = NULL;
 	ssize_t value_len = -ENOENT, xattr_list_len;
 
-	xattr_list_len = ksmbd_vfs_listxattr(dentry, &xattr_list);
+	xattr_list_len = ksmbd_vfs_listxattr(path, &xattr_list);
 	if (xattr_list_len < 0) {
 		value_len = xattr_list_len;
 		goto out;
@@ -1977,7 +1959,7 @@ ssize_t ksmbd_vfs_casexattr_len(const struct mnt_idmap *idmap,
 		if (actual_name && strlen(name) + 1 != attr_name_len)
 			continue;
 
-		value_len = ksmbd_vfs_xattr_len(idmap, dentry, name);
+		value_len = ksmbd_vfs_xattr_len(path, name);
 		/* The caller provides attr_name_len bytes for the actual name. */
 		if (value_len >= 0 && actual_name)
 			memcpy(actual_name, name, attr_name_len);
@@ -2133,8 +2115,7 @@ int ksmbd_vfs_copy_file_ranges(struct ksmbd_work *work,
 
 		saved_cred = override_creds(src_fp->filp->f_cred);
 		src_file_size = ksmbd_vfs_casexattr_len(
-				file_mnt_idmap(src_fp->filp),
-				src_fp->filp->f_path.dentry,
+				&src_fp->filp->f_path,
 				src_fp->stream.name, src_fp->stream.size, NULL);
 		revert_creds(saved_cred);
 		if (src_file_size < 0)
@@ -2347,12 +2328,12 @@ int ksmbd_vfs_inherit_posix_acl(const struct mnt_idmap *idmap,
 	return 0;
 }
 
-void ksmbd_vfs_update_compressed_fattr(struct dentry *dentry, __le32 *fattr)
+void ksmbd_vfs_update_compressed_fattr(struct path *path, __le32 *fattr)
 {
 	int rc;
 	struct file_kattr fa = { .flags_valid = true };
 
-	rc = vfs_fileattr_get(dentry, &fa);
+	rc = vfs_fileattr_get(path, &fa);
 	if (rc)
 		return;
 
@@ -2365,7 +2346,7 @@ int ksmbd_vfs_get_compression(struct ksmbd_file *fp, u16 *fmt)
 	struct file_kattr fa = { .flags_valid = true };
 	int rc;
 
-	rc = vfs_fileattr_get(fp->filp->f_path.dentry, &fa);
+	rc = vfs_fileattr_get(&fp->filp->f_path, &fa);
 	if (rc == -ENOIOCTLCMD || rc == -ENOTTY || rc == -EINVAL ||
 	    rc == -EOPNOTSUPP) {
 		if (fp->f_ci->m_fattr & FILE_ATTRIBUTE_COMPRESSED_LE)
@@ -2393,8 +2374,6 @@ static int __ksmbd_vfs_set_compression(struct ksmbd_work *work,
 {
 	const struct cred *saved_cred = NULL;
 	struct file_kattr fa;
-	struct dentry *dentry = fp->filp->f_path.dentry;
-	const struct mnt_idmap *idmap = file_mnt_idmap(fp->filp);
 	u32 flags;
 	__le32 old_fattr;
 	int rc;
@@ -2412,7 +2391,7 @@ static int __ksmbd_vfs_set_compression(struct ksmbd_work *work,
 	}
 
 	saved_cred = override_creds(fp->filp->f_cred);
-	rc = vfs_fileattr_get(dentry, &fa);
+	rc = vfs_fileattr_get(&fp->filp->f_path, &fa);
 	if (rc == -ENOIOCTLCMD || rc == -ENOTTY || rc == -EINVAL ||
 	    rc == -EOPNOTSUPP)
 		goto update_fattr;
@@ -2433,7 +2412,7 @@ static int __ksmbd_vfs_set_compression(struct ksmbd_work *work,
 		if (rc)
 			goto out;
 
-		rc = vfs_fileattr_set(idmap, dentry, &fa);
+		rc = vfs_fileattr_set(&fp->filp->f_path, &fa);
 		mnt_drop_write_file(fp->filp);
 		if (rc == -ENOIOCTLCMD || rc == -ENOTTY || rc == -EINVAL ||
 		    rc == -EOPNOTSUPP)
@@ -2452,7 +2431,7 @@ static int __ksmbd_vfs_set_compression(struct ksmbd_work *work,
 	if (fp->f_ci->m_fattr != old_fattr) {
 		struct xattr_dos_attrib da = {0};
 
-		rc = ksmbd_vfs_get_dos_attrib_xattr(idmap, dentry, &da);
+		rc = ksmbd_vfs_get_dos_attrib_xattr(&fp->filp->f_path, &da);
 		if (rc <= 0) {
 			da.version = 4;
 			da.itime = fp->itime;
@@ -2463,8 +2442,7 @@ static int __ksmbd_vfs_set_compression(struct ksmbd_work *work,
 
 		da.attr = le32_to_cpu(fp->f_ci->m_fattr);
 		da.flags |= XATTR_DOSINFO_ATTRIB;
-		rc = ksmbd_vfs_set_dos_attrib_xattr(idmap,
-						    &fp->filp->f_path,
+		rc = ksmbd_vfs_set_dos_attrib_xattr(&fp->filp->f_path,
 						    &da, true);
 		if (rc)
 			rc = 0;
diff --git a/fs/smb/server/vfs.h b/fs/smb/server/vfs.h
index 21b0d29a3db0b..404cf98fe6074 100644
--- a/fs/smb/server/vfs.h
+++ b/fs/smb/server/vfs.h
@@ -104,27 +104,24 @@ int ksmbd_vfs_copy_file_ranges(struct ksmbd_work *work,
 			       unsigned int *chunk_count_written,
 			       unsigned int *chunk_size_written,
 			       loff_t  *total_size_written);
-ssize_t ksmbd_vfs_listxattr(struct dentry *dentry, char **list);
-ssize_t ksmbd_vfs_getxattr(const struct mnt_idmap *idmap,
-			   struct dentry *dentry,
+ssize_t ksmbd_vfs_listxattr(const struct path *path, char **list);
+ssize_t ksmbd_vfs_getxattr(const struct path *path,
 			   char *xattr_name,
 			   char **xattr_buf);
-ssize_t ksmbd_vfs_xattr_len(const struct mnt_idmap *idmap,
-			    struct dentry *dentry, char *xattr_name);
-ssize_t ksmbd_vfs_getcasexattr(const struct mnt_idmap *idmap,
-			       struct dentry *dentry, char *attr_name,
+ssize_t ksmbd_vfs_xattr_len(const struct path *path,
+			    char *xattr_name);
+ssize_t ksmbd_vfs_getcasexattr(const struct path *path,
+			       char *attr_name,
 			       int attr_name_len, char **attr_value);
-ssize_t ksmbd_vfs_casexattr_len(const struct mnt_idmap *idmap,
-				struct dentry *dentry, char *attr_name,
+ssize_t ksmbd_vfs_casexattr_len(const struct path *path,
+				char *attr_name,
 				int attr_name_len, char *actual_name);
-int ksmbd_vfs_setxattr(const struct mnt_idmap *idmap,
-		       const struct path *path, const char *attr_name,
+int ksmbd_vfs_setxattr(const struct path *path, const char *attr_name,
 		       void *attr_value, size_t attr_size, int flags,
 		       bool get_write);
 int ksmbd_vfs_xattr_stream_name(char *stream_name, char **xattr_stream_name,
 				size_t *xattr_stream_name_size, int s_type);
-int ksmbd_vfs_remove_xattr(const struct mnt_idmap *idmap,
-			   const struct path *path, char *attr_name,
+int ksmbd_vfs_remove_xattr(const struct path *path, char *attr_name,
 			   bool get_write);
 int ksmbd_vfs_kern_path(struct ksmbd_work *work, char *name,
 			unsigned int flags,
@@ -153,36 +150,30 @@ int ksmbd_vfs_query_allocated_ranges(struct ksmbd_file *fp, loff_t start,
 int ksmbd_vfs_unlink(struct file *filp);
 void *ksmbd_vfs_init_kstat(char **p, struct ksmbd_kstat *ksmbd_kstat);
 int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work,
-				const struct mnt_idmap *idmap,
 				struct dentry *dentry,
 				struct ksmbd_kstat *ksmbd_kstat);
 void ksmbd_vfs_posix_lock_wait(struct file_lock *flock);
 void ksmbd_vfs_posix_lock_unblock(struct file_lock *flock);
-int ksmbd_vfs_remove_acl_xattrs(const struct mnt_idmap *idmap,
-				const struct path *path);
-int ksmbd_vfs_remove_sd_xattrs(const struct mnt_idmap *idmap, const struct path *path);
+int ksmbd_vfs_remove_acl_xattrs(const struct path *path);
+int ksmbd_vfs_remove_sd_xattrs(const struct path *path);
 int ksmbd_vfs_set_sd_xattr(struct ksmbd_conn *conn,
-			   const struct mnt_idmap *idmap,
 			   const struct path *path,
 			   struct smb_ntsd *pntsd, int len,
 			   bool get_write);
 int ksmbd_vfs_get_sd_xattr(struct ksmbd_conn *conn,
-			   const struct mnt_idmap *idmap,
-			   struct dentry *dentry,
+			   const struct path *path,
 			   struct smb_ntsd **pntsd);
-int ksmbd_vfs_set_dos_attrib_xattr(const struct mnt_idmap *idmap,
-				   const struct path *path,
+int ksmbd_vfs_set_dos_attrib_xattr(const struct path *path,
 				   struct xattr_dos_attrib *da,
 				   bool get_write);
-int ksmbd_vfs_get_dos_attrib_xattr(const struct mnt_idmap *idmap,
-				   struct dentry *dentry,
+int ksmbd_vfs_get_dos_attrib_xattr(const struct path *path,
 				   struct xattr_dos_attrib *da);
 int ksmbd_vfs_set_init_posix_acl(const struct mnt_idmap *idmap,
 				 const struct path *path);
 int ksmbd_vfs_inherit_posix_acl(const struct mnt_idmap *idmap,
 				const struct path *path,
 				struct inode *parent_inode);
-void ksmbd_vfs_update_compressed_fattr(struct dentry *dentry, __le32 *fattr);
+void ksmbd_vfs_update_compressed_fattr(struct path *path, __le32 *fattr);
 int ksmbd_vfs_get_compression(struct ksmbd_file *fp, u16 *fmt);
 int ksmbd_vfs_set_compression(struct ksmbd_work *work, struct ksmbd_file *fp, u16 fmt);
 int ksmbd_vfs_set_compression_create(struct ksmbd_work *work,
diff --git a/fs/smb/server/vfs_cache.c b/fs/smb/server/vfs_cache.c
index 496055ce4a4d9..96385d1cdbb42 100644
--- a/fs/smb/server/vfs_cache.c
+++ b/fs/smb/server/vfs_cache.c
@@ -538,8 +538,7 @@ static void __ksmbd_inode_close(struct ksmbd_file *fp)
 			const struct cred *saved_cred;
 
 			saved_cred = override_creds(filp->f_cred);
-			err = ksmbd_vfs_remove_xattr(file_mnt_idmap(filp),
-						     &filp->f_path,
+			err = ksmbd_vfs_remove_xattr(&filp->f_path,
 						     fp->stream.name,
 						     true);
 			revert_creds(saved_cred);
diff --git a/fs/stat.c b/fs/stat.c
index a2e63c6c45b77..06e4a5dcea574 100644
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -172,7 +172,7 @@ EXPORT_SYMBOL_GPL(generic_fill_statx_atomic_writes);
  * @request_mask: STATX_xxx flags indicating what the caller wants
  * @query_flags: Query mode (AT_STATX_SYNC_TYPE)
  *
- * Get attributes without calling security_inode_getattr.
+ * Get attributes without calling security_path_getattr.
  *
  * Currently the only caller other than vfs_getattr is internal to the
  * filehandle lookup code, which uses only the inode number and returns no
@@ -260,7 +260,7 @@ int vfs_getattr(const struct path *path, struct kstat *stat,
 {
 	int retval;
 
-	retval = security_inode_getattr(path);
+	retval = security_path_getattr(path);
 	if (unlikely(retval))
 		return retval;
 	return vfs_getattr_nosec(path, stat, request_mask, query_flags);
diff --git a/fs/utimes.c b/fs/utimes.c
index e22664e4115f6..5de794587147c 100644
--- a/fs/utimes.c
+++ b/fs/utimes.c
@@ -64,8 +64,7 @@ int vfs_utimes(const struct path *path, struct timespec64 *times)
 	}
 retry_deleg:
 	inode_lock(inode);
-	error = notify_change(mnt_idmap(path->mnt), path->dentry, &newattrs,
-			      &delegated_inode);
+	error = notify_change(path, &newattrs, &delegated_inode);
 	inode_unlock(inode);
 	if (is_delegated(&delegated_inode)) {
 		error = break_deleg_wait(&delegated_inode);
diff --git a/fs/xattr.c b/fs/xattr.c
index d9f035610f0bf..5e960f4504883 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -285,8 +285,7 @@ int __vfs_setxattr_noperm(const struct mnt_idmap *idmap,
  * __vfs_setxattr_locked - set an extended attribute while holding the inode
  * lock
  *
- *  @idmap: idmap of the mount of the target inode
- *  @dentry: object to perform setxattr on
+ *  @path: object to perform setxattr on
  *  @name: xattr name to set
  *  @value: value to set @name to
  *  @size: size of @value
@@ -295,10 +294,12 @@ int __vfs_setxattr_noperm(const struct mnt_idmap *idmap,
  *  a delegation was broken on, NULL if none.
  */
 int
-__vfs_setxattr_locked(const struct mnt_idmap *idmap, struct dentry *dentry,
-		      const char *name, const void *value, size_t size,
-		      int flags, struct delegated_inode *delegated_inode)
+__vfs_setxattr_locked(const struct path *path, const char *name,
+		      const void *value, size_t size, int flags,
+		      struct delegated_inode *delegated_inode)
 {
+	const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
+	struct dentry *dentry = path->dentry;
 	struct inode *inode = dentry->d_inode;
 	int error;
 
@@ -306,7 +307,7 @@ __vfs_setxattr_locked(const struct mnt_idmap *idmap, struct dentry *dentry,
 	if (error)
 		return error;
 
-	error = security_inode_setxattr(idmap, dentry, name, value, size,
+	error = security_path_setxattr(path, name, value, size,
 					flags);
 	if (error)
 		goto out;
@@ -324,9 +325,11 @@ __vfs_setxattr_locked(const struct mnt_idmap *idmap, struct dentry *dentry,
 EXPORT_SYMBOL_GPL(__vfs_setxattr_locked);
 
 int
-vfs_setxattr(const struct mnt_idmap *idmap, struct dentry *dentry,
-	     const char *name, const void *value, size_t size, int flags)
+vfs_setxattr(const struct path *path, const char *name, const void *value,
+	     size_t size, int flags)
 {
+	const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
+	struct dentry *dentry = path->dentry;
 	struct inode *inode = dentry->d_inode;
 	struct delegated_inode delegated_inode = { };
 	const void  *orig_value = value;
@@ -341,7 +344,7 @@ vfs_setxattr(const struct mnt_idmap *idmap, struct dentry *dentry,
 
 retry_deleg:
 	inode_lock(inode);
-	error = __vfs_setxattr_locked(idmap, dentry, name, value, size,
+	error = __vfs_setxattr_locked(path, name, value, size,
 				      flags, &delegated_inode);
 	inode_unlock(inode);
 
@@ -448,9 +451,11 @@ __vfs_getxattr(struct dentry *dentry, struct inode *inode, const char *name,
 EXPORT_SYMBOL(__vfs_getxattr);
 
 ssize_t
-vfs_getxattr(const struct mnt_idmap *idmap, struct dentry *dentry,
-	     const char *name, void *value, size_t size)
+vfs_getxattr(const struct path *path, const char *name, void *value,
+	     size_t size)
 {
+	const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
+	struct dentry *dentry = path->dentry;
 	struct inode *inode = dentry->d_inode;
 	int error;
 
@@ -458,7 +463,7 @@ vfs_getxattr(const struct mnt_idmap *idmap, struct dentry *dentry,
 	if (error)
 		return error;
 
-	error = security_inode_getxattr(dentry, name);
+	error = security_path_getxattr(path, name);
 	if (error)
 		return error;
 
@@ -482,12 +487,12 @@ EXPORT_SYMBOL_GPL(vfs_getxattr);
 
 /**
  * vfs_listxattr - retrieve \0 separated list of xattr names
- * @dentry: the dentry from whose inode the xattr names are retrieved
+ * @path: the path from whose inode the xattr names are retrieved
  * @list: buffer to store xattr names into
  * @size: size of the buffer
  *
  * This function returns the names of all xattrs associated with the
- * inode of @dentry.
+ * inode of @path->dentry.
  *
  * Note, for legacy reasons the vfs_listxattr() function lists POSIX
  * ACLs as well. Since POSIX ACLs are decoupled from IOP_XATTR the
@@ -503,12 +508,13 @@ EXPORT_SYMBOL_GPL(vfs_getxattr);
  *         negative error code.
  */
 ssize_t
-vfs_listxattr(struct dentry *dentry, char *list, size_t size)
+vfs_listxattr(const struct path *path, char *list, size_t size)
 {
+	struct dentry *dentry = path->dentry;
 	struct inode *inode = d_inode(dentry);
 	ssize_t error;
 
-	error = security_inode_listxattr(dentry);
+	error = security_path_listxattr(path);
 	if (error)
 		return error;
 
@@ -550,17 +556,17 @@ EXPORT_SYMBOL(__vfs_removexattr);
  * __vfs_removexattr_locked - set an extended attribute while holding the inode
  * lock
  *
- *  @idmap: idmap of the mount of the target inode
- *  @dentry: object to perform setxattr on
+ *  @path: object to perform removexattr on
  *  @name: name of xattr to remove
  *  @delegated_inode: on return, will contain an inode pointer that
  *  a delegation was broken on, NULL if none.
  */
 int
-__vfs_removexattr_locked(const struct mnt_idmap *idmap,
-			 struct dentry *dentry, const char *name,
+__vfs_removexattr_locked(const struct path *path, const char *name,
 			 struct delegated_inode *delegated_inode)
 {
+	const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
+	struct dentry *dentry = path->dentry;
 	struct inode *inode = dentry->d_inode;
 	int error;
 
@@ -568,7 +574,7 @@ __vfs_removexattr_locked(const struct mnt_idmap *idmap,
 	if (error)
 		return error;
 
-	error = security_inode_removexattr(idmap, dentry, name);
+	error = security_path_removexattr(path, name);
 	if (error)
 		goto out;
 
@@ -589,17 +595,16 @@ __vfs_removexattr_locked(const struct mnt_idmap *idmap,
 EXPORT_SYMBOL_GPL(__vfs_removexattr_locked);
 
 int
-vfs_removexattr(const struct mnt_idmap *idmap, struct dentry *dentry,
-		const char *name)
+vfs_removexattr(const struct path *path, const char *name)
 {
+	struct dentry *dentry = path->dentry;
 	struct inode *inode = dentry->d_inode;
 	struct delegated_inode delegated_inode = { };
 	int error;
 
 retry_deleg:
 	inode_lock(inode);
-	error = __vfs_removexattr_locked(idmap, dentry,
-					 name, &delegated_inode);
+	error = __vfs_removexattr_locked(path, name, &delegated_inode);
 	inode_unlock(inode);
 
 	if (is_delegated(&delegated_inode)) {
@@ -652,14 +657,13 @@ int setxattr_copy(const char __user *name, struct kernel_xattr_ctx *ctx)
 	return error;
 }
 
-static int do_setxattr(const struct mnt_idmap *idmap, struct dentry *dentry,
-		struct kernel_xattr_ctx *ctx)
+static int do_setxattr(const struct path *path, struct kernel_xattr_ctx *ctx)
 {
 	if (is_posix_acl_xattr(ctx->kname->name))
-		return do_set_acl(idmap, dentry, ctx->kname->name,
+		return do_set_acl(path, ctx->kname->name,
 				  ctx->kvalue, ctx->size);
 
-	return vfs_setxattr(idmap, dentry, ctx->kname->name,
+	return vfs_setxattr(path, ctx->kname->name,
 			ctx->kvalue, ctx->size, ctx->flags);
 }
 
@@ -669,7 +673,7 @@ int file_setxattr(struct file *f, struct kernel_xattr_ctx *ctx)
 
 	if (!error) {
 		audit_file(f);
-		error = do_setxattr(file_mnt_idmap(f), f->f_path.dentry, ctx);
+		error = do_setxattr(&f->f_path, ctx);
 		mnt_drop_write_file(f);
 	}
 	return error;
@@ -687,7 +691,7 @@ int filename_setxattr(int dfd, struct filename *filename,
 		return error;
 	error = mnt_want_write(path.mnt);
 	if (!error) {
-		error = do_setxattr(mnt_idmap(path.mnt), path.dentry, ctx);
+		error = do_setxattr(&path, ctx);
 		mnt_drop_write(path.mnt);
 	}
 	path_put(&path);
@@ -787,8 +791,7 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
  * Extended attribute GET operations
  */
 static ssize_t
-do_getxattr(const struct mnt_idmap *idmap, struct dentry *d,
-	struct kernel_xattr_ctx *ctx)
+do_getxattr(const struct path *path, struct kernel_xattr_ctx *ctx)
 {
 	ssize_t error;
 	char *kname = ctx->kname->name;
@@ -803,9 +806,9 @@ do_getxattr(const struct mnt_idmap *idmap, struct dentry *d,
 	}
 
 	if (is_posix_acl_xattr(kname))
-		error = do_get_acl(idmap, d, kname, kvalue, ctx->size);
+		error = do_get_acl(path, kname, kvalue, ctx->size);
 	else
-		error = vfs_getxattr(idmap, d, kname, kvalue, ctx->size);
+		error = vfs_getxattr(path, kname, kvalue, ctx->size);
 	if (error > 0) {
 		if (ctx->size && copy_to_user(ctx->value, kvalue, error))
 			error = -EFAULT;
@@ -822,7 +825,7 @@ do_getxattr(const struct mnt_idmap *idmap, struct dentry *d,
 ssize_t file_getxattr(struct file *f, struct kernel_xattr_ctx *ctx)
 {
 	audit_file(f);
-	return do_getxattr(file_mnt_idmap(f), f->f_path.dentry, ctx);
+	return do_getxattr(&f->f_path, ctx);
 }
 
 ssize_t filename_getxattr(int dfd, struct filename *filename,
@@ -834,7 +837,7 @@ ssize_t filename_getxattr(int dfd, struct filename *filename,
 	error = filename_lookup(dfd, filename, lookup_flags, &path, NULL);
 	if (error)
 		return error;
-	error = do_getxattr(mnt_idmap(path.mnt), path.dentry, ctx);
+	error = do_getxattr(&path, ctx);
 	path_put(&path);
 	if (retry_estale(error, lookup_flags)) {
 		lookup_flags |= LOOKUP_REVAL;
@@ -925,7 +928,7 @@ SYSCALL_DEFINE4(fgetxattr, int, fd, const char __user *, name,
  * Extended attribute LIST operations
  */
 static ssize_t
-listxattr(struct dentry *d, char __user *list, size_t size)
+listxattr(const struct path *path, char __user *list, size_t size)
 {
 	ssize_t error;
 	char *klist = NULL;
@@ -938,7 +941,7 @@ listxattr(struct dentry *d, char __user *list, size_t size)
 			return -ENOMEM;
 	}
 
-	error = vfs_listxattr(d, klist, size);
+	error = vfs_listxattr(path, klist, size);
 	if (error > 0) {
 		if (size && copy_to_user(list, klist, error))
 			error = -EFAULT;
@@ -957,7 +960,7 @@ static
 ssize_t file_listxattr(struct file *f, char __user *list, size_t size)
 {
 	audit_file(f);
-	return listxattr(f->f_path.dentry, list, size);
+	return listxattr(&f->f_path, list, size);
 }
 
 static
@@ -971,7 +974,7 @@ ssize_t filename_listxattr(int dfd, struct filename *filename,
 	error = filename_lookup(dfd, filename, lookup_flags, &path, NULL);
 	if (error)
 		return error;
-	error = listxattr(path.dentry, list, size);
+	error = listxattr(&path, list, size);
 	path_put(&path);
 	if (retry_estale(error, lookup_flags)) {
 		lookup_flags |= LOOKUP_REVAL;
@@ -1029,11 +1032,11 @@ SYSCALL_DEFINE3(flistxattr, int, fd, char __user *, list, size_t, size)
  * Extended attribute REMOVE operations
  */
 static long
-removexattr(const struct mnt_idmap *idmap, struct dentry *d, const char *name)
+removexattr(const struct path *path, const char *name)
 {
 	if (is_posix_acl_xattr(name))
-		return vfs_remove_acl(idmap, d, name);
-	return vfs_removexattr(idmap, d, name);
+		return vfs_remove_acl(path, name);
+	return vfs_removexattr(path, name);
 }
 
 static int file_removexattr(struct file *f, struct xattr_name *kname)
@@ -1042,8 +1045,7 @@ static int file_removexattr(struct file *f, struct xattr_name *kname)
 
 	if (!error) {
 		audit_file(f);
-		error = removexattr(file_mnt_idmap(f),
-				    f->f_path.dentry, kname->name);
+		error = removexattr(&f->f_path, kname->name);
 		mnt_drop_write_file(f);
 	}
 	return error;
@@ -1061,7 +1063,7 @@ static int filename_removexattr(int dfd, struct filename *filename,
 		return error;
 	error = mnt_want_write(path.mnt);
 	if (!error) {
-		error = removexattr(mnt_idmap(path.mnt), path.dentry, kname->name);
+		error = removexattr(&path, kname->name);
 		mnt_drop_write(path.mnt);
 	}
 	path_put(&path);
diff --git a/include/linux/fileattr.h b/include/linux/fileattr.h
index 09e32b84e02ac..a572cb8500146 100644
--- a/include/linux/fileattr.h
+++ b/include/linux/fileattr.h
@@ -73,9 +73,11 @@ static inline bool fileattr_has_fsx(const struct file_kattr *fa)
 		 fa->fsx_projid != 0 ||	fa->fsx_cowextsize != 0);
 }
 
-int vfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa);
-int vfs_fileattr_set(const struct mnt_idmap *idmap, struct dentry *dentry,
-		     struct file_kattr *fa);
+int __vfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa);
+int __vfs_fileattr_set(const struct mnt_idmap *idmap, struct dentry *dentry,
+		       struct file_kattr *fa);
+int vfs_fileattr_get(const struct path *path, struct file_kattr *fa);
+int vfs_fileattr_set(const struct path *path, struct file_kattr *fa);
 int ioctl_getflags(struct file *file, unsigned int __user *argp);
 int ioctl_setflags(struct file *file, unsigned int __user *argp);
 int ioctl_fsgetxattr(struct file *file, void __user *argp);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index f387c961e0a0a..5db46082906c3 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2488,7 +2488,7 @@ static inline bool is_idmapped_mnt(const struct vfsmount *mnt)
 }
 
 int vfs_truncate(const struct path *, loff_t);
-int do_truncate(const struct mnt_idmap *, struct dentry *, loff_t start,
+int do_truncate(const struct path *path, loff_t length,
 		unsigned int time_attrs, struct file *filp);
 extern int vfs_fallocate(struct file *file, int mode, loff_t offset,
 			loff_t len);
@@ -2712,8 +2712,10 @@ static inline int bmap(struct inode *inode,  sector_t *block)
 }
 #endif
 
-int notify_change(const struct mnt_idmap *, struct dentry *,
-		  struct iattr *, struct delegated_inode *);
+int __notify_change(const struct mnt_idmap *, struct dentry *,
+		    struct iattr *, struct delegated_inode *);
+int notify_change(const struct path *path, struct iattr *attr,
+		  struct delegated_inode *delegated_inode);
 int inode_permission(const struct mnt_idmap *, struct inode *, int);
 int generic_permission(const struct mnt_idmap *, struct inode *, int);
 static inline int file_permission(struct file *file, int mask)
diff --git a/include/linux/landlock.h b/include/linux/landlock.h
index 0ee4880988bab..ee1234fbc9f06 100644
--- a/include/linux/landlock.h
+++ b/include/linux/landlock.h
@@ -41,7 +41,9 @@
 	_LANDLOCK_NAME_ENTRY(LANDLOCK_ACCESS_FS_REFER, "refer"), \
 	_LANDLOCK_NAME_ENTRY(LANDLOCK_ACCESS_FS_TRUNCATE, "truncate"), \
 	_LANDLOCK_NAME_ENTRY(LANDLOCK_ACCESS_FS_IOCTL_DEV, "ioctl_dev"), \
-	_LANDLOCK_NAME_ENTRY(LANDLOCK_ACCESS_FS_RESOLVE_UNIX, "resolve_unix")
+	_LANDLOCK_NAME_ENTRY(LANDLOCK_ACCESS_FS_RESOLVE_UNIX, "resolve_unix"), \
+	_LANDLOCK_NAME_ENTRY(LANDLOCK_ACCESS_FS_READ_METADATA, "read_metadata"), \
+	_LANDLOCK_NAME_ENTRY(LANDLOCK_ACCESS_FS_WRITE_METADATA, "write_metadata")
 
 #define _LANDLOCK_ACCESS_NET_NAMES \
 	_LANDLOCK_NAME_ENTRY(LANDLOCK_ACCESS_NET_BIND_TCP, "bind_tcp"), \
diff --git a/include/linux/lsm_hook_defs.h b/include/linux/lsm_hook_defs.h
index ef16e5343e099..9ea096505ef1f 100644
--- a/include/linux/lsm_hook_defs.h
+++ b/include/linux/lsm_hook_defs.h
@@ -142,33 +142,34 @@ LSM_HOOK(int, 0, inode_follow_link, struct dentry *dentry, struct inode *inode,
 	 bool rcu)
 LSM_HOOK(int, 0, inode_permission, const struct mnt_idmap *idmap,
 	 struct inode *inode, int mask)
-LSM_HOOK(int, 0, inode_setattr, const struct mnt_idmap *idmap, struct dentry *dentry,
+LSM_HOOK(int, 0, path_setattr, const struct path *path,
 	 struct iattr *attr)
 LSM_HOOK(void, LSM_RET_VOID, inode_post_setattr, const struct mnt_idmap *idmap,
 	 struct dentry *dentry, int ia_valid)
-LSM_HOOK(int, 0, inode_getattr, const struct path *path)
+LSM_HOOK(int, 0, path_getattr, const struct path *path)
 LSM_HOOK(int, 0, inode_xattr_skipcap, const char *name)
-LSM_HOOK(int, 0, inode_setxattr, const struct mnt_idmap *idmap,
-	 struct dentry *dentry, const char *name, const void *value,
-	 size_t size, int flags)
+LSM_HOOK(int, 0, path_setxattr, const struct path *path,
+	 const char *name, const void *value, size_t size, int flags)
 LSM_HOOK(void, LSM_RET_VOID, inode_post_setxattr, struct dentry *dentry,
 	 const char *name, const void *value, size_t size, int flags)
-LSM_HOOK(int, 0, inode_getxattr, struct dentry *dentry, const char *name)
-LSM_HOOK(int, 0, inode_listxattr, struct dentry *dentry)
-LSM_HOOK(int, 0, inode_removexattr, const struct mnt_idmap *idmap,
-	 struct dentry *dentry, const char *name)
+LSM_HOOK(int, 0, path_getxattr, const struct path *path, const char *name)
+LSM_HOOK(int, 0, path_listxattr, const struct path *path)
+LSM_HOOK(int, 0, path_removexattr, const struct path *path,
+	 const char *name)
 LSM_HOOK(void, LSM_RET_VOID, inode_post_removexattr, struct dentry *dentry,
 	 const char *name)
-LSM_HOOK(int, 0, inode_file_setattr, struct dentry *dentry, struct file_kattr *fa)
-LSM_HOOK(int, 0, inode_file_getattr, struct dentry *dentry, struct file_kattr *fa)
-LSM_HOOK(int, 0, inode_set_acl, const struct mnt_idmap *idmap,
-	 struct dentry *dentry, const char *acl_name, struct posix_acl *kacl)
+LSM_HOOK(int, 0, path_file_setattr, const struct path *path,
+	 struct file_kattr *fa)
+LSM_HOOK(int, 0, path_file_getattr, const struct path *path,
+	 struct file_kattr *fa)
+LSM_HOOK(int, 0, path_set_acl, const struct path *path,
+	 const char *acl_name, struct posix_acl *kacl)
 LSM_HOOK(void, LSM_RET_VOID, inode_post_set_acl, struct dentry *dentry,
 	 const char *acl_name, struct posix_acl *kacl)
-LSM_HOOK(int, 0, inode_get_acl, const struct mnt_idmap *idmap,
-	 struct dentry *dentry, const char *acl_name)
-LSM_HOOK(int, 0, inode_remove_acl, const struct mnt_idmap *idmap,
-	 struct dentry *dentry, const char *acl_name)
+LSM_HOOK(int, 0, path_get_acl, const struct path *path,
+	 const char *acl_name)
+LSM_HOOK(int, 0, path_remove_acl, const struct path *path,
+	 const char *acl_name)
 LSM_HOOK(void, LSM_RET_VOID, inode_post_remove_acl, const struct mnt_idmap *idmap,
 	 struct dentry *dentry, const char *acl_name)
 LSM_HOOK(int, 0, inode_need_killpriv, struct dentry *dentry)
@@ -314,7 +315,7 @@ LSM_HOOK(int, 0, secctx_to_secid, const char *secdata, u32 seclen, u32 *secid)
 LSM_HOOK(void, LSM_RET_VOID, release_secctx, struct lsm_context *cp)
 LSM_HOOK(void, LSM_RET_VOID, inode_invalidate_secctx, struct inode *inode)
 LSM_HOOK(int, 0, inode_notifysecctx, struct inode *inode, void *ctx, u32 ctxlen)
-LSM_HOOK(int, 0, inode_setsecctx, struct dentry *dentry, void *ctx, u32 ctxlen)
+LSM_HOOK(int, 0, path_setsecctx, const struct path *path, void *ctx, u32 ctxlen)
 LSM_HOOK(int, -EOPNOTSUPP, inode_getsecctx, struct inode *inode,
 	 struct lsm_context *cp)
 
diff --git a/include/linux/posix_acl.h b/include/linux/posix_acl.h
index caf500bed9933..44c23c4e9f946 100644
--- a/include/linux/posix_acl.h
+++ b/include/linux/posix_acl.h
@@ -105,12 +105,11 @@ static inline void cache_no_acl(struct inode *inode)
 	inode->i_default_acl = NULL;
 }
 
-int vfs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
-		const char *acl_name, struct posix_acl *kacl);
-struct posix_acl *vfs_get_acl(const struct mnt_idmap *idmap,
-			      struct dentry *dentry, const char *acl_name);
-int vfs_remove_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
-		   const char *acl_name);
+int vfs_set_acl(const struct path *path, const char *acl_name,
+		struct posix_acl *kacl);
+struct posix_acl *vfs_get_acl(const struct path *path,
+			      const char *acl_name);
+int vfs_remove_acl(const struct path *path, const char *acl_name);
 int posix_acl_listxattr(struct inode *inode, char **buffer,
 			ssize_t *remaining_size);
 #else
@@ -141,22 +140,20 @@ static inline void forget_all_cached_acls(struct inode *inode)
 {
 }
 
-static inline int vfs_set_acl(const struct mnt_idmap *idmap,
-			      struct dentry *dentry, const char *name,
+static inline int vfs_set_acl(const struct path *path, const char *name,
 			      struct posix_acl *acl)
 {
 	return -EOPNOTSUPP;
 }
 
-static inline struct posix_acl *vfs_get_acl(const struct mnt_idmap *idmap,
-					    struct dentry *dentry,
+static inline struct posix_acl *vfs_get_acl(const struct path *path,
 					    const char *acl_name)
 {
 	return ERR_PTR(-EOPNOTSUPP);
 }
 
-static inline int vfs_remove_acl(const struct mnt_idmap *idmap,
-				 struct dentry *dentry, const char *acl_name)
+static inline int vfs_remove_acl(const struct path *path,
+				 const char *acl_name)
 {
 	return -EOPNOTSUPP;
 }
diff --git a/include/linux/security.h b/include/linux/security.h
index 8b8d6b8b802f1..c99a050595c5b 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -185,10 +185,9 @@ extern int cap_capset(struct cred *new, const struct cred *old,
 		      const kernel_cap_t *inheritable,
 		      const kernel_cap_t *permitted);
 extern int cap_bprm_creds_from_file(struct linux_binprm *bprm, const struct file *file);
-int cap_inode_setxattr(struct dentry *dentry, const char *name,
+int cap_inode_setxattr(const struct path *path, const char *name,
 		       const void *value, size_t size, int flags);
-int cap_inode_removexattr(const struct mnt_idmap *idmap,
-			  struct dentry *dentry, const char *name);
+int cap_inode_removexattr(const struct path *path, const char *name);
 int cap_inode_need_killpriv(struct dentry *dentry);
 int cap_inode_killpriv(const struct mnt_idmap *idmap, struct dentry *dentry);
 int cap_inode_getsecurity(const struct mnt_idmap *idmap,
@@ -429,36 +428,32 @@ int security_inode_follow_link(struct dentry *dentry, struct inode *inode,
 			       bool rcu);
 int security_inode_permission(const struct mnt_idmap *idmap, struct inode *inode,
 			      int mask);
-int security_inode_setattr(const struct mnt_idmap *idmap,
-			   struct dentry *dentry, struct iattr *attr);
+int security_path_setattr(const struct path *path, struct iattr *attr);
 void security_inode_post_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
 				 int ia_valid);
-int security_inode_getattr(const struct path *path);
-int security_inode_setxattr(const struct mnt_idmap *idmap,
-			    struct dentry *dentry, const char *name,
-			    const void *value, size_t size, int flags);
-int security_inode_set_acl(const struct mnt_idmap *idmap,
-			   struct dentry *dentry, const char *acl_name,
-			   struct posix_acl *kacl);
+int security_path_getattr(const struct path *path);
+int security_path_setxattr(const struct path *path,
+			    const char *name, const void *value,
+			    size_t size, int flags);
+int security_path_set_acl(const struct path *path,
+			   const char *acl_name, struct posix_acl *kacl);
 void security_inode_post_set_acl(struct dentry *dentry, const char *acl_name,
 				 struct posix_acl *kacl);
-int security_inode_get_acl(const struct mnt_idmap *idmap,
-			   struct dentry *dentry, const char *acl_name);
-int security_inode_remove_acl(const struct mnt_idmap *idmap,
-			      struct dentry *dentry, const char *acl_name);
+int security_path_get_acl(const struct path *path, const char *acl_name);
+int security_path_remove_acl(const struct path *path, const char *acl_name);
 void security_inode_post_remove_acl(const struct mnt_idmap *idmap,
 				    struct dentry *dentry,
 				    const char *acl_name);
 void security_inode_post_setxattr(struct dentry *dentry, const char *name,
 				  const void *value, size_t size, int flags);
-int security_inode_getxattr(struct dentry *dentry, const char *name);
-int security_inode_listxattr(struct dentry *dentry);
-int security_inode_removexattr(const struct mnt_idmap *idmap,
-			       struct dentry *dentry, const char *name);
+int security_path_getxattr(const struct path *path, const char *name);
+int security_path_listxattr(const struct path *path);
+int security_path_removexattr(const struct path *path,
+			       const char *name);
 void security_inode_post_removexattr(struct dentry *dentry, const char *name);
-int security_inode_file_setattr(struct dentry *dentry,
+int security_path_file_setattr(const struct path *path,
 			      struct file_kattr *fa);
-int security_inode_file_getattr(struct dentry *dentry,
+int security_path_file_getattr(const struct path *path,
 			      struct file_kattr *fa);
 int security_inode_need_killpriv(struct dentry *dentry);
 int security_inode_killpriv(const struct mnt_idmap *idmap, struct dentry *dentry);
@@ -589,7 +584,7 @@ int security_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid);
 void security_release_secctx(struct lsm_context *cp);
 void security_inode_invalidate_secctx(struct inode *inode);
 int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen);
-int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen);
+int security_path_setsecctx(const struct path *path, void *ctx, u32 ctxlen);
 int security_inode_getsecctx(struct inode *inode, struct lsm_context *cp);
 int security_locked_down(enum lockdown_reason what);
 int lsm_fill_user_ctx(struct lsm_ctx __user *uctx, u32 *uctx_len,
@@ -1001,8 +996,7 @@ static inline int security_inode_permission(const struct mnt_idmap *idmap,
 	return 0;
 }
 
-static inline int security_inode_setattr(const struct mnt_idmap *idmap,
-					 struct dentry *dentry,
+static inline int security_path_setattr(const struct path *path,
 					 struct iattr *attr)
 {
 	return 0;
@@ -1013,20 +1007,18 @@ security_inode_post_setattr(const struct mnt_idmap *idmap, struct dentry *dentry
 			    int ia_valid)
 { }
 
-static inline int security_inode_getattr(const struct path *path)
+static inline int security_path_getattr(const struct path *path)
 {
 	return 0;
 }
 
-static inline int security_inode_setxattr(const struct mnt_idmap *idmap,
-		struct dentry *dentry, const char *name, const void *value,
-		size_t size, int flags)
+static inline int security_path_setxattr(const struct path *path,
+		const char *name, const void *value, size_t size, int flags)
 {
-	return cap_inode_setxattr(dentry, name, value, size, flags);
+	return cap_inode_setxattr(path, name, value, size, flags);
 }
 
-static inline int security_inode_set_acl(const struct mnt_idmap *idmap,
-					 struct dentry *dentry,
+static inline int security_path_set_acl(const struct path *path,
 					 const char *acl_name,
 					 struct posix_acl *kacl)
 {
@@ -1038,15 +1030,13 @@ static inline void security_inode_post_set_acl(struct dentry *dentry,
 					       struct posix_acl *kacl)
 { }
 
-static inline int security_inode_get_acl(const struct mnt_idmap *idmap,
-					 struct dentry *dentry,
+static inline int security_path_get_acl(const struct path *path,
 					 const char *acl_name)
 {
 	return 0;
 }
 
-static inline int security_inode_remove_acl(const struct mnt_idmap *idmap,
-					    struct dentry *dentry,
+static inline int security_path_remove_acl(const struct path *path,
 					    const char *acl_name)
 {
 	return 0;
@@ -1061,35 +1051,34 @@ static inline void security_inode_post_setxattr(struct dentry *dentry,
 		const char *name, const void *value, size_t size, int flags)
 { }
 
-static inline int security_inode_getxattr(struct dentry *dentry,
+static inline int security_path_getxattr(const struct path *path,
 			const char *name)
 {
 	return 0;
 }
 
-static inline int security_inode_listxattr(struct dentry *dentry)
+static inline int security_path_listxattr(const struct path *path)
 {
 	return 0;
 }
 
-static inline int security_inode_removexattr(const struct mnt_idmap *idmap,
-					     struct dentry *dentry,
+static inline int security_path_removexattr(const struct path *path,
 					     const char *name)
 {
-	return cap_inode_removexattr(idmap, dentry, name);
+	return cap_inode_removexattr(path, name);
 }
 
 static inline void security_inode_post_removexattr(struct dentry *dentry,
 						   const char *name)
 { }
 
-static inline int security_inode_file_setattr(struct dentry *dentry,
+static inline int security_path_file_setattr(const struct path *path,
 					      struct file_kattr *fa)
 {
 	return 0;
 }
 
-static inline int security_inode_file_getattr(struct dentry *dentry,
+static inline int security_path_file_getattr(const struct path *path,
 					      struct file_kattr *fa)
 {
 	return 0;
@@ -1637,7 +1626,7 @@ static inline int security_inode_notifysecctx(struct inode *inode, void *ctx, u3
 {
 	return -EOPNOTSUPP;
 }
-static inline int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen)
+static inline int security_path_setsecctx(const struct path *path, void *ctx, u32 ctxlen)
 {
 	return -EOPNOTSUPP;
 }
diff --git a/include/linux/xattr.h b/include/linux/xattr.h
index 4cc4257de084e..b0c980c7c3361 100644
--- a/include/linux/xattr.h
+++ b/include/linux/xattr.h
@@ -77,22 +77,22 @@ struct xattr {
 };
 
 ssize_t __vfs_getxattr(struct dentry *, struct inode *, const char *, void *, size_t);
-ssize_t vfs_getxattr(const struct mnt_idmap *, struct dentry *, const char *,
-		     void *, size_t);
-ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
+ssize_t vfs_getxattr(const struct path *path, const char *name, void *value,
+		     size_t size);
+ssize_t vfs_listxattr(const struct path *path, char *list, size_t size);
 int __vfs_setxattr(const struct mnt_idmap *, struct dentry *, struct inode *,
 		   const char *, const void *, size_t, int);
 int __vfs_setxattr_noperm(const struct mnt_idmap *, struct dentry *,
 			  const char *, const void *, size_t, int);
-int __vfs_setxattr_locked(const struct mnt_idmap *, struct dentry *,
-			  const char *, const void *, size_t, int,
-			  struct delegated_inode *);
-int vfs_setxattr(const struct mnt_idmap *, struct dentry *, const char *,
-		 const void *, size_t, int);
+int __vfs_setxattr_locked(const struct path *path, const char *name,
+			  const void *value, size_t size, int flags,
+			  struct delegated_inode *delegated_inode);
+int vfs_setxattr(const struct path *path, const char *name,
+		 const void *value, size_t size, int flags);
 int __vfs_removexattr(const struct mnt_idmap *, struct dentry *, const char *);
-int __vfs_removexattr_locked(const struct mnt_idmap *, struct dentry *,
-			     const char *, struct delegated_inode *);
-int vfs_removexattr(const struct mnt_idmap *, struct dentry *, const char *);
+int __vfs_removexattr_locked(const struct path *path, const char *name,
+			     struct delegated_inode *delegated_inode);
+int vfs_removexattr(const struct path *path, const char *name);
 
 ssize_t generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size);
 int vfs_getxattr_alloc(const struct mnt_idmap *idmap,
diff --git a/include/uapi/linux/landlock.h b/include/uapi/linux/landlock.h
index 24510e5d8479a..36dfb499e48e1 100644
--- a/include/uapi/linux/landlock.h
+++ b/include/uapi/linux/landlock.h
@@ -429,6 +429,25 @@ struct landlock_capability_attr {
  *
  *   The rationale for this design is described in
  *   :ref:`Documentation/security/landlock.rst <scoped-flags-interaction>`.
+ * - %LANDLOCK_ACCESS_FS_READ_METADATA: Read file or directory metadata (e.g.
+ *   inode attributes, extended attributes, and POSIX ACLs) through
+ *   :manpage:`stat(2)`, :manpage:`fstat(2)`, :manpage:`lstat(2)`,
+ *   :manpage:`newfstatat(2)`, :manpage:`getxattr(2)`, and
+ *   :manpage:`listxattr(2)`.
+ *
+ *   This access right is available since the thirteenth version of the
+ *   Landlock ABI.
+ * - %LANDLOCK_ACCESS_FS_WRITE_METADATA: Change file or directory metadata
+ *   (e.g. inode attributes, extended attributes, and POSIX ACLs) through
+ *   :manpage:`chmod(2)`, :manpage:`chown(2)`, :manpage:`utimensat(2)`,
+ *   :manpage:`setxattr(2)`, and :manpage:`removexattr(2)`, as well as related
+ *   system calls.  Implicit metadata changes performed by the kernel (e.g.
+ *   timestamp updates with :manpage:`write(2)`, or set-user-ID and
+ *   set-group-ID bit clearing with :manpage:`write(2)` or
+ *   :manpage:`truncate(2)`) are not restricted by this access right.
+ *
+ *   This access right is available since the thirteenth version of the
+ *   Landlock ABI.
  *
  * Whether an opened file can be truncated with :manpage:`ftruncate(2)` or used
  * with `ioctl(2)` is determined during :manpage:`open(2)`, in the same way as
@@ -493,9 +512,7 @@ struct landlock_capability_attr {
  *
  *   It is currently not possible to restrict some file-related actions
  *   accessible through these syscall families: :manpage:`chdir(2)`,
- *   :manpage:`stat(2)`, :manpage:`flock(2)`, :manpage:`chmod(2)`,
- *   :manpage:`chown(2)`, :manpage:`setxattr(2)`, :manpage:`utime(2)`,
- *   :manpage:`fcntl(2)`, :manpage:`access(2)`.
+ *   :manpage:`flock(2)`, :manpage:`fcntl(2)`, :manpage:`access(2)`.
  *   Future Landlock evolutions will enable to restrict them.
  */
 /* clang-format off */
@@ -516,6 +533,8 @@ struct landlock_capability_attr {
 #define LANDLOCK_ACCESS_FS_TRUNCATE			(1ULL << 14)
 #define LANDLOCK_ACCESS_FS_IOCTL_DEV			(1ULL << 15)
 #define LANDLOCK_ACCESS_FS_RESOLVE_UNIX			(1ULL << 16)
+#define LANDLOCK_ACCESS_FS_READ_METADATA		(1ULL << 17)
+#define LANDLOCK_ACCESS_FS_WRITE_METADATA		(1ULL << 18)
 /* clang-format on */
 
 /**
diff --git a/kernel/bpf/bpf_lsm.c b/kernel/bpf/bpf_lsm.c
index f58dce888ff4a..9d77714178127 100644
--- a/kernel/bpf/bpf_lsm.c
+++ b/kernel/bpf/bpf_lsm.c
@@ -335,18 +335,18 @@ BTF_ID(func, bpf_lsm_file_receive)
 
 BTF_ID(func, bpf_lsm_inode_create)
 BTF_ID(func, bpf_lsm_inode_free_security)
-BTF_ID(func, bpf_lsm_inode_getattr)
-BTF_ID(func, bpf_lsm_inode_getxattr)
+BTF_ID(func, bpf_lsm_path_getattr)
+BTF_ID(func, bpf_lsm_path_getxattr)
 BTF_ID(func, bpf_lsm_inode_mknod)
 BTF_ID(func, bpf_lsm_inode_need_killpriv)
 BTF_ID(func, bpf_lsm_inode_post_setxattr)
 BTF_ID(func, bpf_lsm_inode_post_removexattr)
 BTF_ID(func, bpf_lsm_inode_readlink)
-BTF_ID(func, bpf_lsm_inode_removexattr)
+BTF_ID(func, bpf_lsm_path_removexattr)
 BTF_ID(func, bpf_lsm_inode_rename)
 BTF_ID(func, bpf_lsm_inode_rmdir)
-BTF_ID(func, bpf_lsm_inode_setattr)
-BTF_ID(func, bpf_lsm_inode_setxattr)
+BTF_ID(func, bpf_lsm_path_setattr)
+BTF_ID(func, bpf_lsm_path_setxattr)
 BTF_ID(func, bpf_lsm_inode_symlink)
 BTF_ID(func, bpf_lsm_inode_unlink)
 BTF_ID(func, bpf_lsm_kernel_module_request)
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index 195f78db9bdaf..6f36647188429 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -961,7 +961,7 @@ BPF_CALL_3(bpf_d_path, const struct path *, path, char *, buf, u32, sz)
 BTF_SET_START(btf_allowlist_d_path)
 #ifdef CONFIG_SECURITY
 BTF_ID(func, security_file_permission)
-BTF_ID(func, security_inode_getattr)
+BTF_ID(func, security_path_getattr)
 BTF_ID(func, security_file_open)
 #endif
 #ifdef CONFIG_SECURITY_PATH
diff --git a/samples/landlock/sandboxer.c b/samples/landlock/sandboxer.c
index 1362f08ff14b9..29965ef90bed6 100644
--- a/samples/landlock/sandboxer.c
+++ b/samples/landlock/sandboxer.c
@@ -137,6 +137,8 @@ static int parse_path(char *env_path, const char ***const path_list)
 	LANDLOCK_ACCESS_FS_EXECUTE | \
 	LANDLOCK_ACCESS_FS_WRITE_FILE | \
 	LANDLOCK_ACCESS_FS_READ_FILE | \
+	LANDLOCK_ACCESS_FS_READ_METADATA | \
+	LANDLOCK_ACCESS_FS_WRITE_METADATA | \
 	LANDLOCK_ACCESS_FS_TRUNCATE | \
 	LANDLOCK_ACCESS_FS_IOCTL_DEV | \
 	LANDLOCK_ACCESS_FS_RESOLVE_UNIX)
@@ -487,7 +489,8 @@ static bool check_ruleset_scope(const char *const env_var,
 #define ACCESS_FS_ROUGHLY_READ ( \
 	LANDLOCK_ACCESS_FS_EXECUTE | \
 	LANDLOCK_ACCESS_FS_READ_FILE | \
-	LANDLOCK_ACCESS_FS_READ_DIR)
+	LANDLOCK_ACCESS_FS_READ_DIR | \
+	LANDLOCK_ACCESS_FS_READ_METADATA)
 
 #define ACCESS_FS_ROUGHLY_WRITE ( \
 	LANDLOCK_ACCESS_FS_WRITE_FILE | \
@@ -503,7 +506,8 @@ static bool check_ruleset_scope(const char *const env_var,
 	LANDLOCK_ACCESS_FS_REFER | \
 	LANDLOCK_ACCESS_FS_TRUNCATE | \
 	LANDLOCK_ACCESS_FS_IOCTL_DEV | \
-	LANDLOCK_ACCESS_FS_RESOLVE_UNIX)
+	LANDLOCK_ACCESS_FS_RESOLVE_UNIX | \
+	LANDLOCK_ACCESS_FS_WRITE_METADATA)
 
 /* clang-format on */
 
@@ -570,7 +574,7 @@ static int add_quiet_access(const char *const env_var,
 	return 0;
 }
 
-#define LANDLOCK_ABI_LAST 12
+#define LANDLOCK_ABI_LAST 13
 
 #define XSTR(s) #s
 #define STR(s) XSTR(s)
@@ -780,6 +784,12 @@ int main(const int argc, char *const argv[], char *const *const envp)
 		ruleset_attr.handled_permissions &=
 			~(LANDLOCK_PERMISSION_NAMESPACE_USE |
 			  LANDLOCK_PERMISSION_CAPABILITY_USE);
+		__attribute__((fallthrough));
+	case 12:
+		/* Removes metadata rights for ABI < 13 */
+		ruleset_attr.handled_access_fs &=
+			~(LANDLOCK_ACCESS_FS_READ_METADATA |
+			  LANDLOCK_ACCESS_FS_WRITE_METADATA);
 		/* Must be printed for any ABI < LANDLOCK_ABI_LAST. */
 		fprintf(stderr,
 			"Hint: You should update the running kernel "
diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
index 9d572cf8486b2..a2886f6ece786 100644
--- a/security/apparmor/lsm.c
+++ b/security/apparmor/lsm.c
@@ -456,7 +456,7 @@ static int apparmor_path_chown(const struct path *path, kuid_t uid, kgid_t gid)
 	return common_perm_cond(OP_CHOWN, path, AA_MAY_CHOWN);
 }
 
-static int apparmor_inode_getattr(const struct path *path)
+static int apparmor_path_getattr(const struct path *path)
 {
 	return common_perm_cond(OP_GETATTR, path, AA_MAY_GETATTR);
 }
@@ -1785,7 +1785,7 @@ static struct security_hook_list apparmor_hooks[] __ro_after_init = {
 	LSM_HOOK_INIT(path_chmod, apparmor_path_chmod),
 	LSM_HOOK_INIT(path_chown, apparmor_path_chown),
 	LSM_HOOK_INIT(path_truncate, apparmor_path_truncate),
-	LSM_HOOK_INIT(inode_getattr, apparmor_inode_getattr),
+	LSM_HOOK_INIT(path_getattr, apparmor_path_getattr),
 
 	LSM_HOOK_INIT(file_open, apparmor_file_open),
 	LSM_HOOK_INIT(file_receive, apparmor_file_receive),
diff --git a/security/commoncap.c b/security/commoncap.c
index 565c893c6d4b4..971994e9553e6 100644
--- a/security/commoncap.c
+++ b/security/commoncap.c
@@ -14,6 +14,7 @@
 #include <linux/netlink.h>
 #include <linux/ptrace.h>
 #include <linux/xattr.h>
+#include <linux/path.h>
 #include <linux/mount.h>
 #include <linux/sched.h>
 #include <linux/prctl.h>
@@ -1007,7 +1008,7 @@ int cap_bprm_creds_from_file(struct linux_binprm *bprm, const struct file *file)
 
 /**
  * cap_inode_setxattr - Determine whether an xattr may be altered
- * @dentry: The inode/dentry being altered
+ * @path: The inode/path being altered
  * @name: The name of the xattr to be changed
  * @value: The value that the xattr will be changed to
  * @size: The size of value
@@ -1019,9 +1020,10 @@ int cap_bprm_creds_from_file(struct linux_binprm *bprm, const struct file *file)
  * This is used to make sure security xattrs don't get updated or set by those
  * who aren't privileged to do so.
  */
-int cap_inode_setxattr(struct dentry *dentry, const char *name,
+int cap_inode_setxattr(const struct path *path, const char *name,
 		       const void *value, size_t size, int flags)
 {
+	struct dentry *dentry = path->dentry;
 	struct user_namespace *user_ns = dentry->d_sb->s_user_ns;
 
 	/* Ignore non-security xattrs */
@@ -1044,25 +1046,18 @@ int cap_inode_setxattr(struct dentry *dentry, const char *name,
 /**
  * cap_inode_removexattr - Determine whether an xattr may be removed
  *
- * @idmap:	idmap of the mount the inode was found from
- * @dentry:	The inode/dentry being altered
+ * @path:	The inode/path being altered
  * @name:	The name of the xattr to be changed
  *
  * Determine whether an xattr may be removed from an inode, returning 0 if
  * permission is granted, -ve if denied.
  *
- * If the inode has been found through an idmapped mount the idmap of
- * the vfsmount must be passed through @idmap. This function will then
- * take care to map the inode according to @idmap before checking
- * permissions. On non-idmapped mounts or if permission checking is to be
- * performed on the raw inode simply pass @nop_mnt_idmap.
- *
  * This is used to make sure security xattrs don't get removed by those who
  * aren't privileged to remove them.
  */
-int cap_inode_removexattr(const struct mnt_idmap *idmap,
-			  struct dentry *dentry, const char *name)
+int cap_inode_removexattr(const struct path *path, const char *name)
 {
+	struct dentry *dentry = path->dentry;
 	struct user_namespace *user_ns = dentry->d_sb->s_user_ns;
 
 	/* Ignore non-security xattrs */
@@ -1075,7 +1070,8 @@ int cap_inode_removexattr(const struct mnt_idmap *idmap,
 		struct inode *inode = d_backing_inode(dentry);
 		if (!inode)
 			return -EINVAL;
-		if (!capable_wrt_inode_uidgid(idmap, inode, CAP_SETFCAP))
+		if (!capable_wrt_inode_uidgid(mnt_idmap(path->mnt), inode,
+					      CAP_SETFCAP))
 			return -EPERM;
 		return 0;
 	}
diff --git a/security/integrity/evm/evm_crypto.c b/security/integrity/evm/evm_crypto.c
index 1c41af2f91a60..3d759efd3c6c3 100644
--- a/security/integrity/evm/evm_crypto.c
+++ b/security/integrity/evm/evm_crypto.c
@@ -237,7 +237,7 @@ static int evm_calc_hmac_or_hash(struct dentry *dentry,
 	size_t xattr_size = 0;
 	char *xattr_value = NULL;
 	int error;
-	int size, user_space_size;
+	int size;
 	bool ima_present = false;
 	u64 i_version = 0;
 
@@ -287,12 +287,6 @@ static int evm_calc_hmac_or_hash(struct dentry *dentry,
 		if (size < 0)
 			continue;
 
-		user_space_size = vfs_getxattr(&nop_mnt_idmap, dentry,
-					       xattr->name, NULL, 0);
-		if (user_space_size != size)
-			pr_debug("file %s: xattr %s size mismatch (kernel: %d, user: %d)\n",
-				 dentry->d_name.name, xattr->name, size,
-				 user_space_size);
 		error = 0;
 		xattr_size = size;
 		crypto_shash_update(desc, (const u8 *)xattr_value, xattr_size);
diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c
index ac8328812e6ef..5c2ce1d00fb88 100644
--- a/security/integrity/evm/evm_main.c
+++ b/security/integrity/evm/evm_main.c
@@ -7,8 +7,8 @@
  * Kylene Hall <kjhall@us.ibm.com>
  *
  * File: evm_main.c
- *	implements evm_inode_setxattr, evm_inode_post_setxattr,
- *	evm_inode_removexattr, evm_verifyxattr, and evm_inode_set_acl.
+ *	implements evm_path_setxattr, evm_inode_post_setxattr,
+ *	evm_path_removexattr, evm_verifyxattr, and evm_path_set_acl.
  */
 
 #define pr_fmt(fmt) "EVM: "fmt
@@ -593,9 +593,8 @@ static int evm_protect_xattr(const struct mnt_idmap *idmap,
 }
 
 /**
- * evm_inode_setxattr - protect the EVM extended attribute
- * @idmap: idmap of the mount
- * @dentry: pointer to the affected dentry
+ * evm_path_setxattr - protect the EVM extended attribute
+ * @path: pointer to the affected object
  * @xattr_name: pointer to the affected extended attribute name
  * @xattr_value: pointer to the new extended attribute value
  * @xattr_value_len: pointer to the new extended attribute value length
@@ -607,11 +606,13 @@ static int evm_protect_xattr(const struct mnt_idmap *idmap,
  * userspace from writing HMAC value.  Writing 'security.evm' requires
  * requires CAP_SYS_ADMIN privileges.
  */
-static int evm_inode_setxattr(const struct mnt_idmap *idmap, struct dentry *dentry,
+static int evm_path_setxattr(const struct path *path,
 			      const char *xattr_name, const void *xattr_value,
 			      size_t xattr_value_len, int flags)
 {
 	const struct evm_ima_xattr_data *xattr_data = xattr_value;
+	struct dentry *dentry = path->dentry;
+	const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
 
 	/* Policy permits modification of the protected xattrs even though
 	 * there's no HMAC key loaded
@@ -631,17 +632,19 @@ static int evm_inode_setxattr(const struct mnt_idmap *idmap, struct dentry *dent
 }
 
 /**
- * evm_inode_removexattr - protect the EVM extended attribute
- * @idmap: idmap of the mount
- * @dentry: pointer to the affected dentry
+ * evm_path_removexattr - protect the EVM extended attribute
+ * @path: pointer to the affected object
  * @xattr_name: pointer to the affected extended attribute name
  *
  * Removing 'security.evm' requires CAP_SYS_ADMIN privileges and that
  * the current value is valid.
  */
-static int evm_inode_removexattr(const struct mnt_idmap *idmap, struct dentry *dentry,
+static int evm_path_removexattr(const struct path *path,
 				 const char *xattr_name)
 {
+	struct dentry *dentry = path->dentry;
+	const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
+
 	/* Policy permits modification of the protected xattrs even though
 	 * there's no HMAC key loaded
 	 */
@@ -681,9 +684,8 @@ static inline int evm_inode_set_acl_change(const struct mnt_idmap *idmap,
 #endif
 
 /**
- * evm_inode_set_acl - protect the EVM extended attribute from posix acls
- * @idmap: idmap of the idmapped mount
- * @dentry: pointer to the affected dentry
+ * evm_path_set_acl - protect the EVM extended attribute from posix acls
+ * @path: pointer to the affected object
  * @acl_name: name of the posix acl
  * @kacl: pointer to the posix acls
  *
@@ -693,10 +695,12 @@ static inline int evm_inode_set_acl_change(const struct mnt_idmap *idmap,
  *
  * Return: zero on success, -EPERM on failure.
  */
-static int evm_inode_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
+static int evm_path_set_acl(const struct path *path,
 			     const char *acl_name, struct posix_acl *kacl)
 {
 	enum integrity_status evm_status;
+	struct dentry *dentry = path->dentry;
+	const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
 
 	/* Policy permits modification of the protected xattrs even though
 	 * there's no HMAC key loaded
@@ -734,9 +738,8 @@ static int evm_inode_set_acl(const struct mnt_idmap *idmap, struct dentry *dentr
 }
 
 /**
- * evm_inode_remove_acl - Protect the EVM extended attribute from posix acls
- * @idmap: idmap of the mount
- * @dentry: pointer to the affected dentry
+ * evm_path_remove_acl - Protect the EVM extended attribute from posix acls
+ * @path: pointer to the affected object
  * @acl_name: name of the posix acl
  *
  * Prevent removing posix acls causing the EVM HMAC to be re-calculated
@@ -745,10 +748,10 @@ static int evm_inode_set_acl(const struct mnt_idmap *idmap, struct dentry *dentr
  *
  * Return: zero on success, -EPERM on failure.
  */
-static int evm_inode_remove_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
+static int evm_path_remove_acl(const struct path *path,
 				const char *acl_name)
 {
-	return evm_inode_set_acl(idmap, dentry, acl_name, NULL);
+	return evm_path_set_acl(path, acl_name, NULL);
 }
 
 static void evm_reset_status(struct inode *inode)
@@ -948,19 +951,20 @@ static int evm_attr_change(const struct mnt_idmap *idmap,
 }
 
 /**
- * evm_inode_setattr - prevent updating an invalid EVM extended attribute
- * @idmap: idmap of the mount
- * @dentry: pointer to the affected dentry
+ * evm_path_setattr - prevent updating an invalid EVM extended attribute
+ * @path: pointer to the affected object
  * @attr: iattr structure containing the new file attributes
  *
  * Permit update of file attributes when files have a valid EVM signature,
  * except in the case of them having an immutable portable signature.
  */
-static int evm_inode_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
+static int evm_path_setattr(const struct path *path,
 			     struct iattr *attr)
 {
 	unsigned int ia_valid = attr->ia_valid;
 	enum integrity_status evm_status;
+	struct dentry *dentry = path->dentry;
+	const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
 
 	/* Policy permits modification of the protected attrs even though
 	 * there's no HMAC key loaded
@@ -1195,16 +1199,16 @@ static int __init init_evm(void)
 }
 
 static struct security_hook_list evm_hooks[] __ro_after_init = {
-	LSM_HOOK_INIT(inode_setattr, evm_inode_setattr),
+	LSM_HOOK_INIT(path_setattr, evm_path_setattr),
 	LSM_HOOK_INIT(inode_post_setattr, evm_inode_post_setattr),
 	LSM_HOOK_INIT(inode_copy_up_xattr, evm_inode_copy_up_xattr),
-	LSM_HOOK_INIT(inode_setxattr, evm_inode_setxattr),
+	LSM_HOOK_INIT(path_setxattr, evm_path_setxattr),
 	LSM_HOOK_INIT(inode_post_setxattr, evm_inode_post_setxattr),
-	LSM_HOOK_INIT(inode_set_acl, evm_inode_set_acl),
+	LSM_HOOK_INIT(path_set_acl, evm_path_set_acl),
 	LSM_HOOK_INIT(inode_post_set_acl, evm_inode_post_set_acl),
-	LSM_HOOK_INIT(inode_remove_acl, evm_inode_remove_acl),
+	LSM_HOOK_INIT(path_remove_acl, evm_path_remove_acl),
 	LSM_HOOK_INIT(inode_post_remove_acl, evm_inode_post_remove_acl),
-	LSM_HOOK_INIT(inode_removexattr, evm_inode_removexattr),
+	LSM_HOOK_INIT(path_removexattr, evm_path_removexattr),
 	LSM_HOOK_INIT(inode_post_removexattr, evm_inode_post_removexattr),
 	LSM_HOOK_INIT(inode_init_security, evm_inode_init_security),
 	LSM_HOOK_INIT(inode_alloc_security, evm_inode_alloc_security),
diff --git a/security/integrity/ima/ima_appraise.c b/security/integrity/ima/ima_appraise.c
index 134174d2e3f0e..f5068f881a245 100644
--- a/security/integrity/ima/ima_appraise.c
+++ b/security/integrity/ima/ima_appraise.c
@@ -759,11 +759,12 @@ static int validate_hash_algo(struct dentry *dentry,
 	return -EACCES;
 }
 
-static int ima_inode_setxattr(const struct mnt_idmap *idmap, struct dentry *dentry,
+static int ima_path_setxattr(const struct path *path,
 			      const char *xattr_name, const void *xattr_value,
 			      size_t xattr_value_len, int flags)
 {
 	const struct evm_ima_xattr_data *xvalue = xattr_value;
+	struct dentry *dentry = path->dentry;
 	int digsig = 0;
 	int result;
 	int err;
@@ -792,43 +793,43 @@ static int ima_inode_setxattr(const struct mnt_idmap *idmap, struct dentry *dent
 	return result;
 }
 
-static int ima_inode_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
+static int ima_path_set_acl(const struct path *path,
 			     const char *acl_name, struct posix_acl *kacl)
 {
 	if (evm_revalidate_status(acl_name))
-		ima_reset_appraise_flags(d_backing_inode(dentry), -1);
+		ima_reset_appraise_flags(d_backing_inode(path->dentry), -1);
 
 	return 0;
 }
 
-static int ima_inode_removexattr(const struct mnt_idmap *idmap, struct dentry *dentry,
+static int ima_path_removexattr(const struct path *path,
 				 const char *xattr_name)
 {
 	int result, digsig = -1;
 
-	result = ima_protect_xattr(dentry, xattr_name, NULL, 0);
+	result = ima_protect_xattr(path->dentry, xattr_name, NULL, 0);
 	if (result == 1 || evm_revalidate_status(xattr_name)) {
 		if (!strcmp(xattr_name, XATTR_NAME_IMA))
 			digsig = 0;
-		ima_reset_appraise_flags(d_backing_inode(dentry), digsig);
+		ima_reset_appraise_flags(d_backing_inode(path->dentry), digsig);
 		if (result == 1)
 			result = 0;
 	}
 	return result;
 }
 
-static int ima_inode_remove_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
+static int ima_path_remove_acl(const struct path *path,
 				const char *acl_name)
 {
-	return ima_inode_set_acl(idmap, dentry, acl_name, NULL);
+	return ima_path_set_acl(path, acl_name, NULL);
 }
 
 static struct security_hook_list ima_appraise_hooks[] __ro_after_init = {
 	LSM_HOOK_INIT(inode_post_setattr, ima_inode_post_setattr),
-	LSM_HOOK_INIT(inode_setxattr, ima_inode_setxattr),
-	LSM_HOOK_INIT(inode_set_acl, ima_inode_set_acl),
-	LSM_HOOK_INIT(inode_removexattr, ima_inode_removexattr),
-	LSM_HOOK_INIT(inode_remove_acl, ima_inode_remove_acl),
+	LSM_HOOK_INIT(path_setxattr, ima_path_setxattr),
+	LSM_HOOK_INIT(path_set_acl, ima_path_set_acl),
+	LSM_HOOK_INIT(path_removexattr, ima_path_removexattr),
+	LSM_HOOK_INIT(path_remove_acl, ima_path_remove_acl),
 };
 
 void __init init_ima_appraise_lsm(const struct lsm_id *lsmid)
diff --git a/security/landlock/fs.c b/security/landlock/fs.c
index a8fa8f77e775d..1bca7558ea9f9 100644
--- a/security/landlock/fs.c
+++ b/security/landlock/fs.c
@@ -318,6 +318,8 @@ static struct landlock_object *get_inode_object(struct inode *const inode)
 	LANDLOCK_ACCESS_FS_EXECUTE | \
 	LANDLOCK_ACCESS_FS_WRITE_FILE | \
 	LANDLOCK_ACCESS_FS_READ_FILE | \
+	LANDLOCK_ACCESS_FS_READ_METADATA | \
+	LANDLOCK_ACCESS_FS_WRITE_METADATA | \
 	LANDLOCK_ACCESS_FS_TRUNCATE | \
 	LANDLOCK_ACCESS_FS_IOCTL_DEV | \
 	LANDLOCK_ACCESS_FS_RESOLVE_UNIX)
@@ -1676,6 +1678,119 @@ static int hook_path_truncate(const struct path *const path)
 	return current_check_access_path(path, LANDLOCK_ACCESS_FS_TRUNCATE);
 }
 
+static int hook_path_getattr(const struct path *const path)
+{
+	return current_check_access_path(path,
+					LANDLOCK_ACCESS_FS_READ_METADATA);
+}
+
+static int hook_path_file_getattr(const struct path *const path,
+				   struct file_kattr *const fa)
+{
+	return current_check_access_path(path,
+					LANDLOCK_ACCESS_FS_READ_METADATA);
+}
+
+static int hook_path_setattr(const struct path *const path,
+			      struct iattr *const attr)
+{
+	unsigned int ia_valid = attr->ia_valid;
+
+	/*
+	 * Only explicit metadata changes are checked: implicit
+	 * timestamp updates never go through notify_change(), and size
+	 * changes (ATTR_SIZE) are governed by the truncate hooks
+	 * instead.  See the "File metadata" section in the user space
+	 * documentation for the full semantics.
+	 *
+	 * Clearing the setuid and setgid bits on write(2) or
+	 * truncate(2) is also an implicit change: callers request it
+	 * with ATTR_KILL_S[UG]ID, and do_notify_change() then adds a
+	 * synthesized ATTR_MODE (with these bits removed) before
+	 * calling this hook.  As do_notify_change() makes it a bug for
+	 * callers to pass ATTR_MODE together with a kill flag, an
+	 * ATTR_MODE seen along with ATTR_KILL_S[UG]ID is always
+	 * kernel-synthesized and must not be checked.  An explicit
+	 * chmod(2) never sets a kill flag, and an explicit chown(2) on
+	 * a privileged file is still checked thanks to ATTR_UID and
+	 * ATTR_GID.
+	 */
+	if (ia_valid & (ATTR_KILL_SUID | ATTR_KILL_SGID))
+		ia_valid &= ~ATTR_MODE;
+
+	if (!(ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID |
+			  ATTR_TIMES_SET | ATTR_TOUCH)))
+		return 0;
+
+	return current_check_access_path(path,
+					LANDLOCK_ACCESS_FS_WRITE_METADATA);
+}
+
+static int hook_path_file_setattr(const struct path *const path,
+				   struct file_kattr *const fa)
+{
+	/*
+	 * The chattr(2) style flags (e.g. FS_IMMUTABLE_FL) and fsxattr
+	 * fields are metadata: writing them requires WRITE_METADATA.  The
+	 * user-facing path is checked here; stacking filesystems skip this
+	 * hook on their internal forwards because they were already
+	 * checked on the user-facing path.
+	 */
+	return current_check_access_path(path,
+					LANDLOCK_ACCESS_FS_WRITE_METADATA);
+}
+
+static int hook_path_setxattr(const struct path *const path,
+			       const char *const name,
+			       const void *const value, const size_t size,
+			       const int flags)
+{
+	return current_check_access_path(path,
+					LANDLOCK_ACCESS_FS_WRITE_METADATA);
+}
+
+static int hook_path_getxattr(const struct path *const path,
+			       const char *const name)
+{
+	return current_check_access_path(path,
+					LANDLOCK_ACCESS_FS_READ_METADATA);
+}
+
+static int hook_path_listxattr(const struct path *const path)
+{
+	return current_check_access_path(path,
+					LANDLOCK_ACCESS_FS_READ_METADATA);
+}
+
+static int hook_path_removexattr(const struct path *const path,
+				  const char *const name)
+{
+	return current_check_access_path(path,
+					LANDLOCK_ACCESS_FS_WRITE_METADATA);
+}
+
+static int hook_path_set_acl(const struct path *const path,
+			      const char *const acl_name,
+			      struct posix_acl *const kacl)
+{
+	return current_check_access_path(path,
+					LANDLOCK_ACCESS_FS_WRITE_METADATA);
+}
+
+static int hook_path_get_acl(const struct path *const path,
+			      const char *const acl_name)
+{
+	return current_check_access_path(path,
+					LANDLOCK_ACCESS_FS_READ_METADATA);
+}
+
+static int hook_path_remove_acl(const struct path *const path,
+				 const char *const acl_name)
+{
+	return current_check_access_path(path,
+					LANDLOCK_ACCESS_FS_WRITE_METADATA);
+}
+
 /**
  * unmask_scoped_access - Remove access right bits in @masks in all layers
  *                        where @client and @server have the same domain
@@ -2100,6 +2215,17 @@ static struct security_hook_list landlock_hooks[] __ro_after_init = {
 	LSM_HOOK_INIT(path_unlink, hook_path_unlink),
 	LSM_HOOK_INIT(path_rmdir, hook_path_rmdir),
 	LSM_HOOK_INIT(path_truncate, hook_path_truncate),
+	LSM_HOOK_INIT(path_getattr, hook_path_getattr),
+	LSM_HOOK_INIT(path_file_getattr, hook_path_file_getattr),
+	LSM_HOOK_INIT(path_setattr, hook_path_setattr),
+	LSM_HOOK_INIT(path_file_setattr, hook_path_file_setattr),
+	LSM_HOOK_INIT(path_setxattr, hook_path_setxattr),
+	LSM_HOOK_INIT(path_getxattr, hook_path_getxattr),
+	LSM_HOOK_INIT(path_listxattr, hook_path_listxattr),
+	LSM_HOOK_INIT(path_removexattr, hook_path_removexattr),
+	LSM_HOOK_INIT(path_set_acl, hook_path_set_acl),
+	LSM_HOOK_INIT(path_get_acl, hook_path_get_acl),
+	LSM_HOOK_INIT(path_remove_acl, hook_path_remove_acl),
 	LSM_HOOK_INIT(unix_find, hook_unix_find),
 
 	LSM_HOOK_INIT(file_alloc_security, hook_file_alloc_security),
diff --git a/security/landlock/limits.h b/security/landlock/limits.h
index ddd300e10689f..ed606ee3102f4 100644
--- a/security/landlock/limits.h
+++ b/security/landlock/limits.h
@@ -21,7 +21,7 @@
 #define LANDLOCK_MAX_NUM_LAYERS		16
 #define LANDLOCK_MAX_NUM_RULES		U32_MAX
 
-#define LANDLOCK_LAST_ACCESS_FS		LANDLOCK_ACCESS_FS_RESOLVE_UNIX
+#define LANDLOCK_LAST_ACCESS_FS		LANDLOCK_ACCESS_FS_WRITE_METADATA
 #define LANDLOCK_MASK_ACCESS_FS		((LANDLOCK_LAST_ACCESS_FS << 1) - 1)
 #define LANDLOCK_NUM_ACCESS_FS		__const_hweight64(LANDLOCK_MASK_ACCESS_FS)
 
diff --git a/security/landlock/syscalls.c b/security/landlock/syscalls.c
index fb5af318b69bb..11d3a2abcec13 100644
--- a/security/landlock/syscalls.c
+++ b/security/landlock/syscalls.c
@@ -191,7 +191,7 @@ static const struct file_operations ruleset_fops = {
  * If the change involves a fix that requires userspace awareness, also update
  * the errata documentation in Documentation/userspace-api/landlock.rst .
  */
-const int landlock_abi_version = 12;
+const int landlock_abi_version = 13;
 
 /**
  * sys_landlock_create_ruleset - Create a new ruleset
diff --git a/security/security.c b/security/security.c
index da8d48cd0a2a4..7c17300989b67 100644
--- a/security/security.c
+++ b/security/security.c
@@ -1890,9 +1890,8 @@ int security_inode_permission(const struct mnt_idmap *idmap, struct inode *inode
 }
 
 /**
- * security_inode_setattr() - Check if setting file attributes is allowed
- * @idmap: idmap of the mount
- * @dentry: file
+ * security_path_setattr() - Check if setting file attributes is allowed
+ * @path: file
  * @attr: new attributes
  *
  * Check permission before setting file attributes.  Note that the kernel call
@@ -1902,14 +1901,13 @@ int security_inode_permission(const struct mnt_idmap *idmap, struct inode *inode
  *
  * Return: Returns 0 if permission is granted.
  */
-int security_inode_setattr(const struct mnt_idmap *idmap,
-			   struct dentry *dentry, struct iattr *attr)
+int security_path_setattr(const struct path *path, struct iattr *attr)
 {
-	if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
+	if (unlikely(IS_PRIVATE(d_backing_inode(path->dentry))))
 		return 0;
-	return call_int_hook(inode_setattr, idmap, dentry, attr);
+	return call_int_hook(path_setattr, path, attr);
 }
-EXPORT_SYMBOL_GPL(security_inode_setattr);
+EXPORT_SYMBOL_GPL(security_path_setattr);
 
 /**
  * security_inode_post_setattr() - Update the inode after a setattr operation
@@ -1928,31 +1926,30 @@ void security_inode_post_setattr(const struct mnt_idmap *idmap, struct dentry *d
 }
 
 /**
- * security_inode_getattr() - Check if getting file attributes is allowed
+ * security_path_getattr() - Check if getting file attributes is allowed
  * @path: file
  *
  * Check permission before obtaining file attributes.
  *
  * Return: Returns 0 if permission is granted.
  */
-int security_inode_getattr(const struct path *path)
+int security_path_getattr(const struct path *path)
 {
 	if (unlikely(IS_PRIVATE(d_backing_inode(path->dentry))))
 		return 0;
-	return call_int_hook(inode_getattr, path);
+	return call_int_hook(path_getattr, path);
 }
 
 /**
- * security_inode_setxattr() - Check if setting file xattrs is allowed
- * @idmap: idmap of the mount
- * @dentry: file
+ * security_path_setxattr() - Check if setting file xattrs is allowed
+ * @path: file
  * @name: xattr name
  * @value: xattr value
  * @size: size of xattr value
  * @flags: flags
  *
  * This hook performs the desired permission checks before setting the extended
- * attributes (xattrs) on @dentry.  It is important to note that we have some
+ * attributes (xattrs) on @path.  It is important to note that we have some
  * additional logic before the main LSM implementation calls to detect if we
  * need to perform an additional capability check at the LSM layer.
  *
@@ -1968,30 +1965,29 @@ int security_inode_getattr(const struct path *path)
  *
  * Return: Returns 0 if permission is granted.
  */
-int security_inode_setxattr(const struct mnt_idmap *idmap,
-			    struct dentry *dentry, const char *name,
-			    const void *value, size_t size, int flags)
+int security_path_setxattr(const struct path *path,
+			    const char *name, const void *value,
+			    size_t size, int flags)
 {
 	int rc;
 
-	if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
+	if (unlikely(IS_PRIVATE(d_backing_inode(path->dentry))))
 		return 0;
 
 	/* enforce the capability checks at the lsm layer, if needed */
 	if (!call_int_hook(inode_xattr_skipcap, name)) {
-		rc = cap_inode_setxattr(dentry, name, value, size, flags);
+		rc = cap_inode_setxattr(path, name, value, size, flags);
 		if (rc)
 			return rc;
 	}
 
-	return call_int_hook(inode_setxattr, idmap, dentry, name, value, size,
+	return call_int_hook(path_setxattr, path, name, value, size,
 			     flags);
 }
 
 /**
- * security_inode_set_acl() - Check if setting posix acls is allowed
- * @idmap: idmap of the mount
- * @dentry: file
+ * security_path_set_acl() - Check if setting posix acls is allowed
+ * @path: file
  * @acl_name: acl name
  * @kacl: acl struct
  *
@@ -2000,13 +1996,12 @@ int security_inode_setxattr(const struct mnt_idmap *idmap,
  *
  * Return: Returns 0 if permission is granted.
  */
-int security_inode_set_acl(const struct mnt_idmap *idmap,
-			   struct dentry *dentry, const char *acl_name,
-			   struct posix_acl *kacl)
+int security_path_set_acl(const struct path *path,
+			   const char *acl_name, struct posix_acl *kacl)
 {
-	if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
+	if (unlikely(IS_PRIVATE(d_backing_inode(path->dentry))))
 		return 0;
-	return call_int_hook(inode_set_acl, idmap, dentry, acl_name, kacl);
+	return call_int_hook(path_set_acl, path, acl_name, kacl);
 }
 
 /**
@@ -2027,9 +2022,8 @@ void security_inode_post_set_acl(struct dentry *dentry, const char *acl_name,
 }
 
 /**
- * security_inode_get_acl() - Check if reading posix acls is allowed
- * @idmap: idmap of the mount
- * @dentry: file
+ * security_path_get_acl() - Check if reading posix acls is allowed
+ * @path: file
  * @acl_name: acl name
  *
  * Check permission before getting osix acls, the posix acls are identified by
@@ -2037,18 +2031,16 @@ void security_inode_post_set_acl(struct dentry *dentry, const char *acl_name,
  *
  * Return: Returns 0 if permission is granted.
  */
-int security_inode_get_acl(const struct mnt_idmap *idmap,
-			   struct dentry *dentry, const char *acl_name)
+int security_path_get_acl(const struct path *path, const char *acl_name)
 {
-	if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
+	if (unlikely(IS_PRIVATE(d_backing_inode(path->dentry))))
 		return 0;
-	return call_int_hook(inode_get_acl, idmap, dentry, acl_name);
+	return call_int_hook(path_get_acl, path, acl_name);
 }
 
 /**
- * security_inode_remove_acl() - Check if removing a posix acl is allowed
- * @idmap: idmap of the mount
- * @dentry: file
+ * security_path_remove_acl() - Check if removing a posix acl is allowed
+ * @path: file
  * @acl_name: acl name
  *
  * Check permission before removing posix acls, the posix acls are identified
@@ -2056,12 +2048,11 @@ int security_inode_get_acl(const struct mnt_idmap *idmap,
  *
  * Return: Returns 0 if permission is granted.
  */
-int security_inode_remove_acl(const struct mnt_idmap *idmap,
-			      struct dentry *dentry, const char *acl_name)
+int security_path_remove_acl(const struct path *path, const char *acl_name)
 {
-	if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
+	if (unlikely(IS_PRIVATE(d_backing_inode(path->dentry))))
 		return 0;
-	return call_int_hook(inode_remove_acl, idmap, dentry, acl_name);
+	return call_int_hook(path_remove_acl, path, acl_name);
 }
 
 /**
@@ -2100,46 +2091,45 @@ void security_inode_post_setxattr(struct dentry *dentry, const char *name,
 }
 
 /**
- * security_inode_getxattr() - Check if xattr access is allowed
- * @dentry: file
+ * security_path_getxattr() - Check if xattr access is allowed
+ * @path: file
  * @name: xattr name
  *
  * Check permission before obtaining the extended attributes identified by
- * @name for @dentry.
+ * @name for @path.
  *
  * Return: Returns 0 if permission is granted.
  */
-int security_inode_getxattr(struct dentry *dentry, const char *name)
+int security_path_getxattr(const struct path *path, const char *name)
 {
-	if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
+	if (unlikely(IS_PRIVATE(d_backing_inode(path->dentry))))
 		return 0;
-	return call_int_hook(inode_getxattr, dentry, name);
+	return call_int_hook(path_getxattr, path, name);
 }
 
 /**
- * security_inode_listxattr() - Check if listing xattrs is allowed
- * @dentry: file
+ * security_path_listxattr() - Check if listing xattrs is allowed
+ * @path: file
  *
  * Check permission before obtaining the list of extended attribute names for
- * @dentry.
+ * @path.
  *
  * Return: Returns 0 if permission is granted.
  */
-int security_inode_listxattr(struct dentry *dentry)
+int security_path_listxattr(const struct path *path)
 {
-	if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
+	if (unlikely(IS_PRIVATE(d_backing_inode(path->dentry))))
 		return 0;
-	return call_int_hook(inode_listxattr, dentry);
+	return call_int_hook(path_listxattr, path);
 }
 
 /**
- * security_inode_removexattr() - Check if removing an xattr is allowed
- * @idmap: idmap of the mount
- * @dentry: file
+ * security_path_removexattr() - Check if removing an xattr is allowed
+ * @path: file
  * @name: xattr name
  *
  * This hook performs the desired permission checks before setting the extended
- * attributes (xattrs) on @dentry.  It is important to note that we have some
+ * attributes (xattrs) on @path.  It is important to note that we have some
  * additional logic before the main LSM implementation calls to detect if we
  * need to perform an additional capability check at the LSM layer.
  *
@@ -2155,22 +2145,21 @@ int security_inode_listxattr(struct dentry *dentry)
  *
  * Return: Returns 0 if permission is granted.
  */
-int security_inode_removexattr(const struct mnt_idmap *idmap,
-			       struct dentry *dentry, const char *name)
+int security_path_removexattr(const struct path *path, const char *name)
 {
 	int rc;
 
-	if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
+	if (unlikely(IS_PRIVATE(d_backing_inode(path->dentry))))
 		return 0;
 
 	/* enforce the capability checks at the lsm layer, if needed */
 	if (!call_int_hook(inode_xattr_skipcap, name)) {
-		rc = cap_inode_removexattr(idmap, dentry, name);
+		rc = cap_inode_removexattr(path, name);
 		if (rc)
 			return rc;
 	}
 
-	return call_int_hook(inode_removexattr, idmap, dentry, name);
+	return call_int_hook(path_removexattr, path, name);
 }
 
 /**
@@ -2188,8 +2177,8 @@ void security_inode_post_removexattr(struct dentry *dentry, const char *name)
 }
 
 /**
- * security_inode_file_setattr() - check if setting fsxattr is allowed
- * @dentry: file to set filesystem extended attributes on
+ * security_path_file_setattr() - check if setting fsxattr is allowed
+ * @path: file to set filesystem extended attributes on
  * @fa: extended attributes to set on the inode
  *
  * Called when file_setattr() syscall or FS_IOC_FSSETXATTR ioctl() is called on
@@ -2197,14 +2186,14 @@ void security_inode_post_removexattr(struct dentry *dentry, const char *name)
  *
  * Return: Returns 0 if permission is granted.
  */
-int security_inode_file_setattr(struct dentry *dentry, struct file_kattr *fa)
+int security_path_file_setattr(const struct path *path, struct file_kattr *fa)
 {
-	return call_int_hook(inode_file_setattr, dentry, fa);
+	return call_int_hook(path_file_setattr, path, fa);
 }
 
 /**
- * security_inode_file_getattr() - check if retrieving fsxattr is allowed
- * @dentry: file to retrieve filesystem extended attributes from
+ * security_path_file_getattr() - check if retrieving fsxattr is allowed
+ * @path: file to retrieve filesystem extended attributes from
  * @fa: extended attributes to get
  *
  * Called when file_getattr() syscall or FS_IOC_FSGETXATTR ioctl() is called on
@@ -2212,9 +2201,9 @@ int security_inode_file_setattr(struct dentry *dentry, struct file_kattr *fa)
  *
  * Return: Returns 0 if permission is granted.
  */
-int security_inode_file_getattr(struct dentry *dentry, struct file_kattr *fa)
+int security_path_file_getattr(const struct path *path, struct file_kattr *fa)
 {
-	return call_int_hook(inode_file_getattr, dentry, fa);
+	return call_int_hook(path_file_getattr, path, fa);
 }
 
 /**
@@ -4133,8 +4122,8 @@ int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen)
 EXPORT_SYMBOL(security_inode_notifysecctx);
 
 /**
- * security_inode_setsecctx() - Change the security label of an inode
- * @dentry: inode
+ * security_path_setsecctx() - Change the security label of an inode
+ * @path: inode
  * @ctx: secctx
  * @ctxlen: length of secctx
  *
@@ -4148,11 +4137,11 @@ EXPORT_SYMBOL(security_inode_notifysecctx);
  *
  * Return: Returns 0 on success, error on failure.
  */
-int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen)
+int security_path_setsecctx(const struct path *path, void *ctx, u32 ctxlen)
 {
-	return call_int_hook(inode_setsecctx, dentry, ctx, ctxlen);
+	return call_int_hook(path_setsecctx, path, ctx, ctxlen);
 }
-EXPORT_SYMBOL(security_inode_setsecctx);
+EXPORT_SYMBOL(security_path_setsecctx);
 
 /**
  * security_inode_getsecctx() - Get the security label of an inode
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 51454c411a038..81b7be7181e79 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -3346,10 +3346,11 @@ static int selinux_inode_permission(const struct mnt_idmap *idmap,
 	return rc;
 }
 
-static int selinux_inode_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
+static int selinux_path_setattr(const struct path *path,
 				 struct iattr *iattr)
 {
 	const struct cred *cred = current_cred();
+	struct dentry *dentry = path->dentry;
 	struct inode *inode = d_backing_inode(dentry);
 	unsigned int ia_valid = iattr->ia_valid;
 	u32 av = FILE__WRITE;
@@ -3375,7 +3376,7 @@ static int selinux_inode_setattr(const struct mnt_idmap *idmap, struct dentry *d
 	return dentry_has_perm(cred, dentry, av);
 }
 
-static int selinux_inode_getattr(const struct path *path)
+static int selinux_path_getattr(const struct path *path)
 {
 	struct task_security_struct *tsec;
 
@@ -3416,10 +3417,12 @@ static int selinux_inode_xattr_skipcap(const char *name)
 	return !strcmp(name, XATTR_NAME_SELINUX);
 }
 
-static int selinux_inode_setxattr(const struct mnt_idmap *idmap,
-				  struct dentry *dentry, const char *name,
-				  const void *value, size_t size, int flags)
+static int selinux_path_setxattr(const struct path *path,
+				  const char *name, const void *value,
+				  size_t size, int flags)
 {
+	struct dentry *dentry = path->dentry;
+	const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
 	struct inode *inode = d_backing_inode(dentry);
 	struct inode_security_struct *isec;
 	struct superblock_security_struct *sbsec;
@@ -3502,23 +3505,22 @@ static int selinux_inode_setxattr(const struct mnt_idmap *idmap,
 			    &ad);
 }
 
-static int selinux_inode_set_acl(const struct mnt_idmap *idmap,
-				 struct dentry *dentry, const char *acl_name,
-				 struct posix_acl *kacl)
+static int selinux_path_set_acl(const struct path *path,
+				 const char *acl_name, struct posix_acl *kacl)
 {
-	return dentry_has_perm(current_cred(), dentry, FILE__SETATTR);
+	return dentry_has_perm(current_cred(), path->dentry, FILE__SETATTR);
 }
 
-static int selinux_inode_get_acl(const struct mnt_idmap *idmap,
-				 struct dentry *dentry, const char *acl_name)
+static int selinux_path_get_acl(const struct path *path,
+				 const char *acl_name)
 {
-	return dentry_has_perm(current_cred(), dentry, FILE__GETATTR);
+	return dentry_has_perm(current_cred(), path->dentry, FILE__GETATTR);
 }
 
-static int selinux_inode_remove_acl(const struct mnt_idmap *idmap,
-				    struct dentry *dentry, const char *acl_name)
+static int selinux_path_remove_acl(const struct path *path,
+				    const char *acl_name)
 {
-	return dentry_has_perm(current_cred(), dentry, FILE__SETATTR);
+	return dentry_has_perm(current_cred(), path->dentry, FILE__SETATTR);
 }
 
 static void selinux_inode_post_setxattr(struct dentry *dentry, const char *name,
@@ -3561,26 +3563,27 @@ static void selinux_inode_post_setxattr(struct dentry *dentry, const char *name,
 	spin_unlock(&isec->lock);
 }
 
-static int selinux_inode_getxattr(struct dentry *dentry, const char *name)
+static int selinux_path_getxattr(const struct path *path, const char *name)
 {
 	const struct cred *cred = current_cred();
 
-	return dentry_has_perm(cred, dentry, FILE__GETATTR);
+	return dentry_has_perm(cred, path->dentry, FILE__GETATTR);
 }
 
-static int selinux_inode_listxattr(struct dentry *dentry)
+static int selinux_path_listxattr(const struct path *path)
 {
 	const struct cred *cred = current_cred();
 
-	return dentry_has_perm(cred, dentry, FILE__GETATTR);
+	return dentry_has_perm(cred, path->dentry, FILE__GETATTR);
 }
 
-static int selinux_inode_removexattr(const struct mnt_idmap *idmap,
-				     struct dentry *dentry, const char *name)
+static int selinux_path_removexattr(const struct path *path,
+				     const char *name)
 {
 	/* if not a selinux xattr, only check the ordinary setattr perm */
 	if (strcmp(name, XATTR_NAME_SELINUX))
-		return dentry_has_perm(current_cred(), dentry, FILE__SETATTR);
+		return dentry_has_perm(current_cred(), path->dentry,
+				       FILE__SETATTR);
 
 	if (!selinux_initialized())
 		return 0;
@@ -3590,16 +3593,16 @@ static int selinux_inode_removexattr(const struct mnt_idmap *idmap,
 	return -EACCES;
 }
 
-static int selinux_inode_file_setattr(struct dentry *dentry,
+static int selinux_path_file_setattr(const struct path *path,
 				      struct file_kattr *fa)
 {
-	return dentry_has_perm(current_cred(), dentry, FILE__SETATTR);
+	return dentry_has_perm(current_cred(), path->dentry, FILE__SETATTR);
 }
 
-static int selinux_inode_file_getattr(struct dentry *dentry,
+static int selinux_path_file_getattr(const struct path *path,
 				      struct file_kattr *fa)
 {
-	return dentry_has_perm(current_cred(), dentry, FILE__GETATTR);
+	return dentry_has_perm(current_cred(), path->dentry, FILE__GETATTR);
 }
 
 static int selinux_path_notify(const struct path *path, u64 mask,
@@ -3653,7 +3656,7 @@ static int selinux_path_notify(const struct path *path, u64 mask,
 /*
  * Copy the inode security context value to the user.
  *
- * Permission check is handled by selinux_inode_getxattr hook.
+ * Permission check is handled by selinux_path_getxattr hook.
  */
 static int selinux_inode_getsecurity(const struct mnt_idmap *idmap,
 				     struct inode *inode, const char *name,
@@ -7173,9 +7176,9 @@ static int selinux_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen
 /*
  *	called with inode->i_mutex locked
  */
-static int selinux_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen)
+static int selinux_path_setsecctx(const struct path *path, void *ctx, u32 ctxlen)
 {
-	return __vfs_setxattr_locked(&nop_mnt_idmap, dentry, XATTR_NAME_SELINUX,
+	return __vfs_setxattr_locked(path, XATTR_NAME_SELINUX,
 				     ctx, ctxlen, 0, NULL);
 }
 
@@ -7752,19 +7755,19 @@ static struct security_hook_list selinux_hooks[] __ro_after_init = {
 	LSM_HOOK_INIT(inode_readlink, selinux_inode_readlink),
 	LSM_HOOK_INIT(inode_follow_link, selinux_inode_follow_link),
 	LSM_HOOK_INIT(inode_permission, selinux_inode_permission),
-	LSM_HOOK_INIT(inode_setattr, selinux_inode_setattr),
-	LSM_HOOK_INIT(inode_getattr, selinux_inode_getattr),
+	LSM_HOOK_INIT(path_setattr, selinux_path_setattr),
+	LSM_HOOK_INIT(path_getattr, selinux_path_getattr),
 	LSM_HOOK_INIT(inode_xattr_skipcap, selinux_inode_xattr_skipcap),
-	LSM_HOOK_INIT(inode_setxattr, selinux_inode_setxattr),
+	LSM_HOOK_INIT(path_setxattr, selinux_path_setxattr),
 	LSM_HOOK_INIT(inode_post_setxattr, selinux_inode_post_setxattr),
-	LSM_HOOK_INIT(inode_getxattr, selinux_inode_getxattr),
-	LSM_HOOK_INIT(inode_listxattr, selinux_inode_listxattr),
-	LSM_HOOK_INIT(inode_removexattr, selinux_inode_removexattr),
-	LSM_HOOK_INIT(inode_file_getattr, selinux_inode_file_getattr),
-	LSM_HOOK_INIT(inode_file_setattr, selinux_inode_file_setattr),
-	LSM_HOOK_INIT(inode_set_acl, selinux_inode_set_acl),
-	LSM_HOOK_INIT(inode_get_acl, selinux_inode_get_acl),
-	LSM_HOOK_INIT(inode_remove_acl, selinux_inode_remove_acl),
+	LSM_HOOK_INIT(path_getxattr, selinux_path_getxattr),
+	LSM_HOOK_INIT(path_listxattr, selinux_path_listxattr),
+	LSM_HOOK_INIT(path_removexattr, selinux_path_removexattr),
+	LSM_HOOK_INIT(path_file_getattr, selinux_path_file_getattr),
+	LSM_HOOK_INIT(path_file_setattr, selinux_path_file_setattr),
+	LSM_HOOK_INIT(path_set_acl, selinux_path_set_acl),
+	LSM_HOOK_INIT(path_get_acl, selinux_path_get_acl),
+	LSM_HOOK_INIT(path_remove_acl, selinux_path_remove_acl),
 	LSM_HOOK_INIT(inode_getsecurity, selinux_inode_getsecurity),
 	LSM_HOOK_INIT(inode_setsecurity, selinux_inode_setsecurity),
 	LSM_HOOK_INIT(inode_listsecurity, selinux_inode_listsecurity),
@@ -7848,7 +7851,7 @@ static struct security_hook_list selinux_hooks[] __ro_after_init = {
 	LSM_HOOK_INIT(release_secctx, selinux_release_secctx),
 	LSM_HOOK_INIT(inode_invalidate_secctx, selinux_inode_invalidate_secctx),
 	LSM_HOOK_INIT(inode_notifysecctx, selinux_inode_notifysecctx),
-	LSM_HOOK_INIT(inode_setsecctx, selinux_inode_setsecctx),
+	LSM_HOOK_INIT(path_setsecctx, selinux_path_setsecctx),
 
 	LSM_HOOK_INIT(unix_stream_connect, selinux_socket_unix_stream_connect),
 	LSM_HOOK_INIT(unix_may_send, selinux_socket_unix_may_send),
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index 3524649f402da..43f407ae007fe 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -1265,17 +1265,18 @@ static int smack_inode_permission(const struct mnt_idmap *idmap, struct inode *i
 }
 
 /**
- * smack_inode_setattr - Smack check for setting attributes
+ * smack_path_setattr - Smack check for setting attributes
  * @idmap: idmap of the mount
  * @dentry: the object
  * @iattr: for the force flag
  *
  * Returns 0 if access is permitted, an error code otherwise
  */
-static int smack_inode_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
+static int smack_path_setattr(const struct path *path,
 			       struct iattr *iattr)
 {
 	struct smk_audit_info ad;
+	struct dentry *dentry = path->dentry;
 	int rc;
 
 	/*
@@ -1292,12 +1293,12 @@ static int smack_inode_setattr(const struct mnt_idmap *idmap, struct dentry *den
 }
 
 /**
- * smack_inode_getattr - Smack check for getting attributes
+ * smack_path_getattr - Smack check for getting attributes
  * @path: path to extract the info from
  *
  * Returns 0 if access is permitted, an error code otherwise
  */
-static int smack_inode_getattr(const struct path *path)
+static int smack_path_getattr(const struct path *path)
 {
 	struct smk_audit_info ad;
 	struct inode *inode = d_backing_inode(path->dentry);
@@ -1338,7 +1339,7 @@ static int smack_inode_xattr_skipcap(const char *name)
 }
 
 /**
- * smack_inode_setxattr - Smack check for setting xattrs
+ * smack_path_setxattr - Smack check for setting xattrs
  * @idmap: idmap of the mount
  * @dentry: the object
  * @name: name of the attribute
@@ -1350,11 +1351,12 @@ static int smack_inode_xattr_skipcap(const char *name)
  *
  * Returns 0 if access is permitted, an error code otherwise
  */
-static int smack_inode_setxattr(const struct mnt_idmap *idmap,
-				struct dentry *dentry, const char *name,
-				const void *value, size_t size, int flags)
+static int smack_path_setxattr(const struct path *path,
+				const char *name, const void *value,
+				size_t size, int flags)
 {
 	struct smk_audit_info ad;
+	struct dentry *dentry = path->dentry;
 	struct smack_known *skp;
 	int check_priv = 0;
 	int check_import = 0;
@@ -1455,15 +1457,16 @@ static void smack_inode_post_setxattr(struct dentry *dentry, const char *name,
 }
 
 /**
- * smack_inode_getxattr - Smack check on getxattr
+ * smack_path_getxattr - Smack check on getxattr
  * @dentry: the object
  * @name: unused
  *
  * Returns 0 if access is permitted, an error code otherwise
  */
-static int smack_inode_getxattr(struct dentry *dentry, const char *name)
+static int smack_path_getxattr(const struct path *path, const char *name)
 {
 	struct smk_audit_info ad;
+	struct dentry *dentry = path->dentry;
 	int rc;
 
 	smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY);
@@ -1475,20 +1478,20 @@ static int smack_inode_getxattr(struct dentry *dentry, const char *name)
 }
 
 /**
- * smack_inode_removexattr - Smack check on removexattr
- * @idmap: idmap of the mount
- * @dentry: the object
+ * smack_path_removexattr - Smack check on removexattr
+ * @path: the object
  * @name: name of the attribute
  *
  * Removing the Smack attribute requires CAP_MAC_ADMIN
  *
  * Returns 0 if access is permitted, an error code otherwise
  */
-static int smack_inode_removexattr(const struct mnt_idmap *idmap,
-				   struct dentry *dentry, const char *name)
+static int smack_path_removexattr(const struct path *path,
+				   const char *name)
 {
 	struct inode_smack *isp;
 	struct smk_audit_info ad;
+	struct dentry *dentry = path->dentry;
 	int rc = 0;
 
 	if (strcmp(name, XATTR_NAME_SMACK) == 0 ||
@@ -1537,7 +1540,7 @@ static int smack_inode_removexattr(const struct mnt_idmap *idmap,
 }
 
 /**
- * smack_inode_set_acl - Smack check for setting posix acls
+ * smack_path_set_acl - Smack check for setting posix acls
  * @idmap: idmap of the mnt this request came from
  * @dentry: the object
  * @acl_name: name of the posix acl
@@ -1545,62 +1548,59 @@ static int smack_inode_removexattr(const struct mnt_idmap *idmap,
  *
  * Returns 0 if access is permitted, an error code otherwise
  */
-static int smack_inode_set_acl(const struct mnt_idmap *idmap,
-			       struct dentry *dentry, const char *acl_name,
-			       struct posix_acl *kacl)
+static int smack_path_set_acl(const struct path *path,
+			       const char *acl_name, struct posix_acl *kacl)
 {
 	struct smk_audit_info ad;
 	int rc;
 
 	smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY);
-	smk_ad_setfield_u_fs_path_dentry(&ad, dentry);
+	smk_ad_setfield_u_fs_path_dentry(&ad, path->dentry);
 
-	rc = smk_curacc(smk_of_inode(d_backing_inode(dentry)), MAY_WRITE, &ad);
-	rc = smk_bu_inode(d_backing_inode(dentry), MAY_WRITE, rc);
+	rc = smk_curacc(smk_of_inode(d_backing_inode(path->dentry)), MAY_WRITE, &ad);
+	rc = smk_bu_inode(d_backing_inode(path->dentry), MAY_WRITE, rc);
 	return rc;
 }
 
 /**
- * smack_inode_get_acl - Smack check for getting posix acls
- * @idmap: idmap of the mnt this request came from
- * @dentry: the object
+ * smack_path_get_acl - Smack check for getting posix acls
+ * @path: the object
  * @acl_name: name of the posix acl
  *
  * Returns 0 if access is permitted, an error code otherwise
  */
-static int smack_inode_get_acl(const struct mnt_idmap *idmap,
-			       struct dentry *dentry, const char *acl_name)
+static int smack_path_get_acl(const struct path *path,
+			       const char *acl_name)
 {
 	struct smk_audit_info ad;
 	int rc;
 
 	smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY);
-	smk_ad_setfield_u_fs_path_dentry(&ad, dentry);
+	smk_ad_setfield_u_fs_path_dentry(&ad, path->dentry);
 
-	rc = smk_curacc(smk_of_inode(d_backing_inode(dentry)), MAY_READ, &ad);
-	rc = smk_bu_inode(d_backing_inode(dentry), MAY_READ, rc);
+	rc = smk_curacc(smk_of_inode(d_backing_inode(path->dentry)), MAY_READ, &ad);
+	rc = smk_bu_inode(d_backing_inode(path->dentry), MAY_READ, rc);
 	return rc;
 }
 
 /**
- * smack_inode_remove_acl - Smack check for getting posix acls
- * @idmap: idmap of the mnt this request came from
- * @dentry: the object
+ * smack_path_remove_acl - Smack check for getting posix acls
+ * @path: the object
  * @acl_name: name of the posix acl
  *
  * Returns 0 if access is permitted, an error code otherwise
  */
-static int smack_inode_remove_acl(const struct mnt_idmap *idmap,
-				  struct dentry *dentry, const char *acl_name)
+static int smack_path_remove_acl(const struct path *path,
+				  const char *acl_name)
 {
 	struct smk_audit_info ad;
 	int rc;
 
 	smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY);
-	smk_ad_setfield_u_fs_path_dentry(&ad, dentry);
+	smk_ad_setfield_u_fs_path_dentry(&ad, path->dentry);
 
-	rc = smk_curacc(smk_of_inode(d_backing_inode(dentry)), MAY_WRITE, &ad);
-	rc = smk_bu_inode(d_backing_inode(dentry), MAY_WRITE, rc);
+	rc = smk_curacc(smk_of_inode(d_backing_inode(path->dentry)), MAY_WRITE, &ad);
+	rc = smk_bu_inode(d_backing_inode(path->dentry), MAY_WRITE, rc);
 	return rc;
 }
 
@@ -4978,9 +4978,9 @@ static int smack_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen)
 				       ctxlen, 0);
 }
 
-static int smack_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen)
+static int smack_path_setsecctx(const struct path *path, void *ctx, u32 ctxlen)
 {
-	return __vfs_setxattr_locked(&nop_mnt_idmap, dentry, XATTR_NAME_SMACK,
+	return __vfs_setxattr_locked(path, XATTR_NAME_SMACK,
 				     ctx, ctxlen, 0, NULL);
 }
 
@@ -5178,16 +5178,16 @@ static struct security_hook_list smack_hooks[] __ro_after_init = {
 	LSM_HOOK_INIT(inode_rmdir, smack_inode_rmdir),
 	LSM_HOOK_INIT(inode_rename, smack_inode_rename),
 	LSM_HOOK_INIT(inode_permission, smack_inode_permission),
-	LSM_HOOK_INIT(inode_setattr, smack_inode_setattr),
-	LSM_HOOK_INIT(inode_getattr, smack_inode_getattr),
+	LSM_HOOK_INIT(path_setattr, smack_path_setattr),
+	LSM_HOOK_INIT(path_getattr, smack_path_getattr),
 	LSM_HOOK_INIT(inode_xattr_skipcap, smack_inode_xattr_skipcap),
-	LSM_HOOK_INIT(inode_setxattr, smack_inode_setxattr),
+	LSM_HOOK_INIT(path_setxattr, smack_path_setxattr),
 	LSM_HOOK_INIT(inode_post_setxattr, smack_inode_post_setxattr),
-	LSM_HOOK_INIT(inode_getxattr, smack_inode_getxattr),
-	LSM_HOOK_INIT(inode_removexattr, smack_inode_removexattr),
-	LSM_HOOK_INIT(inode_set_acl, smack_inode_set_acl),
-	LSM_HOOK_INIT(inode_get_acl, smack_inode_get_acl),
-	LSM_HOOK_INIT(inode_remove_acl, smack_inode_remove_acl),
+	LSM_HOOK_INIT(path_getxattr, smack_path_getxattr),
+	LSM_HOOK_INIT(path_removexattr, smack_path_removexattr),
+	LSM_HOOK_INIT(path_set_acl, smack_path_set_acl),
+	LSM_HOOK_INIT(path_get_acl, smack_path_get_acl),
+	LSM_HOOK_INIT(path_remove_acl, smack_path_remove_acl),
 	LSM_HOOK_INIT(inode_getsecurity, smack_inode_getsecurity),
 	LSM_HOOK_INIT(inode_setsecurity, smack_inode_setsecurity),
 	LSM_HOOK_INIT(inode_listsecurity, smack_inode_listsecurity),
@@ -5303,7 +5303,7 @@ static struct security_hook_list smack_hooks[] __ro_after_init = {
 	LSM_HOOK_INIT(lsmprop_to_secctx, smack_lsmprop_to_secctx),
 	LSM_HOOK_INIT(secctx_to_secid, smack_secctx_to_secid),
 	LSM_HOOK_INIT(inode_notifysecctx, smack_inode_notifysecctx),
-	LSM_HOOK_INIT(inode_setsecctx, smack_inode_setsecctx),
+	LSM_HOOK_INIT(path_setsecctx, smack_path_setsecctx),
 	LSM_HOOK_INIT(inode_getsecctx, smack_inode_getsecctx),
 	LSM_HOOK_INIT(inode_copy_up, smack_inode_copy_up),
 	LSM_HOOK_INIT(inode_copy_up_xattr, smack_inode_copy_up_xattr),
diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
index c66e02ed8ee3b..901eefa84ea6c 100644
--- a/security/tomoyo/tomoyo.c
+++ b/security/tomoyo/tomoyo.c
@@ -112,13 +112,13 @@ static int tomoyo_bprm_check_security(struct linux_binprm *bprm)
 }
 
 /**
- * tomoyo_inode_getattr - Target for security_inode_getattr().
+ * tomoyo_path_getattr - Target for security_path_getattr().
  *
  * @path: Pointer to "struct path".
  *
  * Returns 0 on success, negative value otherwise.
  */
-static int tomoyo_inode_getattr(const struct path *path)
+static int tomoyo_path_getattr(const struct path *path)
 {
 	return tomoyo_path_perm(TOMOYO_TYPE_GETATTR, path, NULL);
 }
@@ -570,7 +570,7 @@ static struct security_hook_list tomoyo_hooks[] __ro_after_init = {
 	LSM_HOOK_INIT(path_mknod, tomoyo_path_mknod),
 	LSM_HOOK_INIT(path_link, tomoyo_path_link),
 	LSM_HOOK_INIT(path_rename, tomoyo_path_rename),
-	LSM_HOOK_INIT(inode_getattr, tomoyo_inode_getattr),
+	LSM_HOOK_INIT(path_getattr, tomoyo_path_getattr),
 	LSM_HOOK_INIT(file_ioctl, tomoyo_file_ioctl),
 	LSM_HOOK_INIT(file_ioctl_compat, tomoyo_file_ioctl),
 	LSM_HOOK_INIT(path_chmod, tomoyo_path_chmod),
diff --git a/tools/testing/selftests/bpf/prog_tests/d_path.c b/tools/testing/selftests/bpf/prog_tests/d_path.c
index 1a2a2f1abf033..9877c098e5c14 100644
--- a/tools/testing/selftests/bpf/prog_tests/d_path.c
+++ b/tools/testing/selftests/bpf/prog_tests/d_path.c
@@ -160,7 +160,7 @@ static void test_d_path_basic(void)
 
 	if (CHECK(!bss->called_stat,
 		  "stat",
-		  "trampoline for security_inode_getattr was not called\n"))
+		  "trampoline for security_path_getattr was not called\n"))
 		goto cleanup;
 
 	if (CHECK(!bss->called_close,
diff --git a/tools/testing/selftests/bpf/prog_tests/fs_kfuncs.c b/tools/testing/selftests/bpf/prog_tests/fs_kfuncs.c
index 43a26ec69a8e3..5145b1f03cac2 100644
--- a/tools/testing/selftests/bpf/prog_tests/fs_kfuncs.c
+++ b/tools/testing/selftests/bpf/prog_tests/fs_kfuncs.c
@@ -53,7 +53,7 @@ static void test_get_xattr(const char *name, const char *value, bool allow_acces
 	if (!ASSERT_GE(fd, 0, "open_file"))
 		goto out;
 
-	/* Trigger security_inode_getxattr */
+	/* Trigger security_path_getxattr */
 	err = getxattr(testfile, name, v, sizeof(v));
 
 	if (allow_access) {
@@ -148,13 +148,13 @@ static void test_set_remove_xattr(void)
 
 	/* First, test not _locked version of the kfuncs with getxattr. */
 
-	/* Read security.bpf.foo and trigger test_inode_getxattr. This
+	/* Read security.bpf.foo and trigger test_path_getxattr. This
 	 * bpf program will set security.bpf.bar to "world".
 	 */
 	read_and_validate_foo(skel);
 	validate_bar_match(skel);
 
-	/* Read security.bpf.foo and trigger test_inode_getxattr again.
+	/* Read security.bpf.foo and trigger test_path_getxattr again.
 	 * This will remove xattr security.bpf.bar.
 	 */
 	read_and_validate_foo(skel);
@@ -167,13 +167,13 @@ static void test_set_remove_xattr(void)
 
 	/* Second, test _locked version of the kfuncs, with setxattr */
 
-	/* Set security.bpf.foo and trigger test_inode_setxattr. This
+	/* Set security.bpf.foo and trigger test_path_setxattr. This
 	 * bpf program will set security.bpf.bar to "world".
 	 */
 	set_foo(skel);
 	validate_bar_match(skel);
 
-	/* Set security.bpf.foo and trigger test_inode_setxattr again.
+	/* Set security.bpf.foo and trigger test_path_setxattr again.
 	 * This will remove xattr security.bpf.bar.
 	 */
 	set_foo(skel);
diff --git a/tools/testing/selftests/bpf/progs/test_d_path.c b/tools/testing/selftests/bpf/progs/test_d_path.c
index 561b2f861808e..b97c203e3992d 100644
--- a/tools/testing/selftests/bpf/progs/test_d_path.c
+++ b/tools/testing/selftests/bpf/progs/test_d_path.c
@@ -19,7 +19,7 @@ int called_stat = 0;
 int called_close = 0;
 int path_match_fallocate = 0;
 
-SEC("fentry/security_inode_getattr")
+SEC("fentry/security_path_getattr")
 int BPF_PROG(prog_stat, struct path *path, struct kstat *stat,
 	     __u32 request_mask, unsigned int query_flags)
 {
diff --git a/tools/testing/selftests/bpf/progs/test_d_path_check_rdonly_mem.c b/tools/testing/selftests/bpf/progs/test_d_path_check_rdonly_mem.c
index 27c27cff6a3aa..5e0e3d4828d79 100644
--- a/tools/testing/selftests/bpf/progs/test_d_path_check_rdonly_mem.c
+++ b/tools/testing/selftests/bpf/progs/test_d_path_check_rdonly_mem.c
@@ -7,7 +7,7 @@
 
 extern const int bpf_prog_active __ksym;
 
-SEC("fentry/security_inode_getattr")
+SEC("fentry/security_path_getattr")
 int BPF_PROG(d_path_check_rdonly_mem, struct path *path, struct kstat *stat,
 	     __u32 request_mask, unsigned int query_flags)
 {
diff --git a/tools/testing/selftests/bpf/progs/test_d_path_check_types.c b/tools/testing/selftests/bpf/progs/test_d_path_check_types.c
index 7e02b7361307c..fba3d527b4df6 100644
--- a/tools/testing/selftests/bpf/progs/test_d_path_check_types.c
+++ b/tools/testing/selftests/bpf/progs/test_d_path_check_types.c
@@ -11,7 +11,7 @@ struct {
 	__uint(max_entries, 1 << 12);
 } ringbuf SEC(".maps");
 
-SEC("fentry/security_inode_getattr")
+SEC("fentry/security_path_getattr")
 int BPF_PROG(d_path_check_rdonly_mem, struct path *path, struct kstat *stat,
 	     __u32 request_mask, unsigned int query_flags)
 {
diff --git a/tools/testing/selftests/bpf/progs/test_get_xattr.c b/tools/testing/selftests/bpf/progs/test_get_xattr.c
index 54305f4c9f2dd..eea89016f96f1 100644
--- a/tools/testing/selftests/bpf/progs/test_get_xattr.c
+++ b/tools/testing/selftests/bpf/progs/test_get_xattr.c
@@ -55,8 +55,8 @@ int BPF_PROG(test_file_open, struct file *f)
 	return 0;
 }
 
-SEC("lsm.s/inode_getxattr")
-int BPF_PROG(test_inode_getxattr, struct dentry *dentry, char *name)
+SEC("lsm.s/path_getxattr")
+int BPF_PROG(test_path_getxattr, const struct path *path, char *name)
 {
 	struct bpf_dynptr value_ptr;
 	__u32 pid;
@@ -69,7 +69,7 @@ int BPF_PROG(test_inode_getxattr, struct dentry *dentry, char *name)
 	bpf_dynptr_from_mem(value2, sizeof(value2), 0, &value_ptr);
 
 	for (i = 0; i < ARRAY_SIZE(xattr_names); i++) {
-		ret = bpf_get_dentry_xattr(dentry, xattr_names[i], &value_ptr);
+		ret = bpf_get_dentry_xattr(path->dentry, xattr_names[i], &value_ptr);
 		if (ret == sizeof(expected_value))
 			break;
 	}
diff --git a/tools/testing/selftests/bpf/progs/test_set_remove_xattr.c b/tools/testing/selftests/bpf/progs/test_set_remove_xattr.c
index 6a612cf168d3f..f7438081d630e 100644
--- a/tools/testing/selftests/bpf/progs/test_set_remove_xattr.c
+++ b/tools/testing/selftests/bpf/progs/test_set_remove_xattr.c
@@ -32,8 +32,8 @@ static inline bool name_match_foo(const char *name)
 }
 
 /* Test bpf_set_dentry_xattr and bpf_remove_dentry_xattr */
-SEC("lsm.s/inode_getxattr")
-int BPF_PROG(test_inode_getxattr, struct dentry *dentry, char *name)
+SEC("lsm.s/path_getxattr")
+int BPF_PROG(test_path_getxattr, const struct path *path, char *name)
 {
 	struct bpf_dynptr value_ptr;
 	__u32 pid;
@@ -50,25 +50,25 @@ int BPF_PROG(test_inode_getxattr, struct dentry *dentry, char *name)
 	bpf_dynptr_from_mem(read_value, sizeof(read_value), 0, &value_ptr);
 
 	/* read security.bpf.bar */
-	ret = bpf_get_dentry_xattr(dentry, xattr_bar, &value_ptr);
+	ret = bpf_get_dentry_xattr(path->dentry, xattr_bar, &value_ptr);
 
 	if (ret < 0) {
 		/* If security.bpf.bar doesn't exist, set it */
 		bpf_dynptr_from_mem(value_bar, sizeof(value_bar), 0, &value_ptr);
 
-		ret = bpf_set_dentry_xattr(dentry, xattr_bar, &value_ptr, 0);
+		ret = bpf_set_dentry_xattr(path->dentry, xattr_bar, &value_ptr, 0);
 		if (!ret)
 			set_security_bpf_bar_success = true;
-		ret = bpf_set_dentry_xattr(dentry, xattr_selinux, &value_ptr, 0);
+		ret = bpf_set_dentry_xattr(path->dentry, xattr_selinux, &value_ptr, 0);
 		if (ret)
 			set_security_selinux_fail = true;
 	} else {
 		/* If security.bpf.bar exists, remove it */
-		ret = bpf_remove_dentry_xattr(dentry, xattr_bar);
+		ret = bpf_remove_dentry_xattr(path->dentry, xattr_bar);
 		if (!ret)
 			remove_security_bpf_bar_success = true;
 
-		ret = bpf_remove_dentry_xattr(dentry, xattr_selinux);
+		ret = bpf_remove_dentry_xattr(path->dentry, xattr_selinux);
 		if (ret)
 			remove_security_selinux_fail = true;
 	}
@@ -86,10 +86,9 @@ bool locked_remove_security_selinux_fail;
  * not-_locked version in the BPF program. The verifier will fix them up
  * properly.
  */
-SEC("lsm.s/inode_setxattr")
-int BPF_PROG(test_inode_setxattr, struct mnt_idmap *idmap,
-	     struct dentry *dentry, const char *name,
-	     const void *value, size_t size, int flags)
+SEC("lsm.s/path_setxattr")
+int BPF_PROG(test_path_setxattr, const struct path *path,
+	     const char *name, const void *value, size_t size, int flags)
 {
 	struct bpf_dynptr value_ptr;
 	__u32 pid;
@@ -106,25 +105,25 @@ int BPF_PROG(test_inode_setxattr, struct mnt_idmap *idmap,
 	bpf_dynptr_from_mem(read_value, sizeof(read_value), 0, &value_ptr);
 
 	/* read security.bpf.bar */
-	ret = bpf_get_dentry_xattr(dentry, xattr_bar, &value_ptr);
+	ret = bpf_get_dentry_xattr(path->dentry, xattr_bar, &value_ptr);
 
 	if (ret < 0) {
 		/* If security.bpf.bar doesn't exist, set it */
 		bpf_dynptr_from_mem(value_bar, sizeof(value_bar), 0, &value_ptr);
 
-		ret = bpf_set_dentry_xattr(dentry, xattr_bar, &value_ptr, 0);
+		ret = bpf_set_dentry_xattr(path->dentry, xattr_bar, &value_ptr, 0);
 		if (!ret)
 			locked_set_security_bpf_bar_success = true;
-		ret = bpf_set_dentry_xattr(dentry, xattr_selinux, &value_ptr, 0);
+		ret = bpf_set_dentry_xattr(path->dentry, xattr_selinux, &value_ptr, 0);
 		if (ret)
 			locked_set_security_selinux_fail = true;
 	} else {
 		/* If security.bpf.bar exists, remove it */
-		ret = bpf_remove_dentry_xattr(dentry, xattr_bar);
+		ret = bpf_remove_dentry_xattr(path->dentry, xattr_bar);
 		if (!ret)
 			locked_remove_security_bpf_bar_success = true;
 
-		ret = bpf_remove_dentry_xattr(dentry, xattr_selinux);
+		ret = bpf_remove_dentry_xattr(path->dentry, xattr_selinux);
 		if (ret)
 			locked_remove_security_selinux_fail = true;
 	}
diff --git a/tools/testing/selftests/bpf/progs/verifier_lsm_init_xattr.c b/tools/testing/selftests/bpf/progs/verifier_lsm_init_xattr.c
index b706bf17b5560..a9b09e559d7e4 100644
--- a/tools/testing/selftests/bpf/progs/verifier_lsm_init_xattr.c
+++ b/tools/testing/selftests/bpf/progs/verifier_lsm_init_xattr.c
@@ -232,9 +232,9 @@ int BPF_PROG(reject_lsm_cgroup, struct inode *inode, struct inode *dir,
 	return 0;
 }
 
-SEC("lsm/inode_setxattr")
+SEC("lsm/path_setxattr")
 __failure __msg("calling kernel function bpf_inode_init_xattr is not allowed")
-int BPF_PROG(reject_wrong_hook, struct mnt_idmap *idmap, struct dentry *dentry,
+int BPF_PROG(reject_wrong_hook, const struct path *path,
 	     const char *name, const void *value, size_t size, int flags)
 {
 	struct bpf_dynptr val;
diff --git a/tools/testing/selftests/bpf/progs/verifier_vfs_accept.c b/tools/testing/selftests/bpf/progs/verifier_vfs_accept.c
index 55398c04290a8..55e292a41d304 100644
--- a/tools/testing/selftests/bpf/progs/verifier_vfs_accept.c
+++ b/tools/testing/selftests/bpf/progs/verifier_vfs_accept.c
@@ -54,7 +54,7 @@ int BPF_PROG(get_task_exe_file_and_put_kfunc_from_argument,
 	return 0;
 }
 
-SEC("lsm.s/inode_getattr")
+SEC("lsm.s/path_getattr")
 __success
 int BPF_PROG(path_d_path_from_path_argument, struct path *path)
 {
diff --git a/tools/testing/selftests/bpf/progs/verifier_vfs_reject.c b/tools/testing/selftests/bpf/progs/verifier_vfs_reject.c
index b5f456d57669e..1337effeb46be 100644
--- a/tools/testing/selftests/bpf/progs/verifier_vfs_reject.c
+++ b/tools/testing/selftests/bpf/progs/verifier_vfs_reject.c
@@ -27,7 +27,7 @@ int BPF_PROG(get_task_exe_file_kfunc_null)
 	return 0;
 }
 
-SEC("lsm.s/inode_getxattr")
+SEC("lsm.s/path_getxattr")
 __failure __msg("R1 type=fp expected=ptr_, trusted_ptr_, rcu_ptr_")
 int BPF_PROG(get_task_exe_file_kfunc_fp)
 {
diff --git a/tools/testing/selftests/landlock/base_test.c b/tools/testing/selftests/landlock/base_test.c
index 89c0d96607deb..14078ad203d8b 100644
--- a/tools/testing/selftests/landlock/base_test.c
+++ b/tools/testing/selftests/landlock/base_test.c
@@ -76,7 +76,7 @@ TEST(abi_version)
 	const struct landlock_ruleset_attr ruleset_attr = {
 		.handled_access_fs = LANDLOCK_ACCESS_FS_READ_FILE,
 	};
-	ASSERT_EQ(12, landlock_create_ruleset(NULL, 0,
+	ASSERT_EQ(13, landlock_create_ruleset(NULL, 0,
 					      LANDLOCK_CREATE_RULESET_VERSION));
 
 	ASSERT_EQ(-1, landlock_create_ruleset(&ruleset_attr, 0,
diff --git a/tools/testing/selftests/landlock/fs_test.c b/tools/testing/selftests/landlock/fs_test.c
index f725882fa4a78..ce865955c5794 100644
--- a/tools/testing/selftests/landlock/fs_test.c
+++ b/tools/testing/selftests/landlock/fs_test.c
@@ -12,6 +12,7 @@
 #include <fcntl.h>
 #include <libgen.h>
 #include <linux/fiemap.h>
+#include <linux/fs.h>
 #include <linux/landlock.h>
 #include <linux/magic.h>
 #include <sched.h>
@@ -26,8 +27,10 @@
 #include <sys/sendfile.h>
 #include <sys/socket.h>
 #include <sys/stat.h>
+#include <sys/syscall.h>
 #include <sys/sysmacros.h>
 #include <sys/un.h>
+#include <sys/xattr.h>
 #include <sys/vfs.h>
 #include <unistd.h>
 
@@ -571,11 +574,13 @@ TEST_F_FORK(layout1, inval)
 	LANDLOCK_ACCESS_FS_EXECUTE | \
 	LANDLOCK_ACCESS_FS_WRITE_FILE | \
 	LANDLOCK_ACCESS_FS_READ_FILE | \
+	LANDLOCK_ACCESS_FS_READ_METADATA | \
+	LANDLOCK_ACCESS_FS_WRITE_METADATA | \
 	LANDLOCK_ACCESS_FS_TRUNCATE | \
 	LANDLOCK_ACCESS_FS_IOCTL_DEV | \
 	LANDLOCK_ACCESS_FS_RESOLVE_UNIX)
 
-#define ACCESS_LAST LANDLOCK_ACCESS_FS_RESOLVE_UNIX
+#define ACCESS_LAST LANDLOCK_ACCESS_FS_WRITE_METADATA
 
 #define ACCESS_ALL ( \
 	ACCESS_FILE | \
@@ -10916,4 +10921,603 @@ TEST_F(trace_layout1, check_rule_fs_empty_grant)
 	free(buf);
 }
 
+/* Invokes chmod(2) and returns its errno or 0. */
+static int test_chmod(const char *const path, mode_t mode)
+{
+	if (chmod(path, mode) < 0)
+		return errno;
+	return 0;
+}
+
+/* Invokes fchmod(2) and returns its errno or 0. */
+static int test_fchmod(int fd, mode_t mode)
+{
+	if (fchmod(fd, mode) < 0)
+		return errno;
+	return 0;
+}
+
+/* Invokes chown(2) and returns its errno or 0. */
+static int test_chown(const char *const path, uid_t uid, gid_t gid)
+{
+	if (chown(path, uid, gid) < 0)
+		return errno;
+	return 0;
+}
+
+/* Invokes fchown(2) and returns its errno or 0. */
+static int test_fchown(int fd, uid_t uid, gid_t gid)
+{
+	if (fchown(fd, uid, gid) < 0)
+		return errno;
+	return 0;
+}
+
+/* Invokes lchown(2) and returns its errno or 0. */
+static int test_lchown(const char *const path, uid_t uid, gid_t gid)
+{
+	if (lchown(path, uid, gid) < 0)
+		return errno;
+	return 0;
+}
+
+/* Invokes utimensat(2) with explicit times and returns its errno or 0. */
+static int test_utimensat(const char *const path)
+{
+	const struct timespec times[] = {
+		{
+			.tv_sec = 0,
+			.tv_nsec = UTIME_OMIT,
+		},
+		{
+			.tv_sec = 1,
+			.tv_nsec = 0,
+		},
+	};
+
+	if (utimensat(AT_FDCWD, path, times, 0) < 0)
+		return errno;
+	return 0;
+}
+
+/* Invokes utimensat(2) with UTIME_NOW and returns its errno or 0. */
+static int test_utimensat_now(const char *const path)
+{
+	if (utimensat(AT_FDCWD, path, NULL, 0) < 0)
+		return errno;
+	return 0;
+}
+
+/* Invokes setxattr(2) and returns its errno or 0. */
+static int test_setxattr(const char *const path, const char *const name,
+			 const void *const value, const size_t size)
+{
+	if (setxattr(path, name, value, size, 0) < 0)
+		return errno;
+	return 0;
+}
+
+/* Invokes getxattr(2) and returns its errno or 0. */
+static int test_getxattr(const char *const path, const char *const name,
+			 void *const value, const size_t size)
+{
+	if (getxattr(path, name, value, size) < 0)
+		return errno;
+	return 0;
+}
+
+/* Invokes listxattr(2) and returns its errno or 0. */
+static int test_listxattr(const char *const path, void *const list,
+			  const size_t size)
+{
+	if (listxattr(path, list, size) < 0)
+		return errno;
+	return 0;
+}
+
+/* Invokes removexattr(2) and returns its errno or 0. */
+static int test_removexattr(const char *const path, const char *const name)
+{
+	if (removexattr(path, name) < 0)
+		return errno;
+	return 0;
+}
+
+/* Invokes stat(2) and returns its errno or 0. */
+static int test_stat(const char *const path, struct stat *statbuf)
+{
+	if (stat(path, statbuf) < 0)
+		return errno;
+	return 0;
+}
+
+/* Invokes fstat(2) and returns its errno or 0. */
+static int test_fstat(int fd, struct stat *statbuf)
+{
+	if (fstat(fd, statbuf) < 0)
+		return errno;
+	return 0;
+}
+
+TEST_F_FORK(layout1, unhandled_metadata)
+{
+	int file_fd;
+	int ruleset_fd;
+	const char *const file1 = file1_s1d1;
+	const char *const file2 = file2_s1d1;
+	const char *const dir1 = dir_s1d1;
+	struct stat statbuf;
+	const struct rule rules[] = {
+		{
+			.path = file1,
+			.access = LANDLOCK_ACCESS_FS_WRITE_FILE,
+		},
+		{
+			.path = file2,
+			.access = LANDLOCK_ACCESS_FS_READ_FILE |
+				  LANDLOCK_ACCESS_FS_WRITE_FILE,
+		},
+		{
+			.path = dir1,
+			.access = ACCESS_RW,
+		},
+		{},
+	};
+
+	/*
+	 * READ_METADATA and WRITE_METADATA are not handled, so metadata
+	 * access should be allowed.
+	 */
+	ruleset_fd = create_ruleset(_metadata, ACCESS_RW, rules);
+	ASSERT_LE(0, ruleset_fd);
+	file_fd = open(file1, O_WRONLY | O_CLOEXEC);
+	ASSERT_LE(0, file_fd);
+
+	enforce_ruleset(_metadata, ruleset_fd);
+	ASSERT_EQ(0, close(ruleset_fd));
+
+	EXPECT_EQ(0, test_chmod(file1, 0644));
+	EXPECT_EQ(0, test_fchmod(file_fd, 0644));
+	EXPECT_EQ(0, test_chmod(file2, 0400));
+	EXPECT_EQ(0, test_chmod(dir1, 0700));
+
+	EXPECT_EQ(0, test_chown(file1, -1, 0));
+	EXPECT_EQ(0, test_fchown(file_fd, -1, 0));
+	EXPECT_EQ(0, test_lchown(file1, -1, 0));
+
+	EXPECT_EQ(0, test_utimensat(file1));
+	EXPECT_EQ(0, test_utimensat_now(file1));
+
+	EXPECT_EQ(0, test_setxattr(file1, "user.test", "a", 1));
+	EXPECT_EQ(0, test_getxattr(file1, "user.test", NULL, 0));
+	EXPECT_EQ(0, test_listxattr(file1, NULL, 0));
+	EXPECT_EQ(0, test_removexattr(file1, "user.test"));
+
+	EXPECT_EQ(0, test_stat(file1, &statbuf));
+	EXPECT_EQ(0, test_fstat(file_fd, &statbuf));
+	EXPECT_EQ(0, test_stat(dir1, &statbuf));
+
+	ASSERT_EQ(0, close(file_fd));
+}
+
+TEST_F_FORK(layout1, write_metadata)
+{
+	int file_fd, file2_fd, trunc_fd;
+	int ruleset_fd;
+	const char *const file1 = file1_s1d1;
+	const char *const file2 = file2_s1d1;
+	const char *const trunc_file = file1_s1d2;
+	const char *const dir1 = dir_s1d1;
+	struct stat statbuf;
+	const struct rule rules[] = {
+		{
+			.path = file1,
+			.access = LANDLOCK_ACCESS_FS_WRITE_FILE |
+				  LANDLOCK_ACCESS_FS_WRITE_METADATA,
+		},
+		{
+			.path = file2,
+			.access = LANDLOCK_ACCESS_FS_READ_FILE |
+				  LANDLOCK_ACCESS_FS_WRITE_FILE,
+		},
+		{
+			.path = dir1,
+			.access = ACCESS_RW,
+		},
+		{},
+	};
+
+	ruleset_fd = create_ruleset(_metadata, ACCESS_RW |
+				    LANDLOCK_ACCESS_FS_WRITE_METADATA, rules);
+	ASSERT_LE(0, ruleset_fd);
+	file_fd = open(file1, O_WRONLY | O_CLOEXEC);
+	ASSERT_LE(0, file_fd);
+	file2_fd = open(file2, O_RDWR | O_CLOEXEC);
+	ASSERT_LE(0, file2_fd);
+	trunc_fd = open(trunc_file, O_RDWR | O_CLOEXEC);
+	ASSERT_LE(0, trunc_fd);
+
+	/*
+	 * Arm the setuid bit for the implicit clearing tests below:
+	 * writing or truncating a setuid file clears that bit when the
+	 * caller has no CAP_FSETID, which is the case here because
+	 * tests run without capabilities (see disable_caps() in
+	 * prepare_layout()).
+	 */
+	ASSERT_EQ(0, fchmod(file2_fd, 04666));
+	ASSERT_EQ(0, fchmod(trunc_fd, 04666));
+
+	enforce_ruleset(_metadata, ruleset_fd);
+	ASSERT_EQ(0, close(ruleset_fd));
+
+	/* file1 has WRITE_METADATA: allowed */
+	EXPECT_EQ(0, test_chmod(file1, 0644));
+	EXPECT_EQ(0, test_fchmod(file_fd, 0644));
+	EXPECT_EQ(0, test_chown(file1, -1, 0));
+	EXPECT_EQ(0, test_fchown(file_fd, -1, 0));
+	EXPECT_EQ(0, test_lchown(file1, -1, 0));
+	EXPECT_EQ(0, test_utimensat(file1));
+	EXPECT_EQ(0, test_utimensat_now(file1));
+	EXPECT_EQ(0, test_setxattr(file1, "user.test", "a", 1));
+	EXPECT_EQ(0, test_removexattr(file1, "user.test"));
+
+	/*
+	 * Writing is not an explicit metadata change: implicit timestamp
+	 * updates and the implicit setuid-bit clearing are allowed
+	 * without WRITE_METADATA.
+	 */
+	EXPECT_EQ(1, write(file2_fd, "a", 1));
+	ASSERT_EQ(0, fstat(file2_fd, &statbuf));
+	EXPECT_EQ(0, statbuf.st_mode & S_ISUID);
+
+	/* file2 does not have WRITE_METADATA: denied */
+	EXPECT_EQ(EACCES, test_chmod(file2, 0400));
+	EXPECT_EQ(EACCES, test_chown(file2, -1, 0));
+	EXPECT_EQ(EACCES, test_lchown(file2, -1, 0));
+	EXPECT_EQ(EACCES, test_utimensat(file2));
+	EXPECT_EQ(EACCES, test_utimensat_now(file2));
+	EXPECT_EQ(EACCES, test_setxattr(file2, "user.test", "a", 1));
+	EXPECT_EQ(EACCES, test_removexattr(file2, "user.test"));
+
+	/* dir1 does not have WRITE_METADATA: denied */
+	EXPECT_EQ(EACCES, test_chmod(dir1, 0700));
+	EXPECT_EQ(EACCES, test_chown(dir1, -1, 0));
+
+	/*
+	 * Truncating a setuid file implicitly clears the setuid bit as
+	 * well: this must not require WRITE_METADATA, which trunc_file
+	 * does not have.
+	 */
+	EXPECT_EQ(0, ftruncate(trunc_fd, 0));
+	ASSERT_EQ(0, fstat(trunc_fd, &statbuf));
+	EXPECT_EQ(0, statbuf.st_mode & S_ISUID);
+
+	ASSERT_EQ(0, close(file_fd));
+	ASSERT_EQ(0, close(file2_fd));
+	ASSERT_EQ(0, close(trunc_fd));
+}
+
+TEST_F_FORK(layout1, read_metadata)
+{
+	int file_fd;
+	int ruleset_fd;
+	const char *const file1 = file1_s1d1;
+	const char *const file2 = file2_s1d1;
+	const char *const dir1 = dir_s1d1;
+	struct stat statbuf;
+	const struct rule rules[] = {
+		{
+			.path = file1,
+			.access = LANDLOCK_ACCESS_FS_READ_FILE |
+				  LANDLOCK_ACCESS_FS_READ_METADATA,
+		},
+		{
+			.path = file2,
+			.access = LANDLOCK_ACCESS_FS_READ_FILE |
+				  LANDLOCK_ACCESS_FS_WRITE_FILE,
+		},
+		{
+			.path = dir1,
+			.access = ACCESS_RW,
+		},
+		{},
+	};
+
+	ruleset_fd = create_ruleset(_metadata, ACCESS_RW |
+				    LANDLOCK_ACCESS_FS_READ_METADATA, rules);
+	ASSERT_LE(0, ruleset_fd);
+
+	ASSERT_EQ(0, setxattr(file1, "user.test", "a", 1, 0));
+	ASSERT_EQ(0, setxattr(file2, "user.test", "a", 1, 0));
+
+	file_fd = open(file1, O_RDONLY | O_CLOEXEC);
+	ASSERT_LE(0, file_fd);
+
+	enforce_ruleset(_metadata, ruleset_fd);
+	ASSERT_EQ(0, close(ruleset_fd));
+
+	/* file1 has READ_METADATA: allowed */
+	EXPECT_EQ(0, test_stat(file1, &statbuf));
+	EXPECT_EQ(0, test_fstat(file_fd, &statbuf));
+	EXPECT_EQ(0, test_getxattr(file1, "user.test", NULL, 0));
+	EXPECT_EQ(0, test_listxattr(file1, NULL, 0));
+
+	/* file2 does not have READ_METADATA: denied */
+	EXPECT_EQ(EACCES, test_stat(file2, &statbuf));
+	EXPECT_EQ(EACCES, test_getxattr(file2, "user.test", NULL, 0));
+	EXPECT_EQ(EACCES, test_listxattr(file2, NULL, 0));
+	/* dir1 does not have READ_METADATA: denied */
+	EXPECT_EQ(EACCES, test_stat(dir1, &statbuf));
+
+	ASSERT_EQ(0, close(file_fd));
+}
+
+/* Invokes ioctl(FS_IOC_GETFLAGS) and returns its errno or 0. */
+static int test_getflags(int fd, unsigned int *const flags)
+{
+	if (ioctl(fd, FS_IOC_GETFLAGS, flags) < 0)
+		return errno;
+	return 0;
+}
+
+/* Invokes ioctl(FS_IOC_SETFLAGS) and returns its errno or 0. */
+static int test_setflags(int fd, const unsigned int flags)
+{
+	unsigned int flags_ = flags;
+
+	if (ioctl(fd, FS_IOC_SETFLAGS, &flags_) < 0)
+		return errno;
+	return 0;
+}
+
+#ifndef __NR_file_getattr
+#define __NR_file_getattr 468
+#endif
+#ifndef __NR_file_setattr
+#define __NR_file_setattr 469
+#endif
+
+/* Invokes file_getattr(2) and returns its errno or 0. */
+static int test_file_getattr(int dfd, const char *const path,
+			     struct file_attr *const fattr,
+			     const unsigned int at_flags)
+{
+	if (syscall(__NR_file_getattr, dfd, path, fattr, sizeof(*fattr),
+		    at_flags) < 0)
+		return errno;
+	return 0;
+}
+
+/* Invokes file_setattr(2) and returns its errno or 0. */
+static int test_file_setattr(int dfd, const char *const path,
+			     struct file_attr *const fattr,
+			     const unsigned int at_flags)
+{
+	if (syscall(__NR_file_setattr, dfd, path, fattr, sizeof(*fattr),
+		    at_flags) < 0)
+		return errno;
+	return 0;
+}
+
+TEST_F_FORK(layout1, fileattr)
+{
+	const struct rule rules[] = {
+		{
+			.path = file1_s1d1,
+			.access = LANDLOCK_ACCESS_FS_READ_METADATA |
+				  LANDLOCK_ACCESS_FS_WRITE_METADATA,
+		},
+		{},
+	};
+	struct file_attr fattr;
+	unsigned int flags;
+	int fd, fd2, ruleset_fd;
+
+	ruleset_fd = create_ruleset(
+		_metadata,
+		LANDLOCK_ACCESS_FS_READ_METADATA |
+			LANDLOCK_ACCESS_FS_WRITE_METADATA,
+		rules);
+	ASSERT_LE(0, ruleset_fd);
+
+	fd = open(file1_s1d1, O_RDONLY | O_CLOEXEC);
+	ASSERT_LE(0, fd);
+
+	enforce_ruleset(_metadata, ruleset_fd);
+	ASSERT_EQ(0, close(ruleset_fd));
+
+	/* Allowed file: FS_IOC_GETFLAGS */
+	flags = 0;
+	EXPECT_EQ(0, test_getflags(fd, &flags));
+	EXPECT_EQ(0, flags & FS_NODUMP_FL);
+
+	/* Allowed file: FS_IOC_SETFLAGS */
+	EXPECT_EQ(0, test_setflags(fd, FS_NODUMP_FL));
+	flags = 0;
+	EXPECT_EQ(0, test_getflags(fd, &flags));
+	EXPECT_EQ(FS_NODUMP_FL, flags & FS_NODUMP_FL);
+	EXPECT_EQ(0, test_setflags(fd, 0));
+
+	/* Allowed file: file_getattr(2), with a path and with AT_EMPTY_PATH */
+	memset(&fattr, 0, sizeof(fattr));
+	EXPECT_EQ(0, test_file_getattr(AT_FDCWD, file1_s1d1, &fattr, 0));
+	EXPECT_EQ(0, fattr.fa_xflags & FS_XFLAG_NODUMP);
+	memset(&fattr, 0, sizeof(fattr));
+	EXPECT_EQ(0, test_file_getattr(fd, NULL, &fattr, AT_EMPTY_PATH));
+
+	/* Allowed file: file_setattr(2), with a path and with AT_EMPTY_PATH */
+	memset(&fattr, 0, sizeof(fattr));
+	fattr.fa_xflags = FS_XFLAG_NODUMP;
+	EXPECT_EQ(0, test_file_setattr(AT_FDCWD, file1_s1d1, &fattr, 0));
+	memset(&fattr, 0, sizeof(fattr));
+	EXPECT_EQ(0, test_file_getattr(AT_FDCWD, file1_s1d1, &fattr, 0));
+	EXPECT_EQ(FS_XFLAG_NODUMP, fattr.fa_xflags & FS_XFLAG_NODUMP);
+	memset(&fattr, 0, sizeof(fattr));
+	fattr.fa_xflags = 0;
+	EXPECT_EQ(0, test_file_setattr(fd, NULL, &fattr, AT_EMPTY_PATH));
+
+	/* Non-allowed file: FS_IOC_GETFLAGS and FS_IOC_SETFLAGS */
+	fd2 = open(file2_s1d1, O_RDONLY | O_CLOEXEC);
+	ASSERT_LE(0, fd2);
+	EXPECT_EQ(EACCES, test_getflags(fd2, &flags));
+	EXPECT_EQ(EACCES, test_setflags(fd2, FS_NODUMP_FL));
+
+	/* Non-allowed file: file_getattr(2) and file_setattr(2) */
+	memset(&fattr, 0, sizeof(fattr));
+	EXPECT_EQ(EACCES, test_file_getattr(AT_FDCWD, file2_s1d1, &fattr, 0));
+	fattr.fa_xflags = FS_XFLAG_NODUMP;
+	EXPECT_EQ(EACCES, test_file_setattr(AT_FDCWD, file2_s1d1, &fattr, 0));
+
+	ASSERT_EQ(0, close(fd));
+	ASSERT_EQ(0, close(fd2));
+}
+
+TEST_F_FORK(layout1, fileattr_write_only)
+{
+	const struct rule rules[] = {
+		{
+			.path = file1_s1d1,
+			.access = LANDLOCK_ACCESS_FS_WRITE_METADATA,
+		},
+		{},
+	};
+	unsigned int flags;
+	int fd, ruleset_fd;
+
+	ruleset_fd = create_ruleset(_metadata,
+				    LANDLOCK_ACCESS_FS_WRITE_METADATA, rules);
+	ASSERT_LE(0, ruleset_fd);
+
+	fd = open(file1_s1d1, O_RDONLY | O_CLOEXEC);
+	ASSERT_LE(0, fd);
+
+	enforce_ruleset(_metadata, ruleset_fd);
+	ASSERT_EQ(0, close(ruleset_fd));
+
+	/*
+	 * WRITE_METADATA alone must be enough to set flags: the kernel-side
+	 * read of the old flags must not require READ_METADATA.
+	 */
+	EXPECT_EQ(0, test_setflags(fd, FS_NODUMP_FL));
+	flags = 0;
+	/* READ_METADATA is not handled: reading is allowed. */
+	EXPECT_EQ(0, test_getflags(fd, &flags));
+	EXPECT_EQ(FS_NODUMP_FL, flags & FS_NODUMP_FL);
+	EXPECT_EQ(0, test_setflags(fd, 0));
+
+	ASSERT_EQ(0, close(fd));
+}
+
+TEST_F_FORK(layout2_overlay, fileattr)
+{
+	const struct rule rules[] = {
+		{
+			.path = MERGE_DATA,
+			.access = LANDLOCK_ACCESS_FS_READ_METADATA |
+				  LANDLOCK_ACCESS_FS_WRITE_METADATA,
+		},
+		{},
+	};
+	unsigned int flags;
+	int fd, fd2, ruleset_fd;
+
+	if (self->skip_test)
+		SKIP(return, "overlayfs is not supported (test)");
+
+	ruleset_fd = create_ruleset(
+		_metadata,
+		LANDLOCK_ACCESS_FS_READ_METADATA |
+			LANDLOCK_ACCESS_FS_WRITE_METADATA,
+		rules);
+	ASSERT_LE(0, ruleset_fd);
+
+	enforce_ruleset(_metadata, ruleset_fd);
+	ASSERT_EQ(0, close(ruleset_fd));
+
+	/*
+	 * The overlay mount was created before the ruleset was enforced
+	 * (i.e. as an administrator): the internal forwards to the real
+	 * paths must not interfere with the allowed accesses below.
+	 */
+	fd = open(merge_fl1, O_RDONLY | O_CLOEXEC);
+	ASSERT_LE(0, fd);
+
+	flags = 0;
+	EXPECT_EQ(0, test_getflags(fd, &flags));
+	EXPECT_EQ(0, flags & FS_NODUMP_FL);
+	/* Copies the file up and sets the flag on the upper real file. */
+	EXPECT_EQ(0, test_setflags(fd, FS_NODUMP_FL));
+	flags = 0;
+	EXPECT_EQ(0, test_getflags(fd, &flags));
+	EXPECT_EQ(FS_NODUMP_FL, flags & FS_NODUMP_FL);
+	EXPECT_EQ(0, test_setflags(fd, 0));
+
+	ASSERT_EQ(0, close(fd));
+
+	/* Non-allowed path: raw lower tmpfs path, outside of MERGE_DATA. */
+	fd2 = open(lower_fl1, O_RDONLY | O_CLOEXEC);
+	ASSERT_LE(0, fd2);
+	EXPECT_EQ(EACCES, test_getflags(fd2, &flags));
+	EXPECT_EQ(EACCES, test_setflags(fd2, FS_NODUMP_FL));
+	ASSERT_EQ(0, close(fd2));
+
+	/*
+	 * Removes the copied-up file to keep the upper tree in the state
+	 * expected by FIXTURE_TEARDOWN_PARENT().
+	 */
+	EXPECT_EQ(0, remove_path(merge_fl1));
+}
+
+/*
+ * A landlocked process cannot change the mount topology with mount(2),
+ * even with CAP_SYS_ADMIN (see hook_sb_mount()).  An overlay filesystem
+ * can therefore not be mounted this way by a restricted process.
+ */
+TEST_F_FORK(layout1, overlay_mount_denied)
+{
+	const char lower_dir[] = TMP_DIR "/ovl-lower";
+	const char upper_dir[] = TMP_DIR "/ovl-upper";
+	const char work_dir[] = TMP_DIR "/ovl-work";
+	const char merge_dir[] = TMP_DIR "/ovl-merge";
+	char mount_data[256];
+	const struct rule rules[] = {
+		{
+			.path = merge_dir,
+			.access = LANDLOCK_ACCESS_FS_READ_METADATA |
+				  LANDLOCK_ACCESS_FS_WRITE_METADATA,
+		},
+		{},
+	};
+	int ruleset_fd;
+
+	ASSERT_EQ(0, mkdir(lower_dir, 0700));
+	ASSERT_EQ(0, mkdir(upper_dir, 0700));
+	ASSERT_EQ(0, mkdir(work_dir, 0700));
+	ASSERT_EQ(0, mkdir(merge_dir, 0700));
+
+	snprintf(mount_data, sizeof(mount_data),
+		 "lowerdir=%s,upperdir=%s,workdir=%s", lower_dir, upper_dir,
+		 work_dir);
+
+	ruleset_fd = create_ruleset(
+		_metadata,
+		LANDLOCK_ACCESS_FS_READ_METADATA |
+			LANDLOCK_ACCESS_FS_WRITE_METADATA,
+		rules);
+	ASSERT_LE(0, ruleset_fd);
+
+	enforce_ruleset(_metadata, ruleset_fd);
+	ASSERT_EQ(0, close(ruleset_fd));
+
+	set_cap(_metadata, CAP_SYS_ADMIN);
+	EXPECT_EQ(-1, mount("overlay", merge_dir, "overlay", 0, mount_data));
+	EXPECT_EQ(EPERM, errno);
+	clear_cap(_metadata, CAP_SYS_ADMIN);
+
+	EXPECT_EQ(0, rmdir(lower_dir));
+	EXPECT_EQ(0, rmdir(upper_dir));
+	EXPECT_EQ(0, rmdir(work_dir));
+	EXPECT_EQ(0, rmdir(merge_dir));
+}
+
 TEST_HARNESS_MAIN
diff --git a/tools/testing/selftests/landlock/trace_fs_test.c b/tools/testing/selftests/landlock/trace_fs_test.c
index 64014ade3a0e9..97506d249c4f1 100644
--- a/tools/testing/selftests/landlock/trace_fs_test.c
+++ b/tools/testing/selftests/landlock/trace_fs_test.c
@@ -252,7 +252,8 @@ TEST_F(trace_fs, add_rule_path_beneath)
 TEST_F(trace_fs, add_rule_path_beneath_escaped_path_overflow)
 {
 	static const char access_prefix[] = "execute|write_file|read_file|";
-	static const char access_suffix[] = "|ioctl_dev|resolve_unix";
+	static const char access_suffix[] =
+		"|ioctl_dev|resolve_unix|read_metadata|write_metadata";
 	struct landlock_ruleset_attr ruleset_attr = {
 		.handled_access_fs = LANDLOCK_ACCESS_FS_READ_FILE,
 	};

3/2 2026/10/15 15:55 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 94136
							output: 38
							thoughts: 935
						

Thoughts:
**Kernel Patch Evaluation: My Initial Assessment**

Okay, so I've got a Linux kernel patch series to evaluate. My first instinct is to dive into what this thing *does*. Let's look at the diff. The title is a bit vague, "syz-cluster: applied patch under review," but the changes themselves are what matter.

Alright, the changes are:
1.  **Documentation Updates:** Some modifications to the documentation specifically, with files: `Documentation/bpf/fs_kfuncs.rst` and `Documentation/userspace-api/landlock.rst`. Nothing too alarming here.
2.  **VFS/LSM Deep Dive:** *This* is where things get interesting. We're looking at a major overhaul of how the VFS and security subsystems interact. We're talking about transitioning core LSM hooks, like `inode_setattr` to `path_setattr`, `inode_getattr` to `path_getattr` and so forth, over to use `path` instead of `dentry` or `mnt_idmap`... big changes! This also involves updates to vital VFS functions: `vfs_setxattr`, `vfs_getxattr`, `vfs_listxattr`, `vfs_removexattr`, etc. They now accept `const struct path *`. Internal forwarding functions also were added (`__notify_change`, `__vfs_fileattr_get`, and `__vfs_fileattr_set`). This ripples through various filesystems (devtmpfs, zloop, ecryptfs, etc.), and impacts core kernel functions like: `notify_change`, `do_truncate`. It also involves AppArmor, SELinux, Smack, Tomoyo, EVM, IMA, and commoncap. Landlock has also been updated, adding hooks like `LANDLOCK_ACCESS_FS_READ_METADATA`, bumping the ABI version to 13. Finally BPF LSM hooks and BTF sets are also transitioned to the new `path_*` hooks.

This isn't just a minor tweak; this is a pretty massive restructuring of core filesystem and security logic!

My next immediate thought? **Reachability.** Can we hit this code with a standard virtualized environment? QEMU/GCE (amd64) are the standard test environments, so can we reach the code in those? VFS, Landlock, LSM, xattr, stat, chmod, chown, utimes, etc... These are all core syscalls and subsystems that userspace can access directly. **Yes, this is definitely reachable.**

Now, let's look at the triage criteria. The patch aims to discover crashes, regressions, exposed bugs, and assertions. The primary gate is reachability. Modifications in memory management, BPF, scheduler, core networking, VFS, and syscall handling are all in scope. This patch hits the VFS changes, which are core functionality. It also involves refactoring, including code cleanups! Runtime assertions and defensive checks are also something to note. Finally, it involves standard syscalls, making this worth fuzzing!

This is a clear `WorthFuzzing=true` scenario. The focus is to identify potential regressions, or new bugs.

Next, I need to check `FocusSymbols` and `EnableConfigs`. I will use the git log or the diff to identify the specific functions modified or introduced by this patch. I'll need to run a tool, or use `git log` or `git diff` to get a precise scope.



4/2 2026/10/15 15:55 tool grepper
0m Args:
{
  "Expression": "LANDLOCK_ACCESS_FS_READ_METADATA",
  "PathPrefixes": [
    "security/landlock/"
  ]
}

Results:
{
  "Output": "security/landlock/fs.c=259=static struct landlock_object *get_inode_object(struct inode *const inode)\n--\nsecurity/landlock/fs.c-320-\tLANDLOCK_ACCESS_FS_READ_FILE | \\\nsecurity/landlock/fs.c:321:\tLANDLOCK_ACCESS_FS_READ_METADATA | \\\nsecurity/landlock/fs.c-322-\tLANDLOCK_ACCESS_FS_WRITE_METADATA | \\\n--\nsecurity/landlock/fs.c=1681=static int hook_path_getattr(const struct path *const path)\n--\nsecurity/landlock/fs.c-1683-\treturn current_check_access_path(path,\nsecurity/landlock/fs.c:1684:\t\t\t\t\tLANDLOCK_ACCESS_FS_READ_METADATA);\nsecurity/landlock/fs.c-1685-}\n--\nsecurity/landlock/fs.c=1687=static int hook_path_file_getattr(const struct path *const path,\n--\nsecurity/landlock/fs.c-1690-\treturn current_check_access_path(path,\nsecurity/landlock/fs.c:1691:\t\t\t\t\tLANDLOCK_ACCESS_FS_READ_METADATA);\nsecurity/landlock/fs.c-1692-}\n--\nsecurity/landlock/fs.c=1752=static int hook_path_getxattr(const struct path *const path,\n--\nsecurity/landlock/fs.c-1755-\treturn current_check_access_path(path,\nsecurity/landlock/fs.c:1756:\t\t\t\t\tLANDLOCK_ACCESS_FS_READ_METADATA);\nsecurity/landlock/fs.c-1757-}\n--\nsecurity/landlock/fs.c=1759=static int hook_path_listxattr(const struct path *const path)\n--\nsecurity/landlock/fs.c-1761-\treturn current_check_access_path(path,\nsecurity/landlock/fs.c:1762:\t\t\t\t\tLANDLOCK_ACCESS_FS_READ_METADATA);\nsecurity/landlock/fs.c-1763-}\n--\nsecurity/landlock/fs.c=1780=static int hook_path_get_acl(const struct path *const path,\n--\nsecurity/landlock/fs.c-1783-\treturn current_check_access_path(path,\nsecurity/landlock/fs.c:1784:\t\t\t\t\tLANDLOCK_ACCESS_FS_READ_METADATA);\nsecurity/landlock/fs.c-1785-}\n"
}

5/2 2026/10/15 15:55 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 96521
							output: 33
							thoughts: 27
						

Thoughts:
Okay, let's dive into this. Here's how I'd approach this task, as if these were my internal thoughts:

**Investigating Landlock and LSM Hook Configuration**

Right, let's get down to brass tacks. I need to figure out which kernel configurations are actually enabling Landlock and its LSM (Linux Security Modules) hooks. No time for guesswork; I'll trace this logically. The best place to start is, as always, the central configuration file for Landlock itself. That means I need to look directly at the `security/landlock/Kconfig` file. That should give me a clear picture of the relevant configuration options. Hopefully, it'll explicitly lay out which features depend on which other settings and how Landlock integrates with the LSM framework. This will lead to the next phase of the investigation.



6/2 2026/10/15 15:55 tool read-file
0m Args:
{
  "File": "security/landlock/Kconfig",
  "FirstLine": 1,
  "LineCount": 50
}

Results:
{
  "Contents": "   1:\t# SPDX-License-Identifier: GPL-2.0-only\n   2:\t\n   3:\tconfig SECURITY_LANDLOCK\n   4:\t\tbool \"Landlock support\"\n   5:\t\tdepends on SECURITY\n   6:\t\tselect SECURITY_NETWORK\n   7:\t\tselect SECURITY_PATH\n   8:\t\thelp\n   9:\t\t  Landlock is a sandboxing mechanism that enables processes to restrict\n  10:\t\t  themselves (and their future children) by gradually enforcing\n  11:\t\t  tailored access control policies.  A Landlock security policy is a\n  12:\t\t  set of access rights (e.g. open a file in read-only, make a\n  13:\t\t  directory, etc.) tied to a file hierarchy.  Such policy can be\n  14:\t\t  configured and enforced by any processes for themselves using the\n  15:\t\t  dedicated system calls: landlock_create_ruleset(),\n  16:\t\t  landlock_add_rule(), and landlock_restrict_self().\n  17:\t\n  18:\t\t  See Documentation/userspace-api/landlock.rst for further information.\n  19:\t\n  20:\t\t  If you are unsure how to answer this question, answer N.  Otherwise,\n  21:\t\t  you should also prepend \"landlock,\" to the content of CONFIG_LSM to\n  22:\t\t  enable Landlock at boot time.\n  23:\t\n  24:\tconfig SECURITY_LANDLOCK_LOG\n  25:\t\tbool\n  26:\t\tdepends on SECURITY_LANDLOCK\n  27:\t\tdefault y if AUDIT || TRACEPOINTS\n  28:\t\n  29:\tconfig SECURITY_LANDLOCK_KUNIT_TEST\n  30:\t\tbool \"KUnit tests for Landlock\" if !KUNIT_ALL_TESTS\n  31:\t\tdepends on KUNIT=y\n  32:\t\tdepends on SECURITY_LANDLOCK\n  33:\t\tdefault KUNIT_ALL_TESTS\n  34:\t\thelp\n  35:\t\t  Build KUnit tests for Landlock.\n  36:\t\n  37:\t\t  See the KUnit documentation in Documentation/dev-tools/kunit\n  38:\t\n  39:\t\t  Run all KUnit tests for Landlock with:\n  40:\t\t  ./tools/testing/kunit/kunit.py run --kunitconfig security/landlock\n  41:\t\n  42:\t\t  If you are unsure how to answer this question, answer N.\n"
}

7/2 2026/10/15 15:55 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 97369
							output: 38
							thoughts: 68
						

Thoughts:
Here's my thought process, as an expert in filesystems, looking at this code:

**Diving into Extended Attributes and ACLs**

Okay, so we're talking about extended attributes and access control lists, the usual suspects when dealing with filesystem metadata. To get a handle on this, I'm thinking I'll start by checking out the relevant source code files. Let's see... `fs/xattr.c` is the obvious starting point for extended attributes. Then, I should probably look at `fs/attr.c` and `fs/file_attr.c` as they probably provide core attribute handling. And since we're also considering ACLs, `fs/posix_acl.c` needs to be in the mix.

Once I've got a grip on the core files, I need to understand what's *actually* enabled. What Kconfigs gate the functionality in these files? I'll need to know which features are optional, and how they relate to the broader configuration. I'll likely need to trace dependencies from configuration options, all the way down to code.

Finally, to tie it all together, I should probably grep the `Makefile` in the `fs/` directory. That's usually where the build dependencies are defined, so I can see what source files are compiled based on what Kconfig options. Alternatively, since we know there's at least one ACL specific config, I can try that one. This should give me a quick understanding of the build-time requirements and dependencies for these features.



8/2 2026/10/15 15:56 tool grepper
0m Args:
{
  "Expression": "(file_attr|posix_acl|xattr)\\.o",
  "PathPrefixes": [
    "fs/"
  ]
}

Results:
{
  "Output": "fs/9p/Makefile=2=obj-$(CONFIG_9P_FS) := 9p.o\n--\nfs/9p/Makefile-13-\tfid.o  \\\nfs/9p/Makefile:14:\txattr.o\nfs/9p/Makefile-15-\n--\nfs/Makefile=10=obj-y :=\topen.o read_write.o file_table.o super.o \\\n--\nfs/Makefile-13-\t\tattr.o bad_inode.o file.o filesystems.o namespace.o \\\nfs/Makefile:14:\t\tseq_file.o xattr.o libfs.o fs-writeback.o \\\nfs/Makefile-15-\t\tpnode.o splice.o sync.o utimes.o d_path.o \\\n--\nfs/Makefile-18-\t\tkernel_read_file.o mnt_idmapping.o remap_range.o pidfs.o \\\nfs/Makefile:19:\t\tfile_attr.o fserror.o nullfs.o failfs.o\nfs/Makefile-20-\n--\nfs/Makefile=44=obj-$(CONFIG_FS_MBCACHE)\t+= mbcache.o\nfs/Makefile:45:obj-$(CONFIG_FS_POSIX_ACL)\t+= posix_acl.o\nfs/Makefile-46-obj-$(CONFIG_NFS_COMMON)\t+= nfs_common/\n--\nfs/afs/Makefile=6=kafs-y := \\\n--\nfs/afs/Makefile-41-\twrite.o \\\nfs/afs/Makefile:42:\txattr.o \\\nfs/afs/Makefile-43-\tyfsclient.o\n--\nfs/btrfs/Makefile=24=btrfs-y += super.o ctree.o extent-tree.o print-tree.o root-tree.o dir-item.o \\\n--\nfs/btrfs/Makefile-26-\t   transaction.o inode.o file.o defrag.o \\\nfs/btrfs/Makefile:27:\t   extent_map.o sysfs.o accessors.o xattr.o ordered-data.o \\\nfs/btrfs/Makefile-28-\t   extent_io.o volumes.o async-thread.o ioctl.o locking.o orphan.o \\\n--\nfs/cachefiles/Makefile=6=cachefiles-y := \\\n--\nfs/cachefiles/Makefile-15-\tvolume.o \\\nfs/cachefiles/Makefile:16:\txattr.o\nfs/cachefiles/Makefile-17-\n--\nfs/ceph/Makefile=8=ceph-y := super.o inode.o dir.o file.o locks.o addr.o ioctl.o \\\nfs/ceph/Makefile:9:\texport.o caps.o snap.o xattr.o quota.o io.o \\\nfs/ceph/Makefile-10-\tmds_client.o mdsmap.o strings.o ceph_frag.o \\\n--\nfs/ceph/xattr.c=1107=static int ceph_sync_setxattr(struct inode *inode, const char *name,\n--\nfs/ceph/xattr.c-1153-\t\treq-\u003er_args.setxattr.flags = cpu_to_le32(flags);\nfs/ceph/xattr.c:1154:\t\treq-\u003er_args.setxattr.osdmap_epoch =\nfs/ceph/xattr.c-1155-\t\t\tcpu_to_le32(osdc-\u003eosdmap-\u003eepoch);\n--\nfs/erofs/Makefile=4=erofs-objs := super.o inode.o data.o namei.o dir.o sysfs.o\nfs/erofs/Makefile:5:erofs-$(CONFIG_EROFS_FS_XATTR) += xattr.o\nfs/erofs/Makefile-6-erofs-$(CONFIG_EROFS_FS_ZIP) += decompressor.o zmap.o zdata.o zutil.o\n--\nfs/ext2/Makefile=14=CFLAGS_trace.o := -I$(src)\nfs/ext2/Makefile-15-\nfs/ext2/Makefile:16:ext2-$(CONFIG_EXT2_FS_XATTR)\t += xattr.o xattr_user.o xattr_trusted.o\nfs/ext2/Makefile-17-ext2-$(CONFIG_EXT2_FS_POSIX_ACL) += acl.o\n--\nfs/ext4/Makefile=8=ext4-y\t:= balloc.o bitmap.o block_validity.o dir.o ext4_jbd2.o extents.o \\\n--\nfs/ext4/Makefile-11-\t\tmmp.o move_extent.o namei.o page-io.o readpage.o resize.o \\\nfs/ext4/Makefile:12:\t\tsuper.o symlink.o sysfs.o xattr.o xattr_hurd.o xattr_trusted.o \\\nfs/ext4/Makefile-13-\t\txattr_user.o fast_commit.o orphan.o\n--\nfs/f2fs/Makefile=7=f2fs-$(CONFIG_F2FS_STAT_FS) += debug.o\nfs/f2fs/Makefile:8:f2fs-$(CONFIG_F2FS_FS_XATTR) += xattr.o\nfs/f2fs/Makefile-9-f2fs-$(CONFIG_F2FS_FS_POSIX_ACL) += acl.o\n--\nfs/fuse/Makefile=13=fuse-y := trace.o\t# put trace.o first so we see ftrace errors sooner\nfs/fuse/Makefile:14:fuse-y += dev.o dir.o file.o inode.o control.o xattr.o acl.o readdir.o ioctl.o req_timeout.o req.o\nfs/fuse/Makefile-15-fuse-y += poll.o notify.o\n--\nfs/gfs2/Makefile=3=obj-$(CONFIG_GFS2_FS) += gfs2.o\nfs/gfs2/Makefile:4:gfs2-y := acl.o bmap.o dir.o xattr.o glock.o \\\nfs/gfs2/Makefile-5-\tglops.o log.o lops.o main.o meta_io.o \\\n--\nfs/hfsplus/Makefile=8=hfsplus-objs := super.o options.o inode.o ioctl.o extents.o catalog.o dir.o btree.o \\\nfs/hfsplus/Makefile-9-\t\tbnode.o brec.o bfind.o tables.o unicode.o wrapper.o bitmap.o part_tbl.o \\\nfs/hfsplus/Makefile:10:\t\tattributes.o xattr.o xattr_user.o xattr_security.o xattr_trusted.o\nfs/hfsplus/Makefile-11-\n--\nfs/jffs2/Makefile=14=jffs2-$(CONFIG_JFFS2_FS_WRITEBUFFER)\t+= wbuf.o\nfs/jffs2/Makefile:15:jffs2-$(CONFIG_JFFS2_FS_XATTR)\t\t+= xattr.o xattr_trusted.o xattr_user.o\nfs/jffs2/Makefile-16-jffs2-$(CONFIG_JFFS2_FS_SECURITY)\t+= security.o\n--\nfs/jfs/Makefile=8=jfs-y    := super.o file.o inode.o namei.o jfs_mount.o jfs_umount.o \\\n--\nfs/jfs/Makefile-12-\t    jfs_logmgr.o jfs_txnmgr.o \\\nfs/jfs/Makefile:13:\t    resize.o xattr.o ioctl.o\nfs/jfs/Makefile-14-\n--\nfs/nfs/Makefile=33=nfsv4-$(CONFIG_NFS_V4_0)\t+= nfs40client.o nfs40proc.o\nfs/nfs/Makefile:34:nfsv4-$(CONFIG_NFS_V4_2)\t+= nfs42proc.o nfs42xattr.o\nfs/nfs/Makefile-35-\n--\nfs/ntfs3/Makefile=33=ntfs3-y :=\tattrib.o \\\n--\nfs/ntfs3/Makefile-49-\t\tupcase.o \\\nfs/ntfs3/Makefile:50:\t\txattr.o\nfs/ntfs3/Makefile-51-\n--\nfs/ocfs2/Makefile=11=ocfs2-objs := \\\n--\nfs/ocfs2/Makefile-41-\tquota_global.o\t\t\\\nfs/ocfs2/Makefile:42:\txattr.o\t\t\t\\\nfs/ocfs2/Makefile-43-\tacl.o\t\\\n--\nfs/orangefs/Makefile=6=obj-$(CONFIG_ORANGEFS_FS) += orangefs.o\nfs/orangefs/Makefile-7-\nfs/orangefs/Makefile:8:orangefs-objs := acl.o file.o orangefs-cache.o orangefs-utils.o xattr.o \\\nfs/orangefs/Makefile-9-\t\t dcache.o inode.o orangefs-sysfs.o orangefs-mod.o super.o \\\n--\nfs/smb/client/Makefile=19=$(obj)/cifs_spnego_negtokeninit.asn1.o: $(obj)/cifs_spnego_negtokeninit.asn1.c $(obj)/cifs_spnego_negtokeninit.asn1.h\nfs/smb/client/Makefile-20-\nfs/smb/client/Makefile:21:cifs-$(CONFIG_CIFS_XATTR) += xattr.o\nfs/smb/client/Makefile-22-\n--\nfs/squashfs/Makefile=13=squashfs-$(CONFIG_SQUASHFS_DECOMP_MULTI_PERCPU) += decompressor_multi_percpu.o\nfs/squashfs/Makefile:14:squashfs-$(CONFIG_SQUASHFS_XATTR) += xattr.o xattr_id.o\nfs/squashfs/Makefile-15-squashfs-$(CONFIG_SQUASHFS_LZ4) += lz4_wrapper.o\n--\nfs/ubifs/Makefile=9=ubifs-$(CONFIG_FS_ENCRYPTION) += crypto.o\nfs/ubifs/Makefile:10:ubifs-$(CONFIG_UBIFS_FS_XATTR) += xattr.o\nfs/ubifs/Makefile-11-ubifs-$(CONFIG_UBIFS_FS_AUTHENTICATION) += auth.o\n--\nfs/xfs/Makefile=71=xfs-y\t\t\t\t+= xfs_aops.o \\\n--\nfs/xfs/Makefile-110-\t\t\t\t   xfs_verify_media.o \\\nfs/xfs/Makefile:111:\t\t\t\t   xfs_xattr.o\nfs/xfs/Makefile-112-\n--\nfs/xfs/Makefile=169=xfs-y\t\t\t\t+= $(addprefix scrub/, \\\n--\nfs/xfs/Makefile-186-\t\t\t\t   iscan.o \\\nfs/xfs/Makefile:187:\t\t\t\t   listxattr.o \\\nfs/xfs/Makefile-188-\t\t\t\t   metapath.o \\\n"
}

9/2 2026/10/15 15:56 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 100580
							output: 27
							thoughts: 147
						

Thoughts:
Okay, let's break this down.

**Diving into the Filesystem Configuration**

Right, so I'm looking at `fs/Makefile` and immediately see that `attr.o`, `xattr.o`, and `file_attr.o` are all compiled in directly, signified by `obj-y`. Interesting. Then, `posix_acl.o` is conditional based on `CONFIG_FS_POSIX_ACL`. That's standard practice, nothing surprising there. Now, `security/landlock` is keyed off of `CONFIG_SECURITY_LANDLOCK`. Makes sense, landlock is security-related, obviously.

Hmm, landlock brings up `CONFIG_SECURITY_PATH`. I need to track that dependency. Let me check `security/landlock/Kconfig` directly. Aha! Here we go:

```
config SECURITY_LANDLOCK
	bool "Landlock support"
	depends on SECURITY
	select SECURITY_NETWORK
	select SECURITY_PATH
```

Landlock *selects* `SECURITY_PATH`. Okay, so `SECURITY_PATH` must be defined somewhere else, likely the parent Kconfig file for the security subsystem. That's a good place to start. I'll need to jump over to `security/Kconfig` to see the definition. Time to see what that Kconfig has to say about it.



10/2 2026/10/15 15:56 tool grepper
0m Args:
{
  "Expression": "config SECURITY_PATH",
  "PathPrefixes": [
    "security/"
  ]
}

Results:
{
  "Output": "security/Kconfig=117=config SECURITY_NETWORK_XFRM\n--\nsecurity/Kconfig-129-\nsecurity/Kconfig:130:config SECURITY_PATH\nsecurity/Kconfig-131-\tbool \"Security hooks for pathname based access control\"\n"
}

11/2 2026/10/15 15:56 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 101122
							output: 32
							thoughts: 17
						

Thoughts:
Okay, let's dive into this Kconfig file, specifically around line 130 in `security/Kconfig`. I'm curious to see what's being defined there, and how this particular configuration option fits into the broader security landscape of this system. I want to understand its purpose, its dependencies, and any implications it might have on the overall security posture. Is this related to a specific security module? Does it interact with other crucial configurations? What level of granularity are we dealing with here? Let's get to the specifics and see what's written.



12/2 2026/10/15 15:56 tool read-file
0m Args:
{
  "File": "security/Kconfig",
  "FirstLine": 125,
  "LineCount": 30
}

Results:
{
  "Contents": " 125:\t\t  designated as unlabelled, and only sockets authorized\n 126:\t\t  to communicate unlabelled data can send without using\n 127:\t\t  IPSec.\n 128:\t\t  If you are unsure how to answer this question, answer N.\n 129:\t\n 130:\tconfig SECURITY_PATH\n 131:\t\tbool \"Security hooks for pathname based access control\"\n 132:\t\tdepends on SECURITY\n 133:\t\thelp\n 134:\t\t  This enables the security hooks for pathname based access control.\n 135:\t\t  If enabled, a security module can use these hooks to\n 136:\t\t  implement pathname based access controls.\n 137:\t\t  If you are unsure how to answer this question, answer N.\n 138:\t\n 139:\tconfig INTEL_TXT\n 140:\t\tbool \"Enable Intel(R) Trusted Execution Technology (Intel(R) TXT)\"\n 141:\t\tdepends on HAVE_INTEL_TXT\n 142:\t\thelp\n 143:\t\t  This option enables support for booting the kernel with the\n 144:\t\t  Trusted Boot (tboot) module. This will utilize\n 145:\t\t  Intel(R) Trusted Execution Technology to perform a measured launch\n 146:\t\t  of the kernel. If the system does not support Intel(R) TXT, this\n 147:\t\t  will have no effect.\n 148:\t\n 149:\t\t  Intel TXT will provide higher assurance of system configuration and\n 150:\t\t  initial state as well as data reset protection.  This is used to\n 151:\t\t  create a robust initial kernel measurement and verification, which\n 152:\t\t  helps to ensure that kernel security mechanisms are functioning\n 153:\t\t  correctly. This level of protection requires a root of trust outside\n 154:\t\t  of the kernel itself.\n"
}

13/2 2026/10/15 15:56 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 101775
							output: 44
							thoughts: 1286
						

Thoughts:
**Analyzing the Landlock Metadata Access Changes**

Okay, let's break down these changes. It looks like this commit is focused on expanding the Landlock security module, specifically concerning metadata access. My first thought is to dig into the details: what problem is being solved here? Is this a refactoring, or a new feature?

I see a clear pattern emerging. The changes are spread across several core filesystem layers and security modules, which is expected for such an intrusive feature. Specifically, I see changes to the following:

*   **Landlock itself (`security/landlock/fs.c`):** This is the heart of it, of course. New access types, `LANDLOCK_ACCESS_FS_READ_METADATA` and `LANDLOCK_ACCESS_FS_WRITE_METADATA`, have been added, indicating a precise control for reading and writing metadata. The ABI version bump is a key indicator; this will almost certainly require a kernel module rebuild if this version doesn't match. The numerous hook additions are critical, as these are how Landlock intercepts and enforces access control.
*   **Core Security Hooks (`security/security.c`):**  The core security infrastructure is being updated to respect the new Landlock restrictions.  These hooks are the central point of integration for most security modules.
*   **VFS Layer (`fs/attr.c`, `fs/file_attr.c`, `fs/xattr.c`, `fs/posix_acl.c`, `fs/open.c`):**  I see modifications to fundamental VFS functions for attribute setting and getting, extended attributes, ACLs, and even truncating. This is expected, as Landlock needs to intercept the calls *before* they're actually processed by the filesystem. The ksmbd changes are a good thing.
*   **Other Security Modules:**  I also see updates to various other security modules like SELinux, Smack, AppArmor, TOMOYO, Integrity, and capabilities. This is good to see as it confirms that the change is propagating to other LSMs.

My quick analysis shows that Landlock is now able to control metadata access with more granularity. This is important for creating secure sandboxes. Next, I need to check the exact git commit message or the commit messages that are connected to this commit to get more details on the rationale. If there isn't one, I need to see if it is a part of any larger series of commits to get context. This could be about a specific use case, like preventing an application from modifying file permissions, timestamps, or ACLs to tamper with audit trails, log data, or other security relevant information. Finally, I'll need to check the commit message (if it exists) to see if there is any discussion on the performance implications of the added checks.



14/2 2026/10/15 15:56 tool grepper
0m Args:
{
  "Expression": "LANDLOCK_ACCESS_FS_READ_METADATA",
  "PathPrefixes": [
    "include/uapi/linux/landlock.h"
  ]
}

Results:
{
  "Output": "include/uapi/linux/landlock.h=339=struct landlock_capability_attr {\n--\ninclude/uapi/linux/landlock.h-431- *   :ref:`Documentation/security/landlock.rst \u003cscoped-flags-interaction\u003e`.\ninclude/uapi/linux/landlock.h:432: * - %LANDLOCK_ACCESS_FS_READ_METADATA: Read file or directory metadata (e.g.\ninclude/uapi/linux/landlock.h-433- *   inode attributes, extended attributes, and POSIX ACLs) through\n--\ninclude/uapi/linux/landlock.h-535-#define LANDLOCK_ACCESS_FS_RESOLVE_UNIX\t\t\t(1ULL \u003c\u003c 16)\ninclude/uapi/linux/landlock.h:536:#define LANDLOCK_ACCESS_FS_READ_METADATA\t\t(1ULL \u003c\u003c 17)\ninclude/uapi/linux/landlock.h-537-#define LANDLOCK_ACCESS_FS_WRITE_METADATA\t\t(1ULL \u003c\u003c 18)\n"
}

15/2 2026/10/15 15:56 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 103969
							output: 29
							thoughts: 2694
						

Thoughts:
**Fuzzing Landlock Metadata Access Control**

Okay, so this patch series introduces new metadata access rights, specifically `LANDLOCK_ACCESS_FS_READ_METADATA` and `LANDLOCK_ACCESS_FS_WRITE_METADATA`, to Landlock. The core of this change involves transforming LSM hooks from `inode_*` to `path_*` to allow path-based metadata access control. This necessitates changes in the VFS functions that handle attributes, extended attributes (xattrs), and ACLs. This is significant because it touches on core file operation routines and the security framework. Given that this modifies core VFS, security, and Landlock itself, fuzzing is definitely warranted.

Now, let's nail down the specific focus points for the fuzzer. We need to avoid ubiquitous functions and target the new feature logic. The Landlock hook functions are the key here. The changes involve modifying quite a number of functions to take `const struct path *`, so we also have VFS entry points to be considered.

Specifically, the Landlock functions of interest are:

-   `hook_path_setattr`
-   `hook_path_file_setattr`
-   `hook_path_getattr`
-   `hook_path_file_getattr`
-   `hook_path_setxattr`
-   `hook_path_getxattr`
-   `hook_path_listxattr`
-   `hook_path_removexattr`
-   `hook_path_set_acl`
-   `hook_path_get_acl`
-   `hook_path_remove_acl`

These functions are part of the Landlock security hooks. They are *not* inlined and are feature-specific entrypoints. These functions, in turn, call `current_check_access_path`, so it would also be interesting to fuzz `current_check_access_path` itself.

Furthermore, we're modifying security entrypoints, so:

-   `security_path_setattr`
-   `security_path_setxattr`
-   `security_path_getxattr`
-   `security_path_listxattr`
-   `security_path_removexattr`
-   `security_path_file_setattr`
-   `security_path_file_getattr`
-   `security_path_set_acl`
-   `security_path_get_acl`
-   `security_path_remove_acl`

These will be important entry points.

While some VFS functions like `vfs_getattr` get called on every stat, the Landlock hooks are only called when a Landlock ruleset is active, which should prevent dilution of effort. It's likely that `hook_path_setattr`, `hook_path_getattr`, etc. will be called, but not by all programs. However, when we do set up a ruleset with those rights, the tests that set up a Landlock ruleset with `LANDLOCK_ACCESS_FS_READ_METADATA` / `LANDLOCK_ACCESS_FS_WRITE_METADATA` will execute them.

This makes the following functions worth fuzzing:
-   `hook_path_setattr`
-   `hook_path_file_setattr`
-   `hook_path_getattr`
-   `hook_path_file_getattr`
-   `hook_path_setxattr`
-   `hook_path_getxattr`
-   `hook_path_listxattr`
-   `hook_path_removexattr`
-   `hook_path_set_acl`
-   `hook_path_get_acl`
-   `hook_path_remove_acl`
-   `current_check_access_path`
-   `security_path_setattr`
-   `security_path_setxattr`
-   `security_path_getxattr`
-   `security_path_listxattr`
-   `security_path_removexattr`
-   `security_path_file_setattr`
-   `security_path_file_getattr`
-   `security_path_set_acl`
-   `security_path_get_acl`
-   `security_path_remove_acl`



16/2 2026/10/15 15:57 tool grepper
0m Args:
{
  "Expression": "obj-",
  "PathPrefixes": [
    "security/landlock/Makefile"
  ]
}

Results:
{
  "Output": "security/landlock/Makefile:1:obj-$(CONFIG_SECURITY_LANDLOCK) := landlock.o\nsecurity/landlock/Makefile-2-\n"
}

17/2 2026/10/15 15:57 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 107702
							output: 327
							thoughts: 2696
						

Thoughts:
**Analysis of Landlock Configuration and Fuzzing Strategy**

Okay, so I need to figure out the right configurations and the most effective focus symbols for fuzzing this Landlock update. First, I need to make sure `SECURITY_LANDLOCK`, `SECURITY_PATH`, and `SECURITY` are enabled, because `SECURITY_LANDLOCK` relies on `SECURITY` and `SECURITY_PATH` is selected by it. I should also check if `FS_POSIX_ACL` is relevant because of the interactions with ACL-related VFS functions. Also I have to make sure Landlock is listed in `LSM` or is enabled, but typically this is the case. So, `SECURITY_LANDLOCK`, `SECURITY_PATH`, `SECURITY` and `FS_POSIX_ACL` look like the key configs.

Now for the interesting part: choosing the right focus symbols. I want specific functions that target the changes. Let's list the landlock hooks: `hook_path_setattr`, `hook_path_getattr`, `hook_path_file_setattr`, `hook_path_file_getattr`, etc. Then the relevant security functions: `security_path_setattr`, `security_path_file_setattr`, etc. The rule is to avoid ubiquitous functions that are called frequently by a myriad of programs. Functions like `security_path_getattr` are used on every stat call, and `hook_path_getattr` is called on *every* stat call if Landlock is enabled, so they're too broad. However, `hook_path_setattr` contains the core new logic for `LANDLOCK_ACCESS_FS_WRITE_METADATA`, so that's a good target. The xattr/ACL hooks are better targets because they're less common. The fileattr functions are also more specific.

I've got to find specific functions that have the new Landlock hooks added. I need to make sure I identify those that are *new*, not generic. Okay, I've got a good list:

- `hook_path_setattr`
- `hook_path_file_setattr`
- `hook_path_file_getattr`
- `hook_path_setxattr`
- `hook_path_getxattr`
- `hook_path_listxattr`
- `hook_path_removexattr`
- `hook_path_set_acl`
- `hook_path_get_acl`
- `hook_path_remove_acl`
- `vfs_fileattr_set`
- `vfs_fileattr_get`
- `__notify_change`

I've validated the configs and the focus symbols. The key configurations are `SECURITY_LANDLOCK`, `SECURITY_PATH`, `SECURITY`, and `FS_POSIX_ACL`. This set of focus symbols represents the new Landlock metadata hooks and related refactored VFS entry points. This looks right. Ready to move on to fuzzing.



18/2 2026/10/15 15:57 tool set-results
0m Args:
{
  "EnableConfigs": [
    "SECURITY_LANDLOCK",
    "SECURITY_PATH",
    "SECURITY",
    "FS_POSIX_ACL"
  ],
  "FocusSymbols": [
    "hook_path_setattr",
    "hook_path_file_setattr",
    "hook_path_file_getattr",
    "hook_path_setxattr",
    "hook_path_getxattr",
    "hook_path_listxattr",
    "hook_path_removexattr",
    "hook_path_set_acl",
    "hook_path_get_acl",
    "hook_path_remove_acl",
    "vfs_fileattr_set",
    "vfs_fileattr_get",
    "__notify_change"
  ],
  "Reasoning": "The patch series introduces Landlock ABI v13 support for controlling file and directory metadata access via two new access rights (LANDLOCK_ACCESS_FS_READ_METADATA and LANDLOCK_ACCESS_FS_WRITE_METADATA). To support path-based metadata access control, the series refactors multiple core VFS interfaces (notify_change, vfs_setxattr, vfs_getxattr, vfs_fileattr_get/set, posix_acl operations) and transitions LSM hooks from inode-based to struct path-based hooks across core VFS, Landlock, and other LSMs. These changes affect reachable core VFS and security subsystem paths and warrant fuzzing.",
  "WorthFuzzing": true
}

Results:
{
  "EnableConfigs": [
    "SECURITY_LANDLOCK",
    "SECURITY_PATH",
    "SECURITY",
    "FS_POSIX_ACL"
  ],
  "FocusSymbols": [
    "hook_path_setattr",
    "hook_path_file_setattr",
    "hook_path_file_getattr",
    "hook_path_setxattr",
    "hook_path_getxattr",
    "hook_path_listxattr",
    "hook_path_removexattr",
    "hook_path_set_acl",
    "hook_path_get_acl",
    "hook_path_remove_acl",
    "vfs_fileattr_set",
    "vfs_fileattr_get",
    "__notify_change"
  ],
  "Reasoning": "The patch series introduces Landlock ABI v13 support for controlling file and directory metadata access via two new access rights (LANDLOCK_ACCESS_FS_READ_METADATA and LANDLOCK_ACCESS_FS_WRITE_METADATA). To support path-based metadata access control, the series refactors multiple core VFS interfaces (notify_change, vfs_setxattr, vfs_getxattr, vfs_fileattr_get/set, posix_acl operations) and transitions LSM hooks from inode-based to struct path-based hooks across core VFS, Landlock, and other LSMs. These changes affect reachable core VFS and security subsystem paths and warrant fuzzing.",
  "WorthFuzzing": true
}

19/1 2026/10/15 15:57 action If
1m Args:
{
  "WorthFuzzing": true
}

Results:
null

20/2 2026/10/15 15:57 agent kmsan-evaluator
1m Model:
core

Args:
null

Results:
{
  "KMSANReasoning": "The patch series primarily refactors VFS and LSM interfaces by converting metadata hooks (getattr, setattr, getxattr, setxattr, listxattr, removexattr, get_acl, set_acl, remove_acl, and fileattr get/set) from accepting raw dentries to accepting `const struct path *`, enabling Landlock to enforce access control on file/directory metadata (introducing LANDLOCK_ACCESS_FS_READ_METADATA and LANDLOCK_ACCESS_FS_WRITE_METADATA for Landlock ABI v13).\n\nReviewing memory initialization and data flow:\n1. No uninitialized memory or info-leak vectors: The patch does not introduce or modify any kernel structures copied to user space, nor does it alter data buffer sizing, bounds checks, or padding exposure.\n2. Stack variables: Every newly introduced `struct path` stack variable across drivers and filesystems (devtmpfs, cachefiles, overlayfs, nfsd, ksmbd) is fully initialized via designated initializers (e.g. `{ .mnt = ..., .dentry = ... }`) or helper initializers (`ovl_path_real`, `ecryptfs_lower_path`).\n3. Branching and logic: Control flow changes in Landlock and VFS depend on validated permissions, struct paths, and `iattr` flags; no branching depends on uninitialized data.\n\nAny potential bugs in this patch series would pertain to access control correctness, permission checks, or pointer validity, which are covered by functional tests and standard detectors (KASAN). There are no uninitialized memory risks that would require or benefit from a dedicated KMSAN fuzzing session.",
  "NeedsKMSAN": false
}

Instruction:
You are an expert Linux kernel security engineer specializing in kernel memory
error detectors (KASAN and KMSAN). Your job is to review the provided patch series and
determine if the code changes justify spawning a dedicated KMSAN (KernelMemorySanitizer)
fuzzing session in addition to standard KASAN fuzzing.

CRITICAL DISTINCTION BETWEEN KASAN AND KMSAN:
- Standard KASAN kernel builds (upstream-apparmor-kasan.config) already enable
  a comprehensive suite of debugging tools and sanitizers, including KASAN
  (out-of-bounds accesses, use-after-free, double free, invalid free), LOCKDEP
  (locking bugs and deadlocks), UB-sanitizers, and memory corruption checks.
- KMSAN (KernelMemorySanitizer) detects reads of UNINITIALIZED memory (stack, heap,
  or page allocations) and kernel-to-user memory info-leaks.

Rule: THERE IS NO SENSE IN RUNNING A KMSAN SESSION IF A BUG CAN BE CAUGHT BY KASAN,
LOCKDEP, OR OTHER STANDARD BUG DETECTORS.
A dedicated KMSAN fuzzing session incurs significant resource costs. You must ONLY
set NeedsKMSAN=true if the code changes introduce or expose UNINITIALIZED MEMORY risks
that are detected ONLY by KMSAN.

Look holistically at the patch series and surrounding code. Even if no direct
uninitialized field accesses or new buffer allocations are added in the diff itself,
a patch may alter control flow, bounds checking, or data length calculations in ways
that change how the rest of the code operates on existing buffers (e.g. allowing
uninitialized stack/heap memory to be read, copied to user space, or used in control
flow). Do not hesitate to use your code access tools to inspect the surrounding code,
called functions, and callers.

Set NeedsKMSAN=true ONLY IF the patch introduces or modifies:
1. Kernel structures sent to user space (via copy_to_user, put_user, netlink skb
   attributes, ioctl output arguments, socket options, or BPF buffers) where fields
   or structure padding might not be fully initialized/zeroed.
2. Conditional logic or branching that depends on potentially uninitialized variables
   or struct fields.
3. Allocation or initialization of complex data structures where uninitialized fields
   could be read later in reachable code paths.
4. Bounds checks, lengths, or logic in a way that allows surrounding code to access
   uninitialized bytes of existing buffers.

Set NeedsKMSAN=false IF:
- The code changes primarily risk out-of-bounds access, array overflows, NULL pointer
  dereferences, locking deadlocks, or use-after-free bugs (these are already caught
  by KASAN, LOCKDEP, or standard bug detectors).
- All stack/heap structures touched or introduced by the patch are fully zeroed
  or initialized (e.g. using = {0}, memset, kzalloc) before being read or copied.
- The patch does not introduce any risk of uninitialized memory usage or info-leaks.

Use your code access tools to inspect the surrounding code if necessary, then provide
detailed KMSANReasoning contrasting KASAN vs KMSAN applicability for this patch.
Prefer calling several tools at the same time to save round-trips.


Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.

Prompt:
Target architecture: amd64

For your convenience, here is the diff of the changes:
commit 014a9caffbc22fe4a10d9464410d1aade02103dc
Author: syz-cluster <triage@syzkaller.com>
Date:   Thu Oct 15 15:55:15 2026 +0000

    syz-cluster: applied patch under review

diff --git a/Documentation/bpf/fs_kfuncs.rst b/Documentation/bpf/fs_kfuncs.rst
index 8762c3233a3d1..9586dbbbf177c 100644
--- a/Documentation/bpf/fs_kfuncs.rst
+++ b/Documentation/bpf/fs_kfuncs.rst
@@ -18,4 +18,4 @@ To avoid recursions, these kfuncs follow the following rules:
 1. These kfuncs are only permitted from BPF LSM function.
 2. These kfuncs should not call into other LSM hooks, i.e. security_*(). For
    example, ``bpf_get_file_xattr()`` does not use ``vfs_getxattr()``, because
-   the latter calls LSM hook ``security_inode_getxattr``.
+   the latter calls LSM hook ``security_path_getxattr``.
diff --git a/Documentation/userspace-api/landlock.rst b/Documentation/userspace-api/landlock.rst
index 3d45b956b6407..62fe39a8b61e6 100644
--- a/Documentation/userspace-api/landlock.rst
+++ b/Documentation/userspace-api/landlock.rst
@@ -87,7 +87,9 @@ to be explicit about the denied-by-default access rights.
             LANDLOCK_ACCESS_FS_REFER |
             LANDLOCK_ACCESS_FS_TRUNCATE |
             LANDLOCK_ACCESS_FS_IOCTL_DEV |
-            LANDLOCK_ACCESS_FS_RESOLVE_UNIX,
+            LANDLOCK_ACCESS_FS_RESOLVE_UNIX |
+            LANDLOCK_ACCESS_FS_READ_METADATA |
+            LANDLOCK_ACCESS_FS_WRITE_METADATA,
         .handled_access_net =
             LANDLOCK_ACCESS_NET_BIND_TCP |
             LANDLOCK_ACCESS_NET_CONNECT_TCP |
@@ -159,6 +161,10 @@ version, and only use the available subset of access rights:
         ruleset_attr.handled_permissions &=
             ~(LANDLOCK_PERMISSION_NAMESPACE_USE |
               LANDLOCK_PERMISSION_CAPABILITY_USE);
+        /* Removes metadata rights for ABI < 13 */
+        ruleset_attr.handled_access_fs &=
+            ~(LANDLOCK_ACCESS_FS_READ_METADATA |
+              LANDLOCK_ACCESS_FS_WRITE_METADATA);
     }
 
 This enables the creation of an inclusive ruleset that will contain our rules.
@@ -669,6 +675,45 @@ for writing, sidestepping the ``LANDLOCK_ACCESS_FS_TRUNCATE`` right.
 
 The truncate right is associated with the opened file (see below).
 
+File metadata
+-------------
+
+The ``LANDLOCK_ACCESS_FS_READ_METADATA`` right governs reading file and
+directory metadata: :manpage:`stat(2)` and friends,
+:manpage:`getxattr(2)`, :manpage:`listxattr(2)` and friends, and POSIX ACL
+reads.
+
+The ``LANDLOCK_ACCESS_FS_WRITE_METADATA`` right governs explicit changes to
+file and directory metadata: :manpage:`chmod(2)` and friends,
+:manpage:`chown(2)` and friends, :manpage:`utimensat(2)`,
+:manpage:`setxattr(2)`, :manpage:`removexattr(2)` and friends, and POSIX ACL
+changes.  Both rights apply to files and directories alike.
+
+Implicit metadata changes performed by the kernel are not restricted by
+``LANDLOCK_ACCESS_FS_WRITE_METADATA``: reading a file may update its access
+time, writing a file updates its modification and change times and may change
+the file size, and writing to or truncating a file with a set-user-ID or
+set-group-ID bit clears these bits.  File size changes through
+:manpage:`truncate(2)` and friends are governed by
+``LANDLOCK_ACCESS_FS_TRUNCATE`` instead.  Metadata change requests that do
+not change any attribute (e.g. :manpage:`chown(2)` with owner and group
+``-1``) are not restricted either.
+
+.. warning::
+
+   Many programs read metadata as part of reading file contents or listing
+   directories (e.g. calling :manpage:`stat(2)` before or after
+   :manpage:`open(2)`), and do not expect such calls to fail with
+   ``EACCES``.  Most of the time, ``LANDLOCK_ACCESS_FS_READ_METADATA``
+   should therefore be granted together with
+   ``LANDLOCK_ACCESS_FS_READ_FILE`` and ``LANDLOCK_ACCESS_FS_READ_DIR``.
+   Conversely, denying only ``LANDLOCK_ACCESS_FS_READ_FILE`` or
+   ``LANDLOCK_ACCESS_FS_READ_DIR`` does not hide metadata: it remains
+   readable through :manpage:`stat(2)` and friends unless
+   ``LANDLOCK_ACCESS_FS_READ_METADATA`` is denied as well.  Tailored
+   programs that do not read metadata at all can still deny this right to
+   further restrict their sandbox.
+
 Rights associated with file descriptors
 ---------------------------------------
 
diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
index 11c70888f38be..71da9235ed49e 100644
--- a/drivers/base/devtmpfs.c
+++ b/drivers/base/devtmpfs.c
@@ -284,13 +284,14 @@ static int handle_create(const char *nodename, umode_t mode, kuid_t uid,
 			dev->devt, NULL);
 	if (!err) {
 		struct iattr newattrs;
+		struct path attr_path = { .mnt = path.mnt, .dentry = dentry };
 
 		newattrs.ia_mode = mode;
 		newattrs.ia_uid = uid;
 		newattrs.ia_gid = gid;
 		newattrs.ia_valid = ATTR_MODE|ATTR_UID|ATTR_GID;
 		inode_lock(d_inode(dentry));
-		notify_change(&nop_mnt_idmap, dentry, &newattrs, NULL);
+		notify_change(&attr_path, &newattrs, NULL);
 		inode_unlock(d_inode(dentry));
 
 		/* mark as kernel-created inode */
@@ -380,6 +381,7 @@ static int handle_remove(const char *nodename, struct device *dev)
 	inode = d_inode(dentry);
 	if (dev_mynode(dev, inode)) {
 		struct iattr newattrs;
+		struct path attr_path = { .mnt = parent.mnt, .dentry = dentry };
 		/*
 		 * before unlinking this node, reset permissions
 		 * of possible references like hardlinks
@@ -390,7 +392,7 @@ static int handle_remove(const char *nodename, struct device *dev)
 		newattrs.ia_valid =
 			ATTR_UID|ATTR_GID|ATTR_MODE;
 		inode_lock(d_inode(dentry));
-		notify_change(&nop_mnt_idmap, dentry, &newattrs, NULL);
+		notify_change(&attr_path, &newattrs, NULL);
 		inode_unlock(d_inode(dentry));
 		err = vfs_unlink(&nop_mnt_idmap, d_inode(parent.dentry),
 				 dentry, NULL);
diff --git a/drivers/block/zloop.c b/drivers/block/zloop.c
index 8f485ef515577..b385192aacb11 100644
--- a/drivers/block/zloop.c
+++ b/drivers/block/zloop.c
@@ -715,7 +715,7 @@ static int zloop_record_safe_wps(struct zloop_device *zlo)
 
 		if (!zloop_zone_is_active(zone))
 			continue;
-		ret = vfs_setxattr(file_mnt_idmap(file), file_dentry(file),
+		ret = vfs_setxattr(&file->f_path,
 				"user.zloop.wp", &zone->wp, sizeof(zone->wp), 0);
 		if (ret) {
 			pr_err("%pg: failed to record write pointer (%d)\n",
@@ -1417,7 +1417,7 @@ static void zloop_forget_cache(struct zloop_device *zlo)
 		if (!zloop_zone_is_active(zone))
 			continue;
 
-		ret = vfs_getxattr(file_mnt_idmap(file), file_dentry(file),
+		ret = vfs_getxattr(&file->f_path,
 				"user.zloop.wp", &old_wp, sizeof(old_wp));
 		if (ret == -ENODATA) {
 			old_wp = 0;
diff --git a/fs/attr.c b/fs/attr.c
index 9706d370f34af..c8bf69e609713 100644
--- a/fs/attr.c
+++ b/fs/attr.c
@@ -397,35 +397,10 @@ int may_setattr(const struct mnt_idmap *idmap, struct inode *inode,
 }
 EXPORT_SYMBOL(may_setattr);
 
-/**
- * notify_change - modify attributes of a filesystem object
- * @idmap:	idmap of the mount the inode was found from
- * @dentry:	object affected
- * @attr:	new attributes
- * @delegated_inode: returns inode, if the inode is delegated
- *
- * The caller must hold the i_rwsem exclusively on the affected object.
- *
- * If notify_change discovers a delegation in need of breaking,
- * it will return -EWOULDBLOCK and return a reference to the inode in
- * delegated_inode.  The caller should then break the delegation and
- * retry.  Because breaking a delegation may take a long time, the
- * caller should drop the i_rwsem before doing so.
- *
- * Alternatively, a caller may pass NULL for delegated_inode.  This may
- * be appropriate for callers that expect the underlying filesystem not
- * to be NFS exported.  Also, passing NULL is fine for callers holding
- * the file open for write, as there can be no conflicting delegation in
- * that case.
- *
- * If the inode has been found through an idmapped mount the idmap of
- * the vfsmount must be passed through @idmap. This function will then
- * take care to map the inode according to @idmap before checking
- * permissions. On non-idmapped mounts or if permission checking is to be
- * performed on the raw inode simply pass @nop_mnt_idmap.
- */
-int notify_change(const struct mnt_idmap *idmap, struct dentry *dentry,
-		  struct iattr *attr, struct delegated_inode *delegated_inode)
+static int do_notify_change(const struct path *const path,
+			    const struct mnt_idmap *const idmap,
+			    struct dentry *const dentry, struct iattr *attr,
+			    struct delegated_inode *delegated_inode)
 {
 	struct inode *inode = dentry->d_inode;
 	umode_t mode = inode->i_mode;
@@ -537,9 +512,16 @@ int notify_change(const struct mnt_idmap *idmap, struct dentry *dentry,
 	    !vfsgid_valid(i_gid_into_vfsgid(idmap, inode)))
 		return -EOVERFLOW;
 
-	error = security_inode_setattr(idmap, dentry, attr);
-	if (error)
-		return error;
+	/*
+	 * The LSM checks are only performed for user-facing calls (i.e.
+	 * when @path is set): internal forwards, e.g. from a stacking
+	 * filesystem, were already checked on the user-facing path.
+	 */
+	if (path) {
+		error = security_path_setattr(path, attr);
+		if (error)
+			return error;
+	}
 
 	/*
 	 * If ATTR_DELEG is set, then these attributes are being set on
@@ -564,4 +546,65 @@ int notify_change(const struct mnt_idmap *idmap, struct dentry *dentry,
 
 	return error;
 }
+
+/**
+ * __notify_change - modify attributes of a filesystem object, without
+ *                   the LSM check
+ * @idmap:	idmap of the mount the inode was found from
+ * @dentry:	object affected
+ * @attr:	new attributes
+ * @delegated_inode: returns inode, if the inode is delegated
+ *
+ * Like notify_change(), but no security_path_setattr() hook is called:
+ * this is the variant to use for internal forwards, where the LSM
+ * checks were already performed on the user-facing path.
+ *
+ * The caller must hold the i_rwsem exclusively on the affected object.
+ *
+ * If the inode has been found through an idmapped mount, permission
+ * checking is performed based on @idmap.  This function will take care
+ * to map the inode according to the idmap before checking permissions.
+ *
+ * Return: 0 on success, or a negative error on failure.
+ */
+int __notify_change(const struct mnt_idmap *idmap, struct dentry *dentry,
+		    struct iattr *attr, struct delegated_inode *delegated_inode)
+{
+	return do_notify_change(NULL, idmap, dentry, attr, delegated_inode);
+}
+EXPORT_SYMBOL(__notify_change);
+
+/**
+ * notify_change - modify attributes of a filesystem object
+ * @path:	object affected
+ * @attr:	new attributes
+ * @delegated_inode: returns inode, if the inode is delegated
+ *
+ * The caller must hold the i_rwsem exclusively on the affected object.
+ *
+ * If notify_change discovers a delegation in need of breaking,
+ * it will return -EWOULDBLOCK and return a reference to the inode in
+ * delegated_inode.  The caller should then break the delegation and
+ * retry.  Because breaking a delegation may take a long time, the
+ * caller should drop the i_rwsem before doing so.
+ *
+ * Alternatively, a caller may pass NULL for delegated_inode.  This may
+ * be appropriate for callers that expect the underlying filesystem not
+ * to be NFS exported.  Also, passing NULL is fine for callers holding
+ * the file open for write, as there can be no conflicting delegation in
+ * that case.
+ *
+ * If the inode has been found through an idmapped mount, permission
+ * checking is performed based on the idmap of @path->mnt.  This function
+ * will take care to map the inode according to the idmap before
+ * checking permissions.
+ *
+ * Return: 0 on success, or a negative error on failure.
+ */
+int notify_change(const struct path *path, struct iattr *attr,
+		  struct delegated_inode *delegated_inode)
+{
+	return do_notify_change(path, mnt_idmap(path->mnt), path->dentry, attr,
+				delegated_inode);
+}
 EXPORT_SYMBOL(notify_change);
diff --git a/fs/bpf_fs_kfuncs.c b/fs/bpf_fs_kfuncs.c
index 35ccd98a4de64..ab25344e6205d 100644
--- a/fs/bpf_fs_kfuncs.c
+++ b/fs/bpf_fs_kfuncs.c
@@ -566,10 +566,10 @@ BTF_SET_START(d_inode_locked_hooks)
 BTF_ID(func, bpf_lsm_inode_post_removexattr)
 BTF_ID(func, bpf_lsm_inode_post_setattr)
 BTF_ID(func, bpf_lsm_inode_post_setxattr)
-BTF_ID(func, bpf_lsm_inode_removexattr)
+BTF_ID(func, bpf_lsm_path_removexattr)
 BTF_ID(func, bpf_lsm_inode_rmdir)
-BTF_ID(func, bpf_lsm_inode_setattr)
-BTF_ID(func, bpf_lsm_inode_setxattr)
+BTF_ID(func, bpf_lsm_path_setattr)
+BTF_ID(func, bpf_lsm_path_setxattr)
 BTF_ID(func, bpf_lsm_inode_unlink)
 BTF_SET_END(d_inode_locked_hooks)
 
diff --git a/fs/cachefiles/xattr.c b/fs/cachefiles/xattr.c
index 8ebb713482e3e..8bafb4dc1f745 100644
--- a/fs/cachefiles/xattr.c
+++ b/fs/cachefiles/xattr.c
@@ -40,7 +40,6 @@ struct cachefiles_vol_xattr {
 int cachefiles_preset_object_xattr(struct cachefiles_object *object, struct file *file)
 {
 	struct cachefiles_xattr *buf;
-	struct dentry *dentry = file->f_path.dentry;
 	unsigned int len = object->cookie->aux_len;
 	int ret;
 
@@ -55,7 +54,7 @@ int cachefiles_preset_object_xattr(struct cachefiles_object *object, struct file
 	if (ret == 0) {
 		ret = mnt_want_write_file(file);
 		if (ret == 0) {
-			ret = vfs_setxattr(&nop_mnt_idmap, dentry,
+			ret = vfs_setxattr(&file->f_path,
 					   cachefiles_xattr_cache, buf,
 					   sizeof(struct cachefiles_xattr) + len, 0);
 			mnt_drop_write_file(file);
@@ -91,7 +90,6 @@ int cachefiles_preset_object_xattr(struct cachefiles_object *object, struct file
 int cachefiles_set_object_xattr(struct cachefiles_object *object)
 {
 	struct cachefiles_xattr *buf;
-	struct dentry *dentry;
 	struct file *file = object->file;
 	unsigned int len = object->cookie->aux_len;
 	uoff_t object_size = object->cookie->object_size;
@@ -99,7 +97,6 @@ int cachefiles_set_object_xattr(struct cachefiles_object *object)
 
 	if (!file)
 		return -ESTALE;
-	dentry = file->f_path.dentry;
 
 	_enter("%x,#%d", object->debug_id, len);
 
@@ -121,7 +118,7 @@ int cachefiles_set_object_xattr(struct cachefiles_object *object)
 	if (ret == 0) {
 		ret = mnt_want_write_file(file);
 		if (ret == 0) {
-			ret = vfs_setxattr(&nop_mnt_idmap, dentry,
+			ret = vfs_setxattr(&file->f_path,
 					   cachefiles_xattr_cache, buf,
 					   sizeof(struct cachefiles_xattr) + len, 0);
 			mnt_drop_write_file(file);
@@ -160,7 +157,6 @@ int cachefiles_set_object_xattr(struct cachefiles_object *object)
 int cachefiles_check_auxdata(struct cachefiles_object *object, struct file *file)
 {
 	struct cachefiles_xattr *buf;
-	struct dentry *dentry = file->f_path.dentry;
 	struct inode *inode = file_inode(file);
 	unsigned int len = object->cookie->aux_len, tlen;
 	const void *p = fscache_get_aux(object->cookie);
@@ -177,7 +173,7 @@ int cachefiles_check_auxdata(struct cachefiles_object *object, struct file *file
 
 	xlen = cachefiles_inject_read_error();
 	if (xlen == 0)
-		xlen = vfs_getxattr(&nop_mnt_idmap, dentry, cachefiles_xattr_cache, buf, tlen);
+		xlen = vfs_getxattr(&file->f_path, cachefiles_xattr_cache, buf, tlen);
 	if (xlen != tlen) {
 		if (xlen < 0) {
 			ret = xlen;
@@ -226,6 +222,7 @@ int cachefiles_remove_object_xattr(struct cachefiles_cache *cache,
 				   struct cachefiles_object *object,
 				   struct dentry *dentry)
 {
+	struct path path = { .mnt = cache->mnt, .dentry = dentry };
 	int ret;
 
 	trace_cachefiles_coherency(object, d_inode(dentry)->i_ino, 0, NULL, 0,
@@ -235,8 +232,7 @@ int cachefiles_remove_object_xattr(struct cachefiles_cache *cache,
 	if (ret == 0) {
 		ret = mnt_want_write(cache->mnt);
 		if (ret == 0) {
-			ret = vfs_removexattr(&nop_mnt_idmap, dentry,
-					      cachefiles_xattr_cache);
+			ret = vfs_removexattr(&path, cachefiles_xattr_cache);
 			mnt_drop_write(cache->mnt);
 		}
 	}
@@ -282,7 +278,8 @@ bool cachefiles_set_volume_xattr(struct cachefiles_volume *volume)
 	struct cachefiles_vol_xattr *buf;
 	unsigned int len = volume->vcookie->coherency_len;
 	const void *p = volume->vcookie->coherency;
-	struct dentry *dentry = volume->dentry;
+	struct path path = { .mnt = volume->cache->mnt,
+			     .dentry = volume->dentry };
 	int ret;
 
 	_enter("%x,#%d", volume->vcookie->debug_id, len);
@@ -298,22 +295,21 @@ bool cachefiles_set_volume_xattr(struct cachefiles_volume *volume)
 	if (ret == 0) {
 		ret = mnt_want_write(volume->cache->mnt);
 		if (ret == 0) {
-			ret = vfs_setxattr(&nop_mnt_idmap, dentry,
-					   cachefiles_xattr_cache,
+			ret = vfs_setxattr(&path, cachefiles_xattr_cache,
 					   buf, len, 0);
 			mnt_drop_write(volume->cache->mnt);
 		}
 	}
 	if (ret < 0) {
-		trace_cachefiles_vfs_error(NULL, d_inode(dentry), ret,
+		trace_cachefiles_vfs_error(NULL, d_inode(path.dentry), ret,
 					   cachefiles_trace_setxattr_error);
-		trace_cachefiles_vol_coherency(volume, d_inode(dentry)->i_ino,
+		trace_cachefiles_vol_coherency(volume, d_inode(path.dentry)->i_ino,
 					       cachefiles_coherency_vol_set_fail);
 		if (ret != -ENOMEM)
 			cachefiles_io_error(
 				volume->cache, "Failed to set xattr with error %d", ret);
 	} else {
-		trace_cachefiles_vol_coherency(volume, d_inode(dentry)->i_ino,
+		trace_cachefiles_vol_coherency(volume, d_inode(path.dentry)->i_ino,
 					       cachefiles_coherency_vol_set_ok);
 	}
 
@@ -328,9 +324,10 @@ bool cachefiles_set_volume_xattr(struct cachefiles_volume *volume)
 int cachefiles_check_volume_xattr(struct cachefiles_volume *volume)
 {
 	struct cachefiles_vol_xattr *buf;
-	struct dentry *dentry = volume->dentry;
 	unsigned int len = volume->vcookie->coherency_len;
 	const void *p = volume->vcookie->coherency;
+	struct path path = { .mnt = volume->cache->mnt,
+			     .dentry = volume->dentry };
 	enum cachefiles_coherency_trace why;
 	ssize_t xlen;
 	int ret = -ESTALE;
@@ -344,11 +341,11 @@ int cachefiles_check_volume_xattr(struct cachefiles_volume *volume)
 
 	xlen = cachefiles_inject_read_error();
 	if (xlen == 0)
-		xlen = vfs_getxattr(&nop_mnt_idmap, dentry, cachefiles_xattr_cache, buf, len);
+		xlen = vfs_getxattr(&path, cachefiles_xattr_cache, buf, len);
 	if (xlen != len) {
 		if (xlen < 0) {
 			ret = xlen;
-			trace_cachefiles_vfs_error(NULL, d_inode(dentry), xlen,
+			trace_cachefiles_vfs_error(NULL, d_inode(path.dentry), xlen,
 						   cachefiles_trace_getxattr_error);
 			if (xlen == -EIO)
 				cachefiles_io_error(
@@ -365,7 +362,7 @@ int cachefiles_check_volume_xattr(struct cachefiles_volume *volume)
 		ret = 0;
 	}
 
-	trace_cachefiles_vol_coherency(volume, d_inode(dentry)->i_ino, why);
+	trace_cachefiles_vol_coherency(volume, d_inode(path.dentry)->i_ino, why);
 	kfree(buf);
 	_leave(" = %d", ret);
 	return ret;
diff --git a/fs/coredump.c b/fs/coredump.c
index b25ef2ffbdeed..57787e8c699f5 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -1060,7 +1060,7 @@ static bool coredump_file(struct core_name *cn, struct coredump_params *cprm,
 	}
 	if (!(file->f_mode & FMODE_CAN_WRITE))
 		return false;
-	if (do_truncate(idmap, file->f_path.dentry, 0, 0, file))
+	if (do_truncate(&file->f_path, 0, 0, file))
 		return false;
 
 	cprm->file = no_free_ptr(file);
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index 48e520960d665..e894ce435b5bb 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -732,7 +732,8 @@ upper_size_to_lower_size(struct ecryptfs_crypt_stat *crypt_stat,
  */
 static int __ecryptfs_truncate(struct dentry *dentry, const struct iattr *ia)
 {
-	struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry);
+	struct path lower_path = ecryptfs_lower_path(dentry);
+	struct dentry *lower_dentry = lower_path.dentry;
 	struct inode *inode = d_inode(dentry);
 	struct ecryptfs_crypt_stat *crypt_stat;
 	loff_t i_size = i_size_read(inode);
@@ -821,7 +822,7 @@ static int __ecryptfs_truncate(struct dentry *dentry, const struct iattr *ia)
 set_size:
 	lower_ia.ia_valid |= ATTR_SIZE;
 	inode_lock(d_inode(lower_dentry));
-	rc = notify_change(&nop_mnt_idmap, lower_dentry, &lower_ia, NULL);
+	rc = notify_change(&lower_path, &lower_ia, NULL);
 	inode_unlock(d_inode(lower_dentry));
 out:
 	ecryptfs_put_lower_file(inode);
@@ -873,7 +874,6 @@ static int ecryptfs_setattr(const struct mnt_idmap *idmap,
 			    struct dentry *dentry, struct iattr *ia)
 {
 	struct inode *inode = d_inode(dentry);
-	struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry);
 	struct inode *lower_inode = ecryptfs_inode_to_lower(inode);
 	struct ecryptfs_crypt_stat *crypt_stat;
 	int rc;
@@ -925,14 +925,14 @@ static int ecryptfs_setattr(const struct mnt_idmap *idmap,
 	if (ia->ia_valid & ATTR_SIZE) {
 		rc = __ecryptfs_truncate(dentry, ia);
 	} else {
+		struct path lower_path = ecryptfs_lower_path(dentry);
 		struct iattr lower_ia;
 
 		ecryptfs_iattr_to_lower(&lower_ia, ia);
 
-		inode_lock(d_inode(lower_dentry));
-		rc = notify_change(&nop_mnt_idmap, lower_dentry, &lower_ia,
-				NULL);
-		inode_unlock(d_inode(lower_dentry));
+		inode_lock(d_inode(lower_path.dentry));
+		rc = notify_change(&lower_path, &lower_ia, NULL);
+		inode_unlock(d_inode(lower_path.dentry));
 	}
 out:
 	fsstack_copy_attr_all(inode, lower_inode);
@@ -991,17 +991,17 @@ ecryptfs_setxattr(struct dentry *dentry, struct inode *inode,
 		  size_t size, int flags)
 {
 	int rc;
-	struct dentry *lower_dentry;
+	struct path lower_path;
 	struct inode *lower_inode;
 
-	lower_dentry = ecryptfs_dentry_to_lower(dentry);
-	lower_inode = d_inode(lower_dentry);
+	lower_path = ecryptfs_lower_path(dentry);
+	lower_inode = d_inode(lower_path.dentry);
 	if (!(lower_inode->i_opflags & IOP_XATTR)) {
 		rc = -EOPNOTSUPP;
 		goto out;
 	}
 	inode_lock(lower_inode);
-	rc = __vfs_setxattr_locked(&nop_mnt_idmap, lower_dentry, name, value, size, flags, NULL);
+	rc = __vfs_setxattr_locked(&lower_path, name, value, size, flags, NULL);
 	inode_unlock(lower_inode);
 	if (!rc && inode)
 		fsstack_copy_attr_all(inode, lower_inode);
@@ -1075,7 +1075,7 @@ static int ecryptfs_removexattr(struct dentry *dentry, struct inode *inode,
 
 static int ecryptfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
 {
-	return vfs_fileattr_get(ecryptfs_dentry_to_lower(dentry), fa);
+	return __vfs_fileattr_get(ecryptfs_dentry_to_lower(dentry), fa);
 }
 
 static int ecryptfs_fileattr_set(const struct mnt_idmap *idmap,
@@ -1084,7 +1084,7 @@ static int ecryptfs_fileattr_set(const struct mnt_idmap *idmap,
 	struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry);
 	int rc;
 
-	rc = vfs_fileattr_set(&nop_mnt_idmap, lower_dentry, fa);
+	rc = __vfs_fileattr_set(&nop_mnt_idmap, lower_dentry, fa);
 	fsstack_copy_attr_all(d_inode(dentry), d_inode(lower_dentry));
 
 	return rc;
@@ -1093,8 +1093,9 @@ static int ecryptfs_fileattr_set(const struct mnt_idmap *idmap,
 static struct posix_acl *ecryptfs_get_acl(const struct mnt_idmap *idmap,
 					  struct dentry *dentry, int type)
 {
-	return vfs_get_acl(idmap, ecryptfs_dentry_to_lower(dentry),
-			   posix_acl_xattr_name(type));
+	struct path lower_path = ecryptfs_lower_path(dentry);
+
+	return vfs_get_acl(&lower_path, posix_acl_xattr_name(type));
 }
 
 static int ecryptfs_set_acl(const struct mnt_idmap *idmap,
@@ -1102,11 +1103,10 @@ static int ecryptfs_set_acl(const struct mnt_idmap *idmap,
 			    int type)
 {
 	int rc;
-	struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry);
-	struct inode *lower_inode = d_inode(lower_dentry);
+	struct path lower_path = ecryptfs_lower_path(dentry);
+	struct inode *lower_inode = d_inode(lower_path.dentry);
 
-	rc = vfs_set_acl(&nop_mnt_idmap, lower_dentry,
-			 posix_acl_xattr_name(type), acl);
+	rc = vfs_set_acl(&lower_path, posix_acl_xattr_name(type), acl);
 	if (!rc)
 		fsstack_copy_attr_all(d_inode(dentry), lower_inode);
 	return rc;
diff --git a/fs/exfat/file.c b/fs/exfat/file.c
index 1386149916bbe..51ed20e27429b 100644
--- a/fs/exfat/file.c
+++ b/fs/exfat/file.c
@@ -551,8 +551,7 @@ static int exfat_ioctl_set_attributes(struct file *file, u32 __user *user_attr)
 	 * out the RO attribute for checking by the security
 	 * module, just because it maps to a file mode.
 	 */
-	err = security_inode_setattr(file_mnt_idmap(file),
-				     file->f_path.dentry, &ia);
+	err = security_path_setattr(&file->f_path, &ia);
 	if (err)
 		goto out_unlock_inode;
 
diff --git a/fs/fat/file.c b/fs/fat/file.c
index d4f1b360b9743..5178561906dd1 100644
--- a/fs/fat/file.c
+++ b/fs/fat/file.c
@@ -92,8 +92,7 @@ static int fat_ioctl_set_attributes(struct file *file, u32 __user *user_attr)
 	 * out the RO attribute for checking by the security
 	 * module, just because it maps to a file mode.
 	 */
-	err = security_inode_setattr(file_mnt_idmap(file),
-				     file->f_path.dentry, &ia);
+	err = security_path_setattr(&file->f_path, &ia);
 	if (err)
 		goto out_unlock_inode;
 
diff --git a/fs/file_attr.c b/fs/file_attr.c
index 833e03810b24c..ea56843450f70 100644
--- a/fs/file_attr.c
+++ b/fs/file_attr.c
@@ -75,27 +75,46 @@ void fileattr_fill_flags(struct file_kattr *fa, u32 flags)
 EXPORT_SYMBOL(fileattr_fill_flags);
 
 /**
- * vfs_fileattr_get - retrieve miscellaneous file attributes
+ * __vfs_fileattr_get - retrieve miscellaneous file attributes
  * @dentry:	the object to retrieve from
  * @fa:		fileattr pointer
  *
- * Call i_op->fileattr_get() callback, if exists.
+ * Call i_op->fileattr_get() callback, if exists.  Unlike
+ * vfs_fileattr_get(), no security hook is called: this is the variant to
+ * use for internal forwards, where the LSM checks were already performed
+ * on the user-facing path (e.g. by a stacking filesystem).
  *
  * Return: 0 on success, or a negative error on failure.
  */
-int vfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
+int __vfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
 {
 	struct inode *inode = d_inode(dentry);
-	int error;
 
 	if (!inode->i_op->fileattr_get)
 		return -ENOIOCTLCMD;
 
-	error = security_inode_file_getattr(dentry, fa);
+	return inode->i_op->fileattr_get(dentry, fa);
+}
+EXPORT_SYMBOL(__vfs_fileattr_get);
+
+/**
+ * vfs_fileattr_get - retrieve miscellaneous file attributes
+ * @path:	the object to retrieve from
+ * @fa:		fileattr pointer
+ *
+ * Call i_op->fileattr_get() callback, if exists.
+ *
+ * Return: 0 on success, or a negative error on failure.
+ */
+int vfs_fileattr_get(const struct path *path, struct file_kattr *fa)
+{
+	int error;
+
+	error = security_path_file_getattr(path, fa);
 	if (error)
 		return error;
 
-	return inode->i_op->fileattr_get(dentry, fa);
+	return __vfs_fileattr_get(path->dentry, fa);
 }
 EXPORT_SYMBOL(vfs_fileattr_get);
 
@@ -254,24 +273,10 @@ static int fileattr_set_prepare(struct inode *inode,
 	return 0;
 }
 
-/**
- * vfs_fileattr_set - change miscellaneous file attributes
- * @idmap:	idmap of the mount
- * @dentry:	the object to change
- * @fa:		fileattr pointer
- *
- * After verifying permissions, call i_op->fileattr_set() callback, if
- * exists.
- *
- * Verifying attributes involves retrieving current attributes with
- * i_op->fileattr_get(), this also allows initializing attributes that have
- * not been set by the caller to current values.  Inode lock is held
- * thoughout to prevent racing with another instance.
- *
- * Return: 0 on success, or a negative error on failure.
- */
-int vfs_fileattr_set(const struct mnt_idmap *idmap, struct dentry *dentry,
-		     struct file_kattr *fa)
+static int do_vfs_fileattr_set(const struct path *const path,
+			       const struct mnt_idmap *const idmap,
+			       struct dentry *const dentry,
+			       struct file_kattr *const fa)
 {
 	struct inode *inode = d_inode(dentry);
 	struct file_kattr old_ma = {};
@@ -284,7 +289,7 @@ int vfs_fileattr_set(const struct mnt_idmap *idmap, struct dentry *dentry,
 		return -EPERM;
 
 	inode_lock(inode);
-	err = vfs_fileattr_get(dentry, &old_ma);
+	err = __vfs_fileattr_get(dentry, &old_ma);
 	if (!err) {
 		/* initialize missing bits from old_ma */
 		if (fa->flags_valid) {
@@ -300,9 +305,17 @@ int vfs_fileattr_set(const struct mnt_idmap *idmap, struct dentry *dentry,
 		err = fileattr_set_prepare(inode, &old_ma, fa);
 		if (err)
 			goto out;
-		err = security_inode_file_setattr(dentry, fa);
-		if (err)
-			goto out;
+		/*
+		 * The LSM checks are only performed for user-facing calls
+		 * (i.e. when @path is set): internal forwards, e.g. from a
+		 * stacking filesystem, were already checked on the
+		 * user-facing path.
+		 */
+		if (path) {
+			err = security_path_file_setattr(path, fa);
+			if (err)
+				goto out;
+		}
 		err = inode->i_op->fileattr_set(idmap, dentry, fa);
 		if (err)
 			goto out;
@@ -313,6 +326,48 @@ int vfs_fileattr_set(const struct mnt_idmap *idmap, struct dentry *dentry,
 	inode_unlock(inode);
 	return err;
 }
+
+/**
+ * __vfs_fileattr_set - change miscellaneous file attributes
+ * @idmap:	idmap of the mount
+ * @dentry:	the object to change
+ * @fa:		fileattr pointer
+ *
+ * After verifying permissions, call i_op->fileattr_set() callback, if
+ * exists.  Unlike vfs_fileattr_set(), no security hook is called: this is
+ * the variant to use for internal forwards, where the LSM checks were
+ * already performed on the user-facing path (e.g. by a stacking
+ * filesystem).
+ *
+ * Verifying attributes involves retrieving current attributes with
+ * i_op->fileattr_get(), this also allows initializing attributes that have
+ * not been set by the caller to current values.  Inode lock is held
+ * thoughout to prevent racing with another instance.
+ *
+ * Return: 0 on success, or a negative error on failure.
+ */
+int __vfs_fileattr_set(const struct mnt_idmap *idmap, struct dentry *dentry,
+		       struct file_kattr *fa)
+{
+	return do_vfs_fileattr_set(NULL, idmap, dentry, fa);
+}
+EXPORT_SYMBOL(__vfs_fileattr_set);
+
+/**
+ * vfs_fileattr_set - change miscellaneous file attributes
+ * @path:	the object to change
+ * @fa:		fileattr pointer
+ *
+ * After verifying permissions, call i_op->fileattr_set() callback, if
+ * exists.
+ *
+ * Return: 0 on success, or a negative error on failure.
+ */
+int vfs_fileattr_set(const struct path *path, struct file_kattr *fa)
+{
+	return do_vfs_fileattr_set(path, mnt_idmap(path->mnt), path->dentry,
+				   fa);
+}
 EXPORT_SYMBOL(vfs_fileattr_set);
 
 int ioctl_getflags(struct file *file, unsigned int __user *argp)
@@ -320,7 +375,7 @@ int ioctl_getflags(struct file *file, unsigned int __user *argp)
 	struct file_kattr fa = { .flags_valid = true }; /* hint only */
 	int err;
 
-	err = vfs_fileattr_get(file->f_path.dentry, &fa);
+	err = vfs_fileattr_get(&file->f_path, &fa);
 	if (!err)
 		err = put_user(fa.flags, argp);
 	return err;
@@ -328,8 +383,6 @@ int ioctl_getflags(struct file *file, unsigned int __user *argp)
 
 int ioctl_setflags(struct file *file, unsigned int __user *argp)
 {
-	const struct mnt_idmap *idmap = file_mnt_idmap(file);
-	struct dentry *dentry = file->f_path.dentry;
 	struct file_kattr fa = {};
 	unsigned int flags;
 	int err;
@@ -339,7 +392,7 @@ int ioctl_setflags(struct file *file, unsigned int __user *argp)
 		err = mnt_want_write_file(file);
 		if (!err) {
 			fileattr_fill_flags(&fa, flags);
-			err = vfs_fileattr_set(idmap, dentry, &fa);
+			err = vfs_fileattr_set(&file->f_path, &fa);
 			mnt_drop_write_file(file);
 		}
 	}
@@ -351,7 +404,7 @@ int ioctl_fsgetxattr(struct file *file, void __user *argp)
 	struct file_kattr fa = { .fsx_valid = true }; /* hint only */
 	int err;
 
-	err = vfs_fileattr_get(file->f_path.dentry, &fa);
+	err = vfs_fileattr_get(&file->f_path, &fa);
 	if (!err)
 		err = copy_fsxattr_to_user(&fa, argp);
 
@@ -360,8 +413,6 @@ int ioctl_fsgetxattr(struct file *file, void __user *argp)
 
 int ioctl_fssetxattr(struct file *file, void __user *argp)
 {
-	const struct mnt_idmap *idmap = file_mnt_idmap(file);
-	struct dentry *dentry = file->f_path.dentry;
 	struct file_kattr fa = {};
 	int err;
 
@@ -369,7 +420,7 @@ int ioctl_fssetxattr(struct file *file, void __user *argp)
 	if (!err) {
 		err = mnt_want_write_file(file);
 		if (!err) {
-			err = vfs_fileattr_set(idmap, dentry, &fa);
+			err = vfs_fileattr_set(&file->f_path, &fa);
 			mnt_drop_write_file(file);
 		}
 	}
@@ -416,7 +467,7 @@ SYSCALL_DEFINE5(file_getattr, int, dfd, const char __user *, filename,
 			return error;
 	}
 
-	error = vfs_fileattr_get(filepath.dentry, &fa);
+	error = vfs_fileattr_get(&filepath, &fa);
 	if (error == -ENOIOCTLCMD || error == -ENOTTY)
 		error = -EOPNOTSUPP;
 	if (error)
@@ -480,8 +531,7 @@ SYSCALL_DEFINE5(file_setattr, int, dfd, const char __user *, filename,
 
 	error = mnt_want_write(filepath.mnt);
 	if (!error) {
-		error = vfs_fileattr_set(mnt_idmap(filepath.mnt),
-					 filepath.dentry, &fa);
+		error = vfs_fileattr_set(&filepath, &fa);
 		if (error == -ENOIOCTLCMD || error == -ENOTTY)
 			error = -EOPNOTSUPP;
 		mnt_drop_write(filepath.mnt);
diff --git a/fs/inode.c b/fs/inode.c
index 702f2d5ef459c..ea557adbbd203 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -2356,8 +2356,7 @@ int dentry_needs_remove_privs(const struct mnt_idmap *idmap,
 	return mask;
 }
 
-static int __remove_privs(const struct mnt_idmap *idmap,
-			  struct dentry *dentry, int kill)
+static int __remove_privs(const struct path *path, int kill)
 {
 	struct iattr newattrs;
 
@@ -2366,7 +2365,7 @@ static int __remove_privs(const struct mnt_idmap *idmap,
 	 * Note we call this on write, so notify_change will not
 	 * encounter any conflicting delegations:
 	 */
-	return notify_change(idmap, dentry, &newattrs, NULL);
+	return notify_change(path, &newattrs, NULL);
 }
 
 static int file_remove_privs_flags(struct file *file, unsigned int flags)
@@ -2387,7 +2386,7 @@ static int file_remove_privs_flags(struct file *file, unsigned int flags)
 		if (flags & IOCB_NOWAIT)
 			return -EAGAIN;
 
-		error = __remove_privs(file_mnt_idmap(file), dentry, kill);
+		error = __remove_privs(&file->f_path, kill);
 	}
 
 	if (!error)
diff --git a/fs/internal.h b/fs/internal.h
index e833c7e6e14fb..050c35f75d4a7 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -304,20 +304,19 @@ int import_xattr_name(struct xattr_name *kname, const char __user *name);
 int may_write_xattr(const struct mnt_idmap *idmap, struct inode *inode);
 
 #ifdef CONFIG_FS_POSIX_ACL
-int do_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
-	       const char *acl_name, const void *kvalue, size_t size);
-ssize_t do_get_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
-		   const char *acl_name, void *kvalue, size_t size);
+int do_set_acl(const struct path *path, const char *acl_name,
+	       const void *kvalue, size_t size);
+ssize_t do_get_acl(const struct path *path, const char *acl_name,
+		   void *kvalue, size_t size);
 #else
-static inline int do_set_acl(const struct mnt_idmap *idmap,
-			     struct dentry *dentry, const char *acl_name,
+static inline int do_set_acl(const struct path *path, const char *acl_name,
 			     const void *kvalue, size_t size)
 {
 	return -EOPNOTSUPP;
 }
-static inline ssize_t do_get_acl(const struct mnt_idmap *idmap,
-				 struct dentry *dentry, const char *acl_name,
-				 void *kvalue, size_t size)
+static inline ssize_t do_get_acl(const struct path *path,
+				 const char *acl_name, void *kvalue,
+				 size_t size)
 {
 	return -EOPNOTSUPP;
 }
diff --git a/fs/namei.c b/fs/namei.c
index fd160bd7886fa..e43c552e1e96c 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -4335,7 +4335,7 @@ static int may_open(const struct mnt_idmap *idmap, const struct path *path,
 	return 0;
 }
 
-static int handle_truncate(const struct mnt_idmap *idmap, struct file *filp)
+static int handle_truncate(struct file *filp)
 {
 	const struct path *path = &filp->f_path;
 	struct inode *inode = path->dentry->d_inode;
@@ -4345,8 +4345,7 @@ static int handle_truncate(const struct mnt_idmap *idmap, struct file *filp)
 
 	error = security_file_truncate(filp);
 	if (!error) {
-		error = do_truncate(idmap, path->dentry, 0,
-				    ATTR_MTIME|ATTR_CTIME|ATTR_OPEN,
+		error = do_truncate(path, 0, ATTR_MTIME|ATTR_CTIME|ATTR_OPEN,
 				    filp);
 	}
 	put_write_access(inode);
@@ -4894,7 +4893,7 @@ static int do_open(struct nameidata *nd,
 	if (!error)
 		error = security_file_post_open(file, op->acc_mode);
 	if (!error && do_truncate)
-		error = handle_truncate(idmap, file);
+		error = handle_truncate(file);
 	if (unlikely(error > 0)) {
 		WARN_ON(1);
 		error = -EINVAL;
diff --git a/fs/nfsd/nfs4ctl.h b/fs/nfsd/nfs4ctl.h
index bcec4c4ef1d53..97ab3d4212aaa 100644
--- a/fs/nfsd/nfs4ctl.h
+++ b/fs/nfsd/nfs4ctl.h
@@ -38,7 +38,7 @@ int nfsd4_create_laundry_wq(void);
 void nfsd4_destroy_laundry_wq(void);
 bool nfsd_wait_for_delegreturn(struct svc_rqst *rqstp, struct inode *inode);
 
-extern int nfsd4_is_junction(struct dentry *dentry);
+extern int nfsd4_is_junction(const struct path *path);
 extern int register_cld_notifier(void);
 extern void unregister_cld_notifier(void);
 #ifdef CONFIG_NFSD_V4_2_INTER_SSC
@@ -68,7 +68,7 @@ static inline bool nfsd_wait_for_delegreturn(struct svc_rqst *rqstp,
 	return false;
 }
 
-static inline int nfsd4_is_junction(struct dentry *dentry)
+static inline int nfsd4_is_junction(const struct path *path)
 {
 	return 0;
 }
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 1de6c6d757c3e..400a429418794 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -10477,8 +10477,10 @@ bool nfsd4_vet_deleg_time(struct timespec64 *req, const struct timespec64 *orig,
 	return true;
 }
 
-static int cb_getattr_update_times(struct dentry *dentry, struct nfs4_delegation *dp)
+static int cb_getattr_update_times(const struct path *path,
+				   struct nfs4_delegation *dp)
 {
+	struct dentry *dentry = path->dentry;
 	struct inode *inode = d_inode(dentry);
 	struct nfs4_cb_fattr *ncf = &dp->dl_cb_fattr;
 	struct iattr attrs = { };
@@ -10508,7 +10510,7 @@ static int cb_getattr_update_times(struct dentry *dentry, struct nfs4_delegation
 
 	attrs.ia_valid |= ATTR_DELEG;
 	inode_lock(inode);
-	ret = notify_change(&nop_mnt_idmap, dentry, &attrs, NULL);
+	ret = notify_change(path, &attrs, NULL);
 	inode_unlock(inode);
 	return ret;
 }
@@ -10531,7 +10533,7 @@ static int cb_getattr_update_times(struct dentry *dentry, struct nfs4_delegation
  * caller must put the reference.
  */
 __be32
-nfsd4_deleg_getattr_conflict(struct svc_rqst *rqstp, struct dentry *dentry,
+nfsd4_deleg_getattr_conflict(struct svc_rqst *rqstp, const struct path *path,
 			     struct nfs4_delegation **pdp)
 {
 	struct nfsd_thread_local_info *ntli = rqstp->rq_private;
@@ -10539,7 +10541,7 @@ nfsd4_deleg_getattr_conflict(struct svc_rqst *rqstp, struct dentry *dentry,
 	struct nfs4_delegation *dp = NULL;
 	struct file_lease *fl;
 	struct nfs4_cb_fattr *ncf;
-	struct inode *inode = d_inode(dentry);
+	struct inode *inode = d_inode(path->dentry);
 	__be32 status;
 
 	ctx = locks_inode_context(inode);
@@ -10603,7 +10605,7 @@ nfsd4_deleg_getattr_conflict(struct svc_rqst *rqstp, struct dentry *dentry,
 		 * not update the file's metadata with the client's
 		 * modified size
 		 */
-		err = cb_getattr_update_times(dentry, dp);
+		err = cb_getattr_update_times(path, dp);
 		if (err) {
 			status = nfserrno(err);
 			goto out_status;
@@ -10789,7 +10791,7 @@ void nfsd_update_cmtime_attr(struct file *f, unsigned int flags)
 	};
 
 	inode_lock(inode);
-	ret = notify_change(&nop_mnt_idmap, f->f_path.dentry, &attr, NULL);
+	ret = notify_change(&f->f_path, &attr, NULL);
 	inode_unlock(inode);
 	if (ret)
 		pr_notice_ratelimited("nfsd: Unable to update timestamps on "
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 84161dbecd1cb..2a86b69b2ae9b 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -4083,7 +4083,7 @@ nfsd4_encode_fattr4(struct svc_rqst *rqstp, struct xdr_stream *xdr,
 	    (attrmask[1] & (FATTR4_WORD1_TIME_ACCESS |
 			    FATTR4_WORD1_TIME_MODIFY |
 			    FATTR4_WORD1_TIME_METADATA))) {
-		status = nfsd4_deleg_getattr_conflict(rqstp, dentry, &dp);
+		status = nfsd4_deleg_getattr_conflict(rqstp, &path, &dp);
 		if (status)
 			goto out;
 	}
diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h
index cd9294f024bb9..183123f0b91f2 100644
--- a/fs/nfsd/state.h
+++ b/fs/nfsd/state.h
@@ -1018,7 +1018,7 @@ static inline bool try_to_expire_client(struct nfs4_client *clp)
 }
 
 extern __be32 nfsd4_deleg_getattr_conflict(struct svc_rqst *rqstp,
-		struct dentry *dentry, struct nfs4_delegation **pdp);
+		const struct path *path, struct nfs4_delegation **pdp);
 
 struct nfsd4_get_dir_delegation;
 struct nfs4_delegation *nfsd_get_dir_deleg(struct nfsd4_compound_state *cstate,
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 56c49b5bc5bb7..eb7dee641612c 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -233,11 +233,13 @@ static int nfsd_lookup_parent(struct svc_rqst *rqstp, struct dentry *dparent, st
  */
 int nfsd_mountpoint(struct dentry *dentry, struct svc_export *exp)
 {
+	struct path path = { .mnt = exp->ex_path.mnt, .dentry = dentry };
+
 	if (!d_inode(dentry))
 		return 0;
 	if (exp->ex_flags & NFSEXP_V4ROOT)
 		return 1;
-	if (nfsd4_is_junction(dentry))
+	if (nfsd4_is_junction(&path))
 		return 1;
 	if (d_managed(dentry))
 		/*
@@ -455,7 +457,7 @@ nfsd_get_write_access(struct svc_fh *fhp)
 	return nfserrno(get_write_access(d_inode(fhp->fh_dentry)));
 }
 
-static int __nfsd_setattr(struct dentry *dentry, struct iattr *iap)
+static int __nfsd_setattr(const struct path *path, struct iattr *iap)
 {
 	int host_err;
 
@@ -475,7 +477,7 @@ static int __nfsd_setattr(struct dentry *dentry, struct iattr *iap)
 		if (iap->ia_size < 0)
 			return -EFBIG;
 
-		host_err = notify_change(&nop_mnt_idmap, dentry, &size_attr, NULL);
+		host_err = notify_change(path, &size_attr, NULL);
 		if (host_err)
 			return host_err;
 		iap->ia_valid &= ~ATTR_SIZE;
@@ -501,7 +503,7 @@ static int __nfsd_setattr(struct dentry *dentry, struct iattr *iap)
 	if (!(iap->ia_valid & ATTR_DELEG))
 		iap->ia_valid |= ATTR_CTIME;
 
-	return notify_change(&nop_mnt_idmap, dentry, iap, NULL);
+	return notify_change(path, iap, NULL);
 }
 
 /**
@@ -524,6 +526,7 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp,
 {
 	struct dentry	*dentry;
 	struct inode	*inode;
+	struct path	path;
 	struct iattr	*iap = attr->na_iattr;
 	int		accmode = NFSD_MAY_SATTR;
 	umode_t		ftype = 0;
@@ -569,6 +572,11 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp,
 	dentry = fhp->fh_dentry;
 	inode = d_inode(dentry);
 
+	path = (struct path){
+		.mnt	= fhp->fh_export->ex_path.mnt,
+		.dentry	= dentry,
+	};
+
 	nfsd_sanitize_attrs(inode, iap);
 
 	/*
@@ -612,14 +620,14 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp,
 		 * copy for every loop iteration.
 		 */
 		attrs = *iap;
-		host_err = __nfsd_setattr(dentry, &attrs);
+		host_err = __nfsd_setattr(&path, &attrs);
 		if (host_err != -EAGAIN || !retries--)
 			break;
 		if (!nfsd_wait_for_delegreturn(rqstp, inode))
 			break;
 	}
 	if (attr->na_seclabel && attr->na_seclabel->len)
-		attr->na_labelerr = security_inode_setsecctx(dentry,
+		attr->na_labelerr = security_path_setsecctx(&path,
 			attr->na_seclabel->data, attr->na_seclabel->len);
 	if (IS_ENABLED(CONFIG_FS_POSIX_ACL) && attr->na_dpacl) {
 		if (!S_ISDIR(inode->i_mode))
@@ -678,14 +686,14 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp,
 /**
  * nfsd4_is_junction - Test if an object could be an NFS junction
  *
- * @dentry: object to test
+ * @path: object to test
  *
- * Returns 1 if "dentry" appears to contain NFS junction information.
+ * Returns 1 if "path" appears to contain NFS junction information.
  * Otherwise 0 is returned.
  */
-int nfsd4_is_junction(struct dentry *dentry)
+int nfsd4_is_junction(const struct path *path)
 {
-	struct inode *inode = d_inode(dentry);
+	struct inode *inode = d_inode(path->dentry);
 
 	if (inode == NULL)
 		return 0;
@@ -693,8 +701,7 @@ int nfsd4_is_junction(struct dentry *dentry)
 		return 0;
 	if (!(inode->i_mode & S_ISVTX))
 		return 0;
-	if (vfs_getxattr(&nop_mnt_idmap, dentry, NFSD_JUNCTION_XATTR_NAME,
-			 NULL, 0) <= 0)
+	if (vfs_getxattr(path, NFSD_JUNCTION_XATTR_NAME, NULL, 0) <= 0)
 		return 0;
 	return 1;
 }
@@ -2646,19 +2653,20 @@ nfsd_getxattr(struct svc_rqst *rqstp, struct svc_fh *fhp, char *name,
 	__be32 err;
 	char *buf;
 	struct inode *inode;
-	struct dentry *dentry;
+	struct path path;
 
 	err = fh_verify(rqstp, fhp, 0, NFSD_MAY_READ);
 	if (err)
 		return err;
 
 	err = nfs_ok;
-	dentry = fhp->fh_dentry;
-	inode = d_inode(dentry);
+	path.mnt = fhp->fh_export->ex_path.mnt;
+	path.dentry = fhp->fh_dentry;
+	inode = d_inode(path.dentry);
 
 	inode_lock_shared(inode);
 
-	len = vfs_getxattr(&nop_mnt_idmap, dentry, name, NULL, 0);
+	len = vfs_getxattr(&path, name, NULL, 0);
 
 	/*
 	 * Zero-length attribute, just return.
@@ -2685,7 +2693,7 @@ nfsd_getxattr(struct svc_rqst *rqstp, struct svc_fh *fhp, char *name,
 		goto out;
 	}
 
-	len = vfs_getxattr(&nop_mnt_idmap, dentry, name, buf, len);
+	len = vfs_getxattr(&path, name, buf, len);
 	if (len <= 0) {
 		kvfree(buf);
 		buf = NULL;
@@ -2719,19 +2727,20 @@ nfsd_listxattr(struct svc_rqst *rqstp, struct svc_fh *fhp, char **bufp,
 	__be32 err;
 	char *buf;
 	struct inode *inode;
-	struct dentry *dentry;
+	struct path path;
 
 	err = fh_verify(rqstp, fhp, 0, NFSD_MAY_READ);
 	if (err)
 		return err;
 
-	dentry = fhp->fh_dentry;
-	inode = d_inode(dentry);
+	path.mnt = fhp->fh_export->ex_path.mnt;
+	path.dentry = fhp->fh_dentry;
+	inode = d_inode(path.dentry);
 	*lenp = 0;
 
 	inode_lock_shared(inode);
 
-	len = vfs_listxattr(dentry, NULL, 0);
+	len = vfs_listxattr(&path, NULL, 0);
 	if (len <= 0) {
 		err = nfsd_xattr_errno(len);
 		goto out;
@@ -2748,7 +2757,7 @@ nfsd_listxattr(struct svc_rqst *rqstp, struct svc_fh *fhp, char **bufp,
 		goto out;
 	}
 
-	len = vfs_listxattr(dentry, buf, len);
+	len = vfs_listxattr(&path, buf, len);
 	if (len <= 0) {
 		kvfree(buf);
 		err = nfsd_xattr_errno(len);
@@ -2781,6 +2790,7 @@ nfsd_removexattr(struct svc_rqst *rqstp, struct svc_fh *fhp, char *name)
 {
 	__be32 err;
 	int ret;
+	struct path path;
 
 	err = fh_verify(rqstp, fhp, 0, NFSD_MAY_WRITE);
 	if (err)
@@ -2790,16 +2800,17 @@ nfsd_removexattr(struct svc_rqst *rqstp, struct svc_fh *fhp, char *name)
 	if (ret)
 		return nfserrno(ret);
 
-	inode_lock(fhp->fh_dentry->d_inode);
+	path.mnt = fhp->fh_export->ex_path.mnt;
+	path.dentry = fhp->fh_dentry;
+	inode_lock(d_inode(path.dentry));
 	err = fh_fill_pre_attrs(fhp);
 	if (err != nfs_ok)
 		goto out_unlock;
-	ret = __vfs_removexattr_locked(&nop_mnt_idmap, fhp->fh_dentry,
-				       name, NULL);
+	ret = __vfs_removexattr_locked(&path, name, NULL);
 	err = nfsd_xattr_errno(ret);
 	fh_fill_post_attrs(fhp);
 out_unlock:
-	inode_unlock(fhp->fh_dentry->d_inode);
+	inode_unlock(d_inode(path.dentry));
 	fh_drop_write(fhp);
 
 	return err;
@@ -2811,6 +2822,7 @@ nfsd_setxattr(struct svc_rqst *rqstp, struct svc_fh *fhp, char *name,
 {
 	__be32 err;
 	int ret;
+	struct path path;
 
 	err = fh_verify(rqstp, fhp, 0, NFSD_MAY_WRITE);
 	if (err)
@@ -2819,16 +2831,17 @@ nfsd_setxattr(struct svc_rqst *rqstp, struct svc_fh *fhp, char *name,
 	ret = fh_want_write(fhp);
 	if (ret)
 		return nfserrno(ret);
-	inode_lock(fhp->fh_dentry->d_inode);
+	path.mnt = fhp->fh_export->ex_path.mnt;
+	path.dentry = fhp->fh_dentry;
+	inode_lock(d_inode(path.dentry));
 	err = fh_fill_pre_attrs(fhp);
 	if (err != nfs_ok)
 		goto out_unlock;
-	ret = __vfs_setxattr_locked(&nop_mnt_idmap, fhp->fh_dentry,
-				    name, buf, len, flags, NULL);
+	ret = __vfs_setxattr_locked(&path, name, buf, len, flags, NULL);
 	fh_fill_post_attrs(fhp);
 	err = nfsd_xattr_errno(ret);
 out_unlock:
-	inode_unlock(fhp->fh_dentry->d_inode);
+	inode_unlock(d_inode(path.dentry));
 	fh_drop_write(fhp);
 	return err;
 }
@@ -2967,7 +2980,7 @@ nfsd_get_case_info(struct dentry *dentry, bool *case_insensitive,
 	}
 	saved = override_creds(probe);
 
-	err = vfs_fileattr_get(cd, &fa);
+	err = __vfs_fileattr_get(cd, &fa);
 
 	put_cred(revert_creds(saved));
 out:
diff --git a/fs/ntfs/named_stream.c b/fs/ntfs/named_stream.c
index 95a3c05f98211..f0b577a6f7c3e 100644
--- a/fs/ntfs/named_stream.c
+++ b/fs/ntfs/named_stream.c
@@ -897,7 +897,7 @@ static int ntfs_stream_setattr_common(const struct mnt_idmap *idmap,
 			goto out;
 		}
 		if (base_attr.ia_valid)
-			err = notify_change(idmap, base_dentry, &base_attr,
+			err = __notify_change(idmap, base_dentry, &base_attr,
 					NULL);
 		else
 			err = 0;
diff --git a/fs/open.c b/fs/open.c
index bf398105f03a0..97a5f770fa045 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -36,10 +36,12 @@
 
 #include "internal.h"
 
-int do_truncate(const struct mnt_idmap *idmap, struct dentry *dentry,
-		loff_t length, unsigned int time_attrs, struct file *filp)
+int do_truncate(const struct path *path, loff_t length,
+		unsigned int time_attrs, struct file *filp)
 {
 	int ret;
+	const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
+	struct dentry *dentry = path->dentry;
 	struct iattr newattrs;
 
 	/* Not pretty: "inode->i_size" shouldn't really be signed. But it is. */
@@ -65,7 +67,7 @@ int do_truncate(const struct mnt_idmap *idmap, struct dentry *dentry,
 		return ret;
 
 	/* Note any delegations or leases have already been broken: */
-	ret = notify_change(idmap, dentry, &newattrs, NULL);
+	ret = notify_change(path, &newattrs, NULL);
 	inode_unlock(dentry->d_inode);
 	return ret;
 }
@@ -115,7 +117,7 @@ int vfs_truncate(const struct path *path, loff_t length)
 
 	error = security_path_truncate(path);
 	if (!error)
-		error = do_truncate(idmap, path->dentry, length, 0, NULL);
+		error = do_truncate(path, length, 0, NULL);
 
 put_write_and_out:
 	put_write_access(inode);
@@ -191,7 +193,7 @@ int do_ftruncate(struct file *file, loff_t length, unsigned int flags)
 		return error;
 
 	scoped_guard(super_write, inode->i_sb)
-		return do_truncate(file_mnt_idmap(file), dentry, length,
+		return do_truncate(&file->f_path, length,
 				   ATTR_MTIME | ATTR_CTIME, file);
 }
 
@@ -683,8 +685,7 @@ int chmod_common(const struct path *path, umode_t mode)
 		goto out_unlock;
 	newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
 	newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
-	error = notify_change(mnt_idmap(path->mnt), path->dentry,
-			      &newattrs, &delegated_inode);
+	error = notify_change(path, &newattrs, &delegated_inode);
 out_unlock:
 	inode_unlock(inode);
 	if (is_delegated(&delegated_inode)) {
@@ -822,8 +823,7 @@ int chown_common(const struct path *path, uid_t user, gid_t group)
 		from_vfsuid(idmap, fs_userns, newattrs.ia_vfsuid),
 		from_vfsgid(idmap, fs_userns, newattrs.ia_vfsgid));
 	if (!error)
-		error = notify_change(idmap, path->dentry, &newattrs,
-				      &delegated_inode);
+		error = notify_change(path, &newattrs, &delegated_inode);
 	inode_unlock(inode);
 	if (is_delegated(&delegated_inode)) {
 		error = break_deleg_wait(&delegated_inode);
diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c
index e963701b4c877..6dc241f195a66 100644
--- a/fs/overlayfs/copy_up.c
+++ b/fs/overlayfs/copy_up.c
@@ -83,7 +83,7 @@ int ovl_copy_xattr(struct super_block *sb, const struct path *oldpath, struct de
 	if (!old->d_inode->i_op->listxattr || !new->d_inode->i_op->listxattr)
 		return 0;
 
-	list_size = vfs_listxattr(old, NULL, 0);
+	list_size = vfs_listxattr(oldpath, NULL, 0);
 	if (list_size <= 0) {
 		if (list_size == -EOPNOTSUPP)
 			return 0;
@@ -94,7 +94,7 @@ int ovl_copy_xattr(struct super_block *sb, const struct path *oldpath, struct de
 	if (!buf)
 		return -ENOMEM;
 
-	list_size = vfs_listxattr(old, buf, list_size);
+	list_size = vfs_listxattr(oldpath, buf, list_size);
 	if (list_size <= 0) {
 		error = list_size;
 		goto out;
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index 70183d516e5e9..9e89aeabeaa85 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -392,7 +392,7 @@ static void ovl_idmap_posix_acl(const struct inode *realinode,
  * > and following it on overlayfs.
  * >
  * > Applying the same logic to acl: we do need to call the
- * > security_inode_getxattr() on the underlying fs, even if just want to
+ * > security_path_getxattr() on the underlying fs, even if just want to
  * > check permissions on overlay. This is currently not done, which is an
  * > inconsistency.
  * >
@@ -414,7 +414,7 @@ struct posix_acl *ovl_get_acl_path(const struct path *path,
 	if (noperm)
 		real_acl = get_inode_acl(realinode, posix_acl_type(acl_name));
 	else
-		real_acl = vfs_get_acl(idmap, path->dentry, acl_name);
+		real_acl = vfs_get_acl(path, acl_name);
 	if (IS_ERR_OR_NULL(real_acl))
 		return real_acl;
 
@@ -502,7 +502,7 @@ static int ovl_set_or_remove_acl(struct dentry *dentry, struct inode *inode,
 
 		ovl_path_lower(dentry, &realpath);
 		with_ovl_creds(dentry->d_sb)
-			real_acl = vfs_get_acl(mnt_idmap(realpath.mnt), realdentry, acl_name);
+			real_acl = vfs_get_acl(&realpath, acl_name);
 		if (IS_ERR(real_acl)) {
 			err = PTR_ERR(real_acl);
 			goto out;
@@ -607,47 +607,10 @@ static int ovl_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
 		return realinode->i_op->fiemap(realinode, fieinfo, start, len);
 }
 
-/*
- * Work around the fact that security_file_ioctl() takes a file argument.
- * Introducing security_inode_fileattr_get/set() hooks would solve this issue
- * properly.
- */
-static int ovl_security_fileattr(const struct path *realpath, struct file_kattr *fa,
-				 bool set)
-{
-	struct file *file;
-	unsigned int cmd;
-	int err;
-	unsigned int flags;
-
-	flags = O_RDONLY;
-	if (force_o_largefile())
-		flags |= O_LARGEFILE;
-
-	file = dentry_open(realpath, flags, current_cred());
-	if (IS_ERR(file))
-		return PTR_ERR(file);
-
-	if (set)
-		cmd = fa->fsx_valid ? FS_IOC_FSSETXATTR : FS_IOC_SETFLAGS;
-	else
-		cmd = fa->fsx_valid ? FS_IOC_FSGETXATTR : FS_IOC_GETFLAGS;
-
-	err = security_file_ioctl(file, cmd, 0);
-	fput(file);
-
-	return err;
-}
-
 int ovl_real_fileattr_set(const struct path *realpath, struct file_kattr *fa)
 {
-	int err;
-
-	err = ovl_security_fileattr(realpath, fa, true);
-	if (err)
-		return err;
-
-	return vfs_fileattr_set(mnt_idmap(realpath->mnt), realpath->dentry, fa);
+	return __vfs_fileattr_set(mnt_idmap(realpath->mnt), realpath->dentry,
+				  fa);
 }
 
 int ovl_fileattr_set(const struct mnt_idmap *idmap,
@@ -717,11 +680,7 @@ int ovl_real_fileattr_get(const struct path *realpath, struct file_kattr *fa)
 {
 	int err;
 
-	err = ovl_security_fileattr(realpath, fa, false);
-	if (err)
-		return err;
-
-	err = vfs_fileattr_get(realpath->dentry, fa);
+	err = __vfs_fileattr_get(realpath->dentry, fa);
 	if (err == -ENOIOCTLCMD)
 		err = -ENOTTY;
 	return err;
diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
index 53fbbe15c31df..230070f6caa99 100644
--- a/fs/overlayfs/overlayfs.h
+++ b/fs/overlayfs/overlayfs.h
@@ -206,7 +206,12 @@ static inline int ovl_do_notify_change(struct ovl_fs *ofs,
 				       struct dentry *upperdentry,
 				       struct iattr *attr)
 {
-	return notify_change(ovl_upper_mnt_idmap(ofs), upperdentry, attr, NULL);
+	struct path path = {
+		.mnt = ovl_upper_mnt(ofs),
+		.dentry = upperdentry,
+	};
+
+	return notify_change(&path, attr, NULL);
 }
 
 static inline int ovl_do_rmdir(struct ovl_fs *ofs,
@@ -288,8 +293,7 @@ static inline ssize_t ovl_do_getxattr(const struct path *path, const char *name,
 
 	WARN_ON(path->dentry->d_sb != path->mnt->mnt_sb);
 
-	err = vfs_getxattr(mnt_idmap(path->mnt), path->dentry,
-			       name, value, size);
+	err = vfs_getxattr(path, name, value, size);
 	len = (value && err > 0) ? err : 0;
 
 	pr_debug("getxattr(%pd2, \"%s\", \"%*pE\", %zu, 0) = %i\n",
@@ -322,9 +326,13 @@ static inline int ovl_do_setxattr(struct ovl_fs *ofs, struct dentry *dentry,
 				  const char *name, const void *value,
 				  size_t size, int flags)
 {
+	struct path path = {
+		.mnt = ovl_upper_mnt(ofs),
+		.dentry = dentry,
+	};
+
 	/* Use vfs_setxattr(), not __vfs_setxattr(): it idmaps the security.capability rootid. */
-	int err = vfs_setxattr(ovl_upper_mnt_idmap(ofs), dentry, name,
-			       value, size, flags);
+	int err = vfs_setxattr(&path, name, value, size, flags);
 
 	pr_debug("setxattr(%pd2, \"%s\", \"%*pE\", %zu, %d) = %i\n",
 		 dentry, name, min((int)size, 48), value, size, flags, err);
@@ -341,7 +349,12 @@ static inline int ovl_setxattr(struct ovl_fs *ofs, struct dentry *dentry,
 static inline int ovl_do_removexattr(struct ovl_fs *ofs, struct dentry *dentry,
 				     const char *name)
 {
-	int err = vfs_removexattr(ovl_upper_mnt_idmap(ofs), dentry, name);
+	struct path path = {
+		.mnt = ovl_upper_mnt(ofs),
+		.dentry = dentry,
+	};
+
+	int err = vfs_removexattr(&path, name);
 	pr_debug("removexattr(%pd2, \"%s\") = %i\n", dentry, name, err);
 	return err;
 }
@@ -355,13 +368,23 @@ static inline int ovl_removexattr(struct ovl_fs *ofs, struct dentry *dentry,
 static inline int ovl_do_set_acl(struct ovl_fs *ofs, struct dentry *dentry,
 				 const char *acl_name, struct posix_acl *acl)
 {
-	return vfs_set_acl(ovl_upper_mnt_idmap(ofs), dentry, acl_name, acl);
+	struct path path = {
+		.mnt = ovl_upper_mnt(ofs),
+		.dentry = dentry,
+	};
+
+	return vfs_set_acl(&path, acl_name, acl);
 }
 
 static inline int ovl_do_remove_acl(struct ovl_fs *ofs, struct dentry *dentry,
 				    const char *acl_name)
 {
-	return vfs_remove_acl(ovl_upper_mnt_idmap(ofs), dentry, acl_name);
+	struct path path = {
+		.mnt = ovl_upper_mnt(ofs),
+		.dentry = dentry,
+	};
+
+	return vfs_remove_acl(&path, acl_name);
 }
 
 static inline int ovl_do_rename_rd(struct renamedata *rd)
diff --git a/fs/overlayfs/xattrs.c b/fs/overlayfs/xattrs.c
index acc54f6138ef5..6fbd0cbce10d5 100644
--- a/fs/overlayfs/xattrs.c
+++ b/fs/overlayfs/xattrs.c
@@ -45,7 +45,7 @@ static int ovl_xattr_set(struct dentry *dentry, struct inode *inode, const char
 	if (!value && !upperdentry) {
 		ovl_path_lower(dentry, &realpath);
 		with_ovl_creds(dentry->d_sb)
-			err = vfs_getxattr(mnt_idmap(realpath.mnt), realdentry, name, NULL, 0);
+			err = vfs_getxattr(&realpath, name, NULL, 0);
 		if (err < 0)
 			goto out;
 	}
@@ -86,7 +86,7 @@ static int ovl_xattr_get(struct dentry *dentry, struct inode *inode, const char
 	ovl_i_path_real(inode, &realpath);
 	/* Use vfs_getxattr(), not __vfs_getxattr(): it idmaps the security.capability rootid. */
 	with_ovl_creds(dentry->d_sb)
-		return vfs_getxattr(mnt_idmap(realpath.mnt), realpath.dentry, name, value, size);
+		return vfs_getxattr(&realpath, name, value, size);
 }
 
 static bool ovl_can_list(struct super_block *sb, const char *s)
@@ -105,15 +105,17 @@ static bool ovl_can_list(struct super_block *sb, const char *s)
 
 ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size)
 {
-	struct dentry *realdentry = ovl_dentry_real(dentry);
+	struct path realpath;
 	struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
 	ssize_t res;
 	size_t len;
 	char *s;
 	size_t prefix_len, name_len;
 
+	ovl_path_real(dentry, &realpath);
+
 	with_ovl_creds(dentry->d_sb)
-		res = vfs_listxattr(realdentry, list, size);
+		res = vfs_listxattr(&realpath, list, size);
 	if (res <= 0 || size == 0)
 		return res;
 
diff --git a/fs/posix_acl.c b/fs/posix_acl.c
index fe77934ea8f20..d4715c383e041 100644
--- a/fs/posix_acl.c
+++ b/fs/posix_acl.c
@@ -1081,8 +1081,7 @@ static int vfs_set_acl_idmapped_mnt(const struct mnt_idmap *idmap,
 
 /**
  * vfs_set_acl - set posix acls
- * @idmap: idmap of the mount
- * @dentry: the dentry based on which to set the posix acls
+ * @path: the path based on which to set the posix acls
  * @acl_name: the name of the posix acl
  * @kacl: the posix acls in the appropriate VFS format
  *
@@ -1091,9 +1090,11 @@ static int vfs_set_acl_idmapped_mnt(const struct mnt_idmap *idmap,
  *
  * Return: On success 0, on error negative errno.
  */
-int vfs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
-		const char *acl_name, struct posix_acl *kacl)
+int vfs_set_acl(const struct path *path, const char *acl_name,
+		struct posix_acl *kacl)
 {
+	const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
+	struct dentry *dentry = path->dentry;
 	int acl_type;
 	int error;
 	struct inode *inode = d_inode(dentry);
@@ -1127,7 +1128,7 @@ int vfs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
 	if (error)
 		goto out_inode_unlock;
 
-	error = security_inode_set_acl(idmap, dentry, acl_name, kacl);
+	error = security_path_set_acl(path, acl_name, kacl);
 	if (error)
 		goto out_inode_unlock;
 
@@ -1159,8 +1160,7 @@ EXPORT_SYMBOL_GPL(vfs_set_acl);
 
 /**
  * vfs_get_acl - get posix acls
- * @idmap: idmap of the mount
- * @dentry: the dentry based on which to retrieve the posix acls
+ * @path: the path based on which to retrieve the posix acls
  * @acl_name: the name of the posix acl
  *
  * This function retrieves @kacl from the filesystem. The caller must all
@@ -1168,9 +1168,10 @@ EXPORT_SYMBOL_GPL(vfs_set_acl);
  *
  * Return: On success POSIX ACLs in VFS format, on error negative errno.
  */
-struct posix_acl *vfs_get_acl(const struct mnt_idmap *idmap,
-			      struct dentry *dentry, const char *acl_name)
+struct posix_acl *vfs_get_acl(const struct path *path, const char *acl_name)
 {
+	const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
+	struct dentry *dentry = path->dentry;
 	struct inode *inode = d_inode(dentry);
 	struct posix_acl *acl;
 	int acl_type, error;
@@ -1183,7 +1184,7 @@ struct posix_acl *vfs_get_acl(const struct mnt_idmap *idmap,
 	 * The VFS has no restrictions on reading POSIX ACLs so calling
 	 * something like xattr_permission() isn't needed. Only LSMs get a say.
 	 */
-	error = security_inode_get_acl(idmap, dentry, acl_name);
+	error = security_path_get_acl(path, acl_name);
 	if (error)
 		return ERR_PTR(error);
 
@@ -1204,17 +1205,17 @@ EXPORT_SYMBOL_GPL(vfs_get_acl);
 
 /**
  * vfs_remove_acl - remove posix acls
- * @idmap: idmap of the mount
- * @dentry: the dentry based on which to retrieve the posix acls
+ * @path: the path based on which to retrieve the posix acls
  * @acl_name: the name of the posix acl
  *
  * This function removes posix acls.
  *
  * Return: On success 0, on error negative errno.
  */
-int vfs_remove_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
-		   const char *acl_name)
+int vfs_remove_acl(const struct path *path, const char *acl_name)
 {
+	const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
+	struct dentry *dentry = path->dentry;
 	int acl_type;
 	int error;
 	struct inode *inode = d_inode(dentry);
@@ -1235,7 +1236,7 @@ int vfs_remove_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
 	if (error)
 		goto out_inode_unlock;
 
-	error = security_inode_remove_acl(idmap, dentry, acl_name);
+	error = security_path_remove_acl(path, acl_name);
 	if (error)
 		goto out_inode_unlock;
 
@@ -1265,8 +1266,8 @@ int vfs_remove_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
 }
 EXPORT_SYMBOL_GPL(vfs_remove_acl);
 
-int do_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
-	       const char *acl_name, const void *kvalue, size_t size)
+int do_set_acl(const struct path *path, const char *acl_name,
+	       const void *kvalue, size_t size)
 {
 	int error;
 	struct posix_acl *acl = NULL;
@@ -1281,22 +1282,23 @@ int do_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
 			return PTR_ERR(acl);
 	}
 
-	error = vfs_set_acl(idmap, dentry, acl_name, acl);
+	error = vfs_set_acl(path, acl_name, acl);
 	posix_acl_release(acl);
 	return error;
 }
 
-ssize_t do_get_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
-		   const char *acl_name, void *kvalue, size_t size)
+ssize_t do_get_acl(const struct path *path, const char *acl_name,
+		   void *kvalue, size_t size)
 {
 	ssize_t error;
 	struct posix_acl *acl;
 
-	acl = vfs_get_acl(idmap, dentry, acl_name);
+	acl = vfs_get_acl(path, acl_name);
 	if (IS_ERR(acl))
 		return PTR_ERR(acl);
 
-	error = vfs_posix_acl_to_xattr(idmap, d_inode(dentry),
+	error = vfs_posix_acl_to_xattr(mnt_idmap(path->mnt),
+				       d_inode(path->dentry),
 				       acl, kvalue, size);
 	posix_acl_release(acl);
 	return error;
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index b57942263e130..6c8a6f8f27eef 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -3297,7 +3297,6 @@ static bool smb2_is_private_ea(const char *name, size_t name_len)
 static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len,
 		       const struct path *path, bool get_write)
 {
-	const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
 	char *attr_name = NULL, *value;
 	int rc = 0;
 	unsigned int next = 0;
@@ -3337,16 +3336,14 @@ static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len,
 		value = (char *)&eabuf->name + eabuf->EaNameLength + 1;
 
 		if (!eabuf->EaValueLength) {
-			rc = ksmbd_vfs_casexattr_len(idmap,
-						     path->dentry,
+			rc = ksmbd_vfs_casexattr_len(path,
 						     attr_name,
 						     XATTR_USER_PREFIX_LEN +
 						     eabuf->EaNameLength, NULL);
 
 			/* delete the EA only when it exits */
 			if (rc > 0) {
-				rc = ksmbd_vfs_remove_xattr(idmap,
-							    path,
+				rc = ksmbd_vfs_remove_xattr(path,
 							    attr_name,
 							    get_write);
 
@@ -3361,7 +3358,7 @@ static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len,
 			/* if the EA doesn't exist, just do nothing. */
 			rc = 0;
 		} else {
-			rc = ksmbd_vfs_setxattr(idmap, path, attr_name, value,
+			rc = ksmbd_vfs_setxattr(path, attr_name, value,
 						le16_to_cpu(eabuf->EaValueLength),
 						0, get_write);
 			if (rc < 0) {
@@ -3398,7 +3395,6 @@ static noinline int smb2_set_stream_name_xattr(const struct path *path,
 					       struct ksmbd_file *fp,
 					       char *stream_name, int s_type)
 {
-	const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
 	size_t xattr_stream_size;
 	char *xattr_stream_name;
 	int rc;
@@ -3414,8 +3410,7 @@ static noinline int smb2_set_stream_name_xattr(const struct path *path,
 	fp->stream.size = xattr_stream_size;
 
 	/* Keep the existing xattr's case for subsequent writes and removal. */
-	rc = ksmbd_vfs_casexattr_len(idmap,
-				     path->dentry,
+	rc = ksmbd_vfs_casexattr_len(path,
 				     xattr_stream_name,
 				     xattr_stream_size, xattr_stream_name);
 	if (rc >= 0)
@@ -3444,7 +3439,7 @@ static noinline int smb2_set_stream_name_xattr(const struct path *path,
 				0x00, 0x00, 0x01, 0x00,	/* version */
 				[15] = 0x80,		/* backup time */
 			};
-			rc = ksmbd_vfs_setxattr(idmap, path, xattr_stream_name,
+			rc = ksmbd_vfs_setxattr(path, xattr_stream_name,
 						(void *)afpinfo_empty,
 						sizeof(afpinfo_empty), 0, false);
 			return rc < 0 ? rc : 0;
@@ -3453,7 +3448,7 @@ static noinline int smb2_set_stream_name_xattr(const struct path *path,
 		return -EBADF;
 	}
 
-	rc = ksmbd_vfs_setxattr(idmap, path, xattr_stream_name, NULL, 0, 0, false);
+	rc = ksmbd_vfs_setxattr(path, xattr_stream_name, NULL, 0, 0, false);
 	if (rc < 0)
 		pr_err("Failed to store XATTR stream name :%d\n", rc);
 	return 0;
@@ -3468,8 +3463,7 @@ static noinline int smb2_set_stream_name_xattr(const struct path *path,
  */
 static loff_t ksmbd_stream_eof(struct ksmbd_file *fp)
 {
-	ssize_t slen = ksmbd_vfs_casexattr_len(file_mnt_idmap(fp->filp),
-					       fp->filp->f_path.dentry,
+	ssize_t slen = ksmbd_vfs_casexattr_len(&fp->filp->f_path,
 					       fp->stream.name,
 					       fp->stream.size, NULL);
 	return slen < 0 ? 0 : (loff_t)slen;
@@ -3477,12 +3471,11 @@ static loff_t ksmbd_stream_eof(struct ksmbd_file *fp)
 
 static int smb2_remove_smb_xattrs(const struct path *path)
 {
-	const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
 	char *name, *xattr_list = NULL;
 	ssize_t xattr_list_len;
 	int err = 0;
 
-	xattr_list_len = ksmbd_vfs_listxattr(path->dentry, &xattr_list);
+	xattr_list_len = ksmbd_vfs_listxattr(path, &xattr_list);
 	if (xattr_list_len < 0) {
 		goto out;
 	} else if (!xattr_list_len) {
@@ -3497,8 +3490,7 @@ static int smb2_remove_smb_xattrs(const struct path *path)
 		if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN) &&
 		    !strncmp(&name[XATTR_USER_PREFIX_LEN], STREAM_PREFIX,
 			     STREAM_PREFIX_LEN)) {
-			err = ksmbd_vfs_remove_xattr(idmap, path,
-						     name, true);
+			err = ksmbd_vfs_remove_xattr(path, name, true);
 			if (err)
 				ksmbd_debug(SMB, "remove xattr failed : %s\n",
 					    name);
@@ -3544,7 +3536,7 @@ static void smb2_new_xattrs(struct ksmbd_tree_connect *tcon, const struct path *
 	da.flags = XATTR_DOSINFO_ATTRIB | XATTR_DOSINFO_CREATE_TIME |
 		XATTR_DOSINFO_ITIME;
 
-	rc = ksmbd_vfs_set_dos_attrib_xattr(mnt_idmap(path->mnt), path, &da, true);
+	rc = ksmbd_vfs_set_dos_attrib_xattr(path, &da, true);
 	if (rc)
 		ksmbd_debug(SMB, "failed to store file attribute into xattr\n");
 }
@@ -3553,18 +3545,19 @@ static bool smb2_parent_compressed(struct ksmbd_tree_connect *tcon,
 				   const struct path *path)
 {
 	struct dentry *parent = dget_parent(path->dentry);
+	struct path parent_path = { .mnt = path->mnt, .dentry = parent };
 	struct file_kattr fa = { .flags_valid = true };
 	struct xattr_dos_attrib da;
 	bool compressed = false;
 	int rc;
 
-	rc = vfs_fileattr_get(parent, &fa);
+	rc = vfs_fileattr_get(&parent_path, &fa);
 	if (!rc && fa.flags & FS_COMPR_FL) {
 		compressed = true;
 		goto out;
 	}
 
-	rc = ksmbd_vfs_get_dos_attrib_xattr(mnt_idmap(path->mnt), parent, &da);
+	rc = ksmbd_vfs_get_dos_attrib_xattr(&parent_path, &da);
 	if (rc > 0 && da.attr & FILE_ATTRIBUTE_COMPRESSED)
 		compressed = true;
 
@@ -3584,8 +3577,7 @@ static void smb2_update_xattrs(struct ksmbd_tree_connect *tcon,
 	fp->f_ci->m_fattr &= ~(FILE_ATTRIBUTE_HIDDEN_LE | FILE_ATTRIBUTE_SYSTEM_LE);
 
 	/* get FileAttributes from XATTR_NAME_DOS_ATTRIBUTE */
-	rc = ksmbd_vfs_get_dos_attrib_xattr(mnt_idmap(path->mnt),
-					    path->dentry, &da);
+	rc = ksmbd_vfs_get_dos_attrib_xattr(path, &da);
 	if (rc > 0) {
 		if (store_dos_attrs) {
 			fp->f_ci->m_fattr = cpu_to_le32(da.attr);
@@ -4623,8 +4615,7 @@ int smb2_open(struct ksmbd_work *work)
 
 			if (test_share_config_flag(tcon->share_conf,
 						   KSMBD_SHARE_FLAG_STORE_DOS_ATTRS) &&
-			    ksmbd_vfs_get_dos_attrib_xattr(mnt_idmap(path.mnt),
-							 path.dentry, &da) > 0 &&
+			    ksmbd_vfs_get_dos_attrib_xattr(&path, &da) > 0 &&
 			    da.attr & FILE_ATTRIBUTE_READONLY) {
 				rsp->hdr.Status = STATUS_CANNOT_DELETE;
 				rc = -EACCES;
@@ -4962,7 +4953,6 @@ int smb2_open(struct ksmbd_work *work)
 					}
 
 					rc = ksmbd_vfs_set_sd_xattr(conn,
-								    idmap,
 								    &path,
 								    pntsd,
 								    pntsd_size,
@@ -5186,7 +5176,7 @@ int smb2_open(struct ksmbd_work *work)
 		smb2_new_xattrs(tcon, &path, fp);
 	}
 
-	ksmbd_vfs_update_compressed_fattr(path.dentry, &fp->f_ci->m_fattr);
+	ksmbd_vfs_update_compressed_fattr(&path, &fp->f_ci->m_fattr);
 
 	if (created) {
 		if (fp->coption & FILE_NO_COMPRESSION_LE) {
@@ -6163,7 +6153,6 @@ static int process_query_dir_entries(struct smb2_query_dir_private *priv)
 		ksmbd_kstat.kstat = &kstat;
 		if (priv->info_level != FILE_NAMES_INFORMATION) {
 			rc = ksmbd_vfs_fill_dentry_attrs(priv->work,
-							 idmap,
 							 dent,
 							 &ksmbd_kstat);
 			if (rc) {
@@ -6765,7 +6754,6 @@ static int smb2_get_ea(struct ksmbd_work *work, struct ksmbd_file *fp,
 	ssize_t buf_free_len, alignment_bytes, next_offset, rsp_data_cnt = 0;
 	struct smb2_ea_info_req *ea_req = NULL;
 	const struct path *path;
-	const struct mnt_idmap *idmap = file_mnt_idmap(fp->filp);
 
 	if (!(fp->daccess & FILE_READ_EA_LE)) {
 		pr_err("Not permitted to read ext attr : 0x%x\n",
@@ -6802,7 +6790,7 @@ static int smb2_get_ea(struct ksmbd_work *work, struct ksmbd_file *fp,
 	if (buf_free_len < 0)
 		return -EINVAL;
 
-	rc = ksmbd_vfs_listxattr(path->dentry, &xattr_list);
+	rc = ksmbd_vfs_listxattr(path, &xattr_list);
 	if (rc < 0) {
 		rsp->hdr.Status = STATUS_INVALID_HANDLE;
 		goto out;
@@ -6848,8 +6836,7 @@ static int smb2_get_ea(struct ksmbd_work *work, struct ksmbd_file *fp,
 		buf_free_len -= (offsetof(struct smb2_ea_info, name) +
 				name_len + 1);
 		/* bailout if xattr can't fit in buf_free_len */
-		value_len = ksmbd_vfs_getxattr(idmap, path->dentry,
-					       name, &buf);
+		value_len = ksmbd_vfs_getxattr(path, name, &buf);
 		if (value_len <= 0) {
 			rc = -ENOENT;
 			rsp->hdr.Status = STATUS_INVALID_HANDLE;
@@ -7139,7 +7126,7 @@ static char *smb2_get_normalized_stream_name(struct ksmbd_file *fp)
 	if (!ksmbd_stream_fd(fp))
 		return NULL;
 
-	xattr_list_len = ksmbd_vfs_listxattr(fp->filp->f_path.dentry,
+	xattr_list_len = ksmbd_vfs_listxattr(&fp->filp->f_path,
 					     &xattr_list);
 	if (xattr_list_len <= 0)
 		goto out;
@@ -7242,7 +7229,7 @@ static int get_file_stream_info(struct ksmbd_work *work,
 	if (buf_free_len < 0)
 		goto out;
 
-	xattr_list_len = ksmbd_vfs_listxattr(path->dentry, &xattr_list);
+	xattr_list_len = ksmbd_vfs_listxattr(path, &xattr_list);
 	if (xattr_list_len < 0) {
 		goto out;
 	} else if (!xattr_list_len) {
@@ -7287,8 +7274,7 @@ static int get_file_stream_info(struct ksmbd_work *work,
 		streamlen *= 2;
 		kfree(stream_buf);
 		file_info->StreamNameLength = cpu_to_le32(streamlen);
-		slen = ksmbd_vfs_xattr_len(file_mnt_idmap(fp->filp),
-					   path->dentry, stream_name);
+		slen = ksmbd_vfs_xattr_len(path, stream_name);
 		ssize = slen < 0 ? 0 : (loff_t)slen;
 		file_info->StreamSize = cpu_to_le64(ssize);
 		file_info->StreamAllocationSize = cpu_to_le64(ssize);
@@ -7757,7 +7743,7 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work,
 			FILE_SUPPORTS_SPARSE_FILES |
 			FILE_SUPPORTS_BLOCK_REFCOUNTING;
 
-		err = vfs_fileattr_get(path.dentry, &fa);
+		err = vfs_fileattr_get(&path, &fa);
 		/*
 		 * -EINVAL, -EOPNOTSUPP: ntfs-3g and other FUSE
 		 * filesystems that lack FS_IOC_FSGETXATTR support.
@@ -8026,8 +8012,8 @@ static int smb2_get_info_sec(struct ksmbd_work *work,
 
 	if (test_share_config_flag(work->tcon->share_conf,
 				   KSMBD_SHARE_FLAG_ACL_XATTR))
-		ppntsd_size = ksmbd_vfs_get_sd_xattr(work->conn, idmap,
-						     fp->filp->f_path.dentry,
+		ppntsd_size = ksmbd_vfs_get_sd_xattr(work->conn,
+						     &fp->filp->f_path,
 						     &ppntsd);
 
 	/* Check if sd buffer size exceeds response buffer size */
@@ -8388,8 +8374,7 @@ static int smb2_rename(struct ksmbd_work *work,
 				goto out;
 			}
 
-			stream_buf_len = ksmbd_vfs_getcasexattr(file_mnt_idmap(fp->filp),
-								fp->filp->f_path.dentry,
+			stream_buf_len = ksmbd_vfs_getcasexattr(&fp->filp->f_path,
 								fp->stream.name,
 								fp->stream.size,
 								&stream_buf);
@@ -8400,8 +8385,7 @@ static int smb2_rename(struct ksmbd_work *work,
 			}
 		}
 
-		rc = ksmbd_vfs_setxattr(file_mnt_idmap(fp->filp),
-					&fp->filp->f_path,
+		rc = ksmbd_vfs_setxattr(&fp->filp->f_path,
 					xattr_stream_name,
 					stream_buf, stream_buf_len, 0, true);
 		kfree(stream_buf);
@@ -8508,7 +8492,6 @@ static int set_file_basic_info(struct ksmbd_file *fp,
 	struct iattr attrs;
 	struct file *filp;
 	struct inode *inode;
-	const struct mnt_idmap *idmap;
 	__le32 attrs_mask = FILE_ATTRIBUTE_DIRECTORY_LE |
 		FILE_ATTRIBUTE_COMPRESSED_LE;
 	int rc = 0;
@@ -8519,7 +8502,6 @@ static int set_file_basic_info(struct ksmbd_file *fp,
 	attrs.ia_valid = 0;
 	filp = fp->filp;
 	inode = file_inode(filp);
-	idmap = file_mnt_idmap(filp);
 
 	if (file_info->CreationTime)
 		fp->create_time = le64_to_cpu(file_info->CreationTime);
@@ -8564,7 +8546,7 @@ static int set_file_basic_info(struct ksmbd_file *fp,
 		da.flags = XATTR_DOSINFO_ATTRIB | XATTR_DOSINFO_CREATE_TIME |
 			XATTR_DOSINFO_ITIME;
 
-		rc = ksmbd_vfs_set_dos_attrib_xattr(idmap, &filp->f_path, &da,
+		rc = ksmbd_vfs_set_dos_attrib_xattr(&filp->f_path, &da,
 				true);
 		if (rc)
 			ksmbd_debug(SMB,
@@ -8580,7 +8562,7 @@ static int set_file_basic_info(struct ksmbd_file *fp,
 			return -EACCES;
 
 		inode_lock(inode);
-		rc = notify_change(idmap, dentry, &attrs, NULL);
+		rc = notify_change(&filp->f_path, &attrs, NULL);
 		inode_unlock(inode);
 	}
 	return rc;
@@ -11127,7 +11109,6 @@ static inline int fsctl_set_sparse(struct ksmbd_work *work, u64 id,
 				   struct file_sparse *sparse)
 {
 	struct ksmbd_file *fp;
-	const struct mnt_idmap *idmap;
 	int ret = 0;
 	__le32 old_fattr;
 
@@ -11151,8 +11132,6 @@ static inline int fsctl_set_sparse(struct ksmbd_work *work, u64 id,
 		goto out;
 	}
 
-	idmap = file_mnt_idmap(fp->filp);
-
 	old_fattr = fp->f_ci->m_fattr;
 	if (!sparse->SetSparse &&
 	    (old_fattr & FILE_ATTRIBUTE_SPARSE_FILE_LE)) {
@@ -11170,8 +11149,7 @@ static inline int fsctl_set_sparse(struct ksmbd_work *work, u64 id,
 		const struct cred *saved_cred;
 		struct xattr_dos_attrib da = {0};
 
-		ret = ksmbd_vfs_get_dos_attrib_xattr(idmap,
-						     fp->filp->f_path.dentry, &da);
+		ret = ksmbd_vfs_get_dos_attrib_xattr(&fp->filp->f_path, &da);
 		if (ret <= 0) {
 			da.version = 4;
 			da.itime = fp->itime;
@@ -11183,8 +11161,7 @@ static inline int fsctl_set_sparse(struct ksmbd_work *work, u64 id,
 		da.attr = le32_to_cpu(fp->f_ci->m_fattr);
 		da.flags |= XATTR_DOSINFO_ATTRIB;
 		saved_cred = override_creds(fp->filp->f_cred);
-		ret = ksmbd_vfs_set_dos_attrib_xattr(idmap,
-						     &fp->filp->f_path,
+		ret = ksmbd_vfs_set_dos_attrib_xattr(&fp->filp->f_path,
 						     &da, true);
 		revert_creds(saved_cred);
 		if (ret)
diff --git a/fs/smb/server/smb_common.c b/fs/smb/server/smb_common.c
index 7dbcfa658edd5..2cc8e24dcd6cb 100644
--- a/fs/smb/server/smb_common.c
+++ b/fs/smb/server/smb_common.c
@@ -467,7 +467,6 @@ int ksmbd_populate_dot_dotdot_entries(struct ksmbd_work *work, int info_level,
 {
 	int i, rc = 0;
 	struct ksmbd_conn *conn = work->conn;
-	const struct mnt_idmap *idmap = file_mnt_idmap(dir->filp);
 
 	for (i = 0; i < 2; i++) {
 		struct kstat kstat;
@@ -493,7 +492,6 @@ int ksmbd_populate_dot_dotdot_entries(struct ksmbd_work *work, int info_level,
 
 			ksmbd_kstat.kstat = &kstat;
 			rc = ksmbd_vfs_fill_dentry_attrs(work,
-							 idmap,
 							 dentry,
 							 &ksmbd_kstat);
 			if (rc)
diff --git a/fs/smb/server/smbacl.c b/fs/smb/server/smbacl.c
index 96428df33b438..bcc506fca33e5 100644
--- a/fs/smb/server/smbacl.c
+++ b/fs/smb/server/smbacl.c
@@ -1199,8 +1199,8 @@ int smb_inherit_dacl(struct ksmbd_conn *conn,
 	struct smb_acl *parent_pdacl;
 	struct smb_ntsd *parent_pntsd = NULL;
 	struct smb_sid owner_sid, group_sid;
-	struct dentry *parent = path->dentry->d_parent;
-	const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
+	struct path parent_path = { .mnt = path->mnt,
+				    .dentry = path->dentry->d_parent };
 	int inherited_flags = 0, flags = 0, i, nt_size = 0, pdacl_size;
 	int rc = 0, pntsd_type, ppntsd_size, acl_len, aces_size;
 	unsigned int dacloffset;
@@ -1209,8 +1209,8 @@ int smb_inherit_dacl(struct ksmbd_conn *conn,
 	char *aces_base;
 	bool is_dir = S_ISDIR(d_inode(path->dentry)->i_mode);
 
-	ppntsd_size = ksmbd_vfs_get_sd_xattr(conn, idmap,
-					    parent, &parent_pntsd);
+	ppntsd_size = ksmbd_vfs_get_sd_xattr(conn, &parent_path,
+					    &parent_pntsd);
 	if (ppntsd_size <= 0)
 		return -ENOENT;
 
@@ -1427,7 +1427,7 @@ int smb_inherit_dacl(struct ksmbd_conn *conn,
 			pntsd_size += sizeof(struct smb_acl) + nt_size;
 		}
 
-		ksmbd_vfs_set_sd_xattr(conn, idmap, path, pntsd, pntsd_size, false);
+		ksmbd_vfs_set_sd_xattr(conn, path, pntsd, pntsd_size, false);
 		kfree(pntsd);
 	}
 
@@ -1476,8 +1476,7 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path,
 	vfsuid_t vfsuid;
 
 	ksmbd_debug(SMB, "check permission using windows acl\n");
-	pntsd_size = ksmbd_vfs_get_sd_xattr(conn, idmap,
-					    path->dentry, &pntsd);
+	pntsd_size = ksmbd_vfs_get_sd_xattr(conn, path, &pntsd);
 	if (pntsd_size <= 0 || !pntsd)
 		goto err_out;
 
@@ -1701,7 +1700,7 @@ int set_info_sec(struct ksmbd_conn *conn, struct ksmbd_tree_connect *tcon,
 	newattrs.ia_valid |= ATTR_MODE;
 	newattrs.ia_mode = (inode->i_mode & ~0777) | (fattr.cf_mode & 0777);
 
-	ksmbd_vfs_remove_acl_xattrs(idmap, path);
+	ksmbd_vfs_remove_acl_xattrs(path);
 	/* Update posix acls */
 	if (IS_ENABLED(CONFIG_FS_POSIX_ACL) && fattr.cf_dacls) {
 		rc = set_posix_acl(idmap, path->dentry,
@@ -1721,7 +1720,7 @@ int set_info_sec(struct ksmbd_conn *conn, struct ksmbd_tree_connect *tcon,
 	}
 
 	inode_lock(inode);
-	rc = notify_change(idmap, path->dentry, &newattrs, NULL);
+	rc = notify_change(path, &newattrs, NULL);
 	inode_unlock(inode);
 	if (rc)
 		goto out;
@@ -1732,8 +1731,8 @@ int set_info_sec(struct ksmbd_conn *conn, struct ksmbd_tree_connect *tcon,
 
 	if (test_share_config_flag(tcon->share_conf, KSMBD_SHARE_FLAG_ACL_XATTR)) {
 		/* Update WinACL in xattr */
-		ksmbd_vfs_remove_sd_xattrs(idmap, path);
-		ksmbd_vfs_set_sd_xattr(conn, idmap, path, pntsd, ntsd_len,
+		ksmbd_vfs_remove_sd_xattrs(path);
+		ksmbd_vfs_set_sd_xattr(conn, path, pntsd, ntsd_len,
 				get_write);
 	}
 
diff --git a/fs/smb/server/tests/smbacl_kunit.c b/fs/smb/server/tests/smbacl_kunit.c
index 33496b4d31a3e..0e918b72f94fe 100644
--- a/fs/smb/server/tests/smbacl_kunit.c
+++ b/fs/smb/server/tests/smbacl_kunit.c
@@ -221,8 +221,7 @@ static void ksmbd_smb_check_perm_dacl_boundary_test(struct kunit *test)
 				mk_vma_flags(VMA_NORESERVE_BIT));
 	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, file);
 
-	rc = ksmbd_vfs_set_sd_xattr(NULL, mnt_idmap(file->f_path.mnt),
-				    &file->f_path, pntsd, ntsd_size,
+	rc = ksmbd_vfs_set_sd_xattr(NULL, &file->f_path, pntsd, ntsd_size,
 				    false);
 	KUNIT_EXPECT_EQ(test, 0, rc);
 	if (rc)
@@ -263,8 +262,7 @@ ksmbd_smb_check_perm_dacl_maximal_boundary_test(struct kunit *test)
 				mk_vma_flags(VMA_NORESERVE_BIT));
 	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, file);
 
-	rc = ksmbd_vfs_set_sd_xattr(NULL, mnt_idmap(file->f_path.mnt),
-				    &file->f_path, pntsd, ntsd_size,
+	rc = ksmbd_vfs_set_sd_xattr(NULL, &file->f_path, pntsd, ntsd_size,
 				    false);
 	KUNIT_EXPECT_EQ(test, 0, rc);
 	if (rc)
diff --git a/fs/smb/server/vfs.c b/fs/smb/server/vfs.c
index d21ed90454f9a..c27a04dcfe385 100644
--- a/fs/smb/server/vfs.c
+++ b/fs/smb/server/vfs.c
@@ -218,14 +218,14 @@ int ksmbd_vfs_mkdir(struct ksmbd_work *work, const char *name, umode_t mode)
 	return err;
 }
 
-ssize_t ksmbd_vfs_getcasexattr(const struct mnt_idmap *idmap,
-			       struct dentry *dentry, char *attr_name,
+ssize_t ksmbd_vfs_getcasexattr(const struct path *path,
+			       char *attr_name,
 			       int attr_name_len, char **attr_value)
 {
 	char *name, *xattr_list = NULL;
 	ssize_t value_len = -ENOENT, xattr_list_len;
 
-	xattr_list_len = ksmbd_vfs_listxattr(dentry, &xattr_list);
+	xattr_list_len = ksmbd_vfs_listxattr(path, &xattr_list);
 	if (xattr_list_len <= 0)
 		goto out;
 
@@ -235,8 +235,7 @@ ssize_t ksmbd_vfs_getcasexattr(const struct mnt_idmap *idmap,
 		if (strncasecmp(attr_name, name, attr_name_len))
 			continue;
 
-		value_len = ksmbd_vfs_getxattr(idmap,
-					       dentry,
+		value_len = ksmbd_vfs_getxattr(path,
 					       name,
 					       attr_value);
 		if (value_len < 0)
@@ -260,8 +259,7 @@ static int ksmbd_vfs_stream_read(struct ksmbd_file *fp, char *buf, loff_t *pos,
 		    *pos, count);
 
 	saved_cred = override_creds(fp->filp->f_cred);
-	v_len = ksmbd_vfs_getcasexattr(file_mnt_idmap(fp->filp),
-				       fp->filp->f_path.dentry,
+	v_len = ksmbd_vfs_getcasexattr(&fp->filp->f_path,
 				       fp->stream.name,
 				       fp->stream.size,
 				       &stream_buf);
@@ -388,7 +386,6 @@ static int ksmbd_vfs_stream_write(struct ksmbd_file *fp, char *buf, loff_t *pos,
 {
 	const struct cred *saved_cred;
 	char *stream_buf = NULL, *wbuf;
-	const struct mnt_idmap *idmap = file_mnt_idmap(fp->filp);
 	size_t size, write_end;
 	ssize_t v_len;
 	int err = 0;
@@ -406,8 +403,7 @@ static int ksmbd_vfs_stream_write(struct ksmbd_file *fp, char *buf, loff_t *pos,
 	write_end = *pos + count;
 
 	saved_cred = override_creds(fp->filp->f_cred);
-	v_len = ksmbd_vfs_getcasexattr(idmap,
-				       fp->filp->f_path.dentry,
+	v_len = ksmbd_vfs_getcasexattr(&fp->filp->f_path,
 				       fp->stream.name,
 				       fp->stream.size,
 				       &stream_buf);
@@ -434,8 +430,7 @@ static int ksmbd_vfs_stream_write(struct ksmbd_file *fp, char *buf, loff_t *pos,
 
 	memcpy(&stream_buf[*pos], buf, count);
 
-	err = ksmbd_vfs_setxattr(idmap,
-				 &fp->filp->f_path,
+	err = ksmbd_vfs_setxattr(&fp->filp->f_path,
 				 fp->stream.name,
 				 (void *)stream_buf,
 				 size,
@@ -465,7 +460,6 @@ static int ksmbd_vfs_stream_write(struct ksmbd_file *fp, char *buf, loff_t *pos,
 int ksmbd_vfs_stream_truncate(struct ksmbd_file *fp, loff_t newsize)
 {
 	const struct cred *saved_cred;
-	const struct mnt_idmap *idmap = file_mnt_idmap(fp->filp);
 	char *stream_buf = NULL, *new_buf = NULL;
 	ssize_t v_len;
 	int err;
@@ -476,7 +470,7 @@ int ksmbd_vfs_stream_truncate(struct ksmbd_file *fp, loff_t newsize)
 		return -EFBIG;
 
 	saved_cred = override_creds(fp->filp->f_cred);
-	v_len = ksmbd_vfs_getcasexattr(idmap, fp->filp->f_path.dentry,
+	v_len = ksmbd_vfs_getcasexattr(&fp->filp->f_path,
 				       fp->stream.name, fp->stream.size,
 				       &stream_buf);
 	if (v_len < 0) {
@@ -499,7 +493,7 @@ int ksmbd_vfs_stream_truncate(struct ksmbd_file *fp, loff_t newsize)
 			memcpy(new_buf, stream_buf, v_len);
 	}
 
-	err = ksmbd_vfs_setxattr(idmap, &fp->filp->f_path, fp->stream.name,
+	err = ksmbd_vfs_setxattr(&fp->filp->f_path, fp->stream.name,
 				 new_buf, newsize, 0, true);
 	if (new_buf != stream_buf)
 		kvfree(new_buf);
@@ -870,17 +864,17 @@ int ksmbd_vfs_truncate(struct ksmbd_work *work,
 
 /**
  * ksmbd_vfs_listxattr() - vfs helper for smb list extended attributes
- * @dentry:	dentry of file for listing xattrs
+ * @path:	path of file for listing xattrs
  * @list:	destination buffer
  *
  * Return:	xattr list length on success, otherwise error
  */
-ssize_t ksmbd_vfs_listxattr(struct dentry *dentry, char **list)
+ssize_t ksmbd_vfs_listxattr(const struct path *path, char **list)
 {
 	ssize_t size;
 	char *vlist = NULL;
 
-	size = vfs_listxattr(dentry, NULL, 0);
+	size = vfs_listxattr(path, NULL, 0);
 	if (size <= 0)
 		return size;
 
@@ -889,7 +883,7 @@ ssize_t ksmbd_vfs_listxattr(struct dentry *dentry, char **list)
 		return -ENOMEM;
 
 	*list = vlist;
-	size = vfs_listxattr(dentry, vlist, size);
+	size = vfs_listxattr(path, vlist, size);
 	if (size < 0) {
 		ksmbd_debug(VFS, "listxattr failed\n");
 		kvfree(vlist);
@@ -899,30 +893,27 @@ ssize_t ksmbd_vfs_listxattr(struct dentry *dentry, char **list)
 	return size;
 }
 
-ssize_t ksmbd_vfs_xattr_len(const struct mnt_idmap *idmap,
-			    struct dentry *dentry, char *xattr_name)
+ssize_t ksmbd_vfs_xattr_len(const struct path *path, char *xattr_name)
 {
-	return vfs_getxattr(idmap, dentry, xattr_name, NULL, 0);
+	return vfs_getxattr(path, xattr_name, NULL, 0);
 }
 
 /**
  * ksmbd_vfs_getxattr() - vfs helper for smb get extended attributes value
- * @idmap:	idmap
- * @dentry:	dentry of file for getting xattrs
+ * @path:	path of file for getting xattrs
  * @xattr_name:	name of xattr name to query
  * @xattr_buf:	destination buffer xattr value
  *
  * Return:	read xattr value length on success, otherwise error
  */
-ssize_t ksmbd_vfs_getxattr(const struct mnt_idmap *idmap,
-			   struct dentry *dentry,
+ssize_t ksmbd_vfs_getxattr(const struct path *path,
 			   char *xattr_name, char **xattr_buf)
 {
 	ssize_t xattr_len;
 	char *buf;
 
 	*xattr_buf = NULL;
-	xattr_len = ksmbd_vfs_xattr_len(idmap, dentry, xattr_name);
+	xattr_len = ksmbd_vfs_xattr_len(path, xattr_name);
 	if (xattr_len < 0)
 		return xattr_len;
 
@@ -930,8 +921,7 @@ ssize_t ksmbd_vfs_getxattr(const struct mnt_idmap *idmap,
 	if (!buf)
 		return -ENOMEM;
 
-	xattr_len = vfs_getxattr(idmap, dentry, xattr_name,
-				 (void *)buf, xattr_len);
+	xattr_len = vfs_getxattr(path, xattr_name, (void *)buf, xattr_len);
 	if (xattr_len > 0)
 		*xattr_buf = buf;
 	else
@@ -941,7 +931,6 @@ ssize_t ksmbd_vfs_getxattr(const struct mnt_idmap *idmap,
 
 /**
  * ksmbd_vfs_setxattr() - vfs helper for smb set extended attributes value
- * @idmap:	idmap of the relevant mount
  * @path:	path of dentry to set XATTR at
  * @attr_name:	xattr name for setxattr
  * @attr_value:	xattr value to set
@@ -951,8 +940,7 @@ ssize_t ksmbd_vfs_getxattr(const struct mnt_idmap *idmap,
  *
  * Return:	0 on success, otherwise error
  */
-int ksmbd_vfs_setxattr(const struct mnt_idmap *idmap,
-		       const struct path *path, const char *attr_name,
+int ksmbd_vfs_setxattr(const struct path *path, const char *attr_name,
 		       void *attr_value, size_t attr_size, int flags,
 		       bool get_write)
 {
@@ -964,8 +952,7 @@ int ksmbd_vfs_setxattr(const struct mnt_idmap *idmap,
 			return err;
 	}
 
-	err = vfs_setxattr(idmap,
-			   path->dentry,
+	err = vfs_setxattr(path,
 			   attr_name,
 			   attr_value,
 			   attr_size,
@@ -1235,8 +1222,7 @@ int ksmbd_vfs_query_allocated_ranges(struct ksmbd_file *fp, loff_t start,
 	return ret;
 }
 
-int ksmbd_vfs_remove_xattr(const struct mnt_idmap *idmap,
-			   const struct path *path, char *attr_name,
+int ksmbd_vfs_remove_xattr(const struct path *path, char *attr_name,
 			   bool get_write)
 {
 	int err;
@@ -1247,7 +1233,7 @@ int ksmbd_vfs_remove_xattr(const struct mnt_idmap *idmap,
 			return err;
 	}
 
-	err = vfs_removexattr(idmap, path->dentry, attr_name);
+	err = vfs_removexattr(path, attr_name);
 
 	if (get_write == true)
 		mnt_drop_write(path->mnt);
@@ -1529,14 +1515,13 @@ struct dentry *ksmbd_vfs_kern_path_create(struct ksmbd_work *work,
 	return dent;
 }
 
-int ksmbd_vfs_remove_acl_xattrs(const struct mnt_idmap *idmap,
-				const struct path *path)
+int ksmbd_vfs_remove_acl_xattrs(const struct path *path)
 {
 	char *name, *xattr_list = NULL;
 	ssize_t xattr_list_len;
 	int err = 0;
 
-	xattr_list_len = ksmbd_vfs_listxattr(path->dentry, &xattr_list);
+	xattr_list_len = ksmbd_vfs_listxattr(path, &xattr_list);
 	if (xattr_list_len < 0) {
 		goto out;
 	} else if (!xattr_list_len) {
@@ -1556,7 +1541,7 @@ int ksmbd_vfs_remove_acl_xattrs(const struct mnt_idmap *idmap,
 			     sizeof(XATTR_NAME_POSIX_ACL_ACCESS) - 1) ||
 		    !strncmp(name, XATTR_NAME_POSIX_ACL_DEFAULT,
 			     sizeof(XATTR_NAME_POSIX_ACL_DEFAULT) - 1)) {
-			err = vfs_remove_acl(idmap, path->dentry, name);
+			err = vfs_remove_acl(path, name);
 			if (err)
 				ksmbd_debug(SMB,
 					    "remove acl xattr failed : %s\n", name);
@@ -1569,13 +1554,13 @@ int ksmbd_vfs_remove_acl_xattrs(const struct mnt_idmap *idmap,
 	return err;
 }
 
-int ksmbd_vfs_remove_sd_xattrs(const struct mnt_idmap *idmap, const struct path *path)
+int ksmbd_vfs_remove_sd_xattrs(const struct path *path)
 {
 	char *name, *xattr_list = NULL;
 	ssize_t xattr_list_len;
 	int err = 0;
 
-	xattr_list_len = ksmbd_vfs_listxattr(path->dentry, &xattr_list);
+	xattr_list_len = ksmbd_vfs_listxattr(path, &xattr_list);
 	if (xattr_list_len < 0) {
 		goto out;
 	} else if (!xattr_list_len) {
@@ -1588,7 +1573,7 @@ int ksmbd_vfs_remove_sd_xattrs(const struct mnt_idmap *idmap, const struct path
 		ksmbd_debug(SMB, "%s, len %zd\n", name, strlen(name));
 
 		if (!strncmp(name, XATTR_NAME_SD, XATTR_NAME_SD_LEN)) {
-			err = ksmbd_vfs_remove_xattr(idmap, path, name, true);
+			err = ksmbd_vfs_remove_xattr(path, name, true);
 			if (err)
 				ksmbd_debug(SMB, "remove xattr failed : %s\n", name);
 		}
@@ -1664,7 +1649,6 @@ static struct xattr_smb_acl *ksmbd_vfs_make_xattr_posix_acl(const struct mnt_idm
 }
 
 int ksmbd_vfs_set_sd_xattr(struct ksmbd_conn *conn,
-			   const struct mnt_idmap *idmap,
 			   const struct path *path,
 			   struct smb_ntsd *pntsd, int len,
 			   bool get_write)
@@ -1675,6 +1659,7 @@ int ksmbd_vfs_set_sd_xattr(struct ksmbd_conn *conn,
 	struct xattr_smb_acl *smb_acl, *def_smb_acl = NULL;
 	struct dentry *dentry = path->dentry;
 	struct inode *inode = d_inode(dentry);
+	const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
 
 	acl.version = 4;
 	acl.hash_type = XATTR_SD_HASH_TYPE_SHA256;
@@ -1716,7 +1701,7 @@ int ksmbd_vfs_set_sd_xattr(struct ksmbd_conn *conn,
 		goto out;
 	}
 
-	rc = ksmbd_vfs_setxattr(idmap, path,
+	rc = ksmbd_vfs_setxattr(path,
 				XATTR_NAME_SD, sd_ndr.data,
 				sd_ndr.offset, 0, get_write);
 	if (rc < 0)
@@ -1732,19 +1717,19 @@ int ksmbd_vfs_set_sd_xattr(struct ksmbd_conn *conn,
 EXPORT_SYMBOL_IF_KUNIT(ksmbd_vfs_set_sd_xattr);
 
 int ksmbd_vfs_get_sd_xattr(struct ksmbd_conn *conn,
-			   const struct mnt_idmap *idmap,
-			   struct dentry *dentry,
+			   const struct path *path,
 			   struct smb_ntsd **pntsd)
 {
 	int rc;
 	struct ndr n;
-	struct inode *inode = d_inode(dentry);
+	struct inode *inode = d_inode(path->dentry);
 	struct ndr acl_ndr = {0};
 	struct xattr_ntacl acl = {0};
 	struct xattr_smb_acl *smb_acl = NULL, *def_smb_acl = NULL;
+	const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
 	__u8 cmp_hash[XATTR_SD_HASH_SIZE] = {0};
 
-	rc = ksmbd_vfs_getxattr(idmap, dentry, XATTR_NAME_SD, &n.data);
+	rc = ksmbd_vfs_getxattr(path, XATTR_NAME_SD, &n.data);
 	if (rc <= 0)
 		return rc;
 
@@ -1801,8 +1786,7 @@ int ksmbd_vfs_get_sd_xattr(struct ksmbd_conn *conn,
 	return rc;
 }
 
-int ksmbd_vfs_set_dos_attrib_xattr(const struct mnt_idmap *idmap,
-				   const struct path *path,
+int ksmbd_vfs_set_dos_attrib_xattr(const struct path *path,
 				   struct xattr_dos_attrib *da,
 				   bool get_write)
 {
@@ -1813,7 +1797,7 @@ int ksmbd_vfs_set_dos_attrib_xattr(const struct mnt_idmap *idmap,
 	if (err)
 		goto out;
 
-	err = ksmbd_vfs_setxattr(idmap, path, XATTR_NAME_DOS_ATTRIBUTE,
+	err = ksmbd_vfs_setxattr(path, XATTR_NAME_DOS_ATTRIBUTE,
 				 (void *)n.data, n.offset, 0, get_write);
 	if (err)
 		ksmbd_debug(SMB, "failed to store dos attribute in xattr\n");
@@ -1823,14 +1807,13 @@ int ksmbd_vfs_set_dos_attrib_xattr(const struct mnt_idmap *idmap,
 	return err;
 }
 
-int ksmbd_vfs_get_dos_attrib_xattr(const struct mnt_idmap *idmap,
-				   struct dentry *dentry,
+int ksmbd_vfs_get_dos_attrib_xattr(const struct path *path,
 				   struct xattr_dos_attrib *da)
 {
 	struct ndr n;
 	int err;
 
-	err = ksmbd_vfs_getxattr(idmap, dentry, XATTR_NAME_DOS_ATTRIBUTE,
+	err = ksmbd_vfs_getxattr(path, XATTR_NAME_DOS_ATTRIBUTE,
 				 (char **)&n.data);
 	if (err > 0) {
 		n.length = err;
@@ -1879,7 +1862,6 @@ void *ksmbd_vfs_init_kstat(char **p, struct ksmbd_kstat *ksmbd_kstat)
 }
 
 int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work,
-				const struct mnt_idmap *idmap,
 				struct dentry *dentry,
 				struct ksmbd_kstat *ksmbd_kstat)
 {
@@ -1913,7 +1895,7 @@ int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work,
 				   KSMBD_SHARE_FLAG_STORE_DOS_ATTRS)) {
 		struct xattr_dos_attrib da;
 
-		rc = ksmbd_vfs_get_dos_attrib_xattr(idmap, dentry, &da);
+		rc = ksmbd_vfs_get_dos_attrib_xattr(&path, &da);
 		if (rc > 0) {
 			ksmbd_kstat->file_attributes = cpu_to_le32(da.attr);
 			ksmbd_kstat->create_time = da.create_time;
@@ -1936,7 +1918,7 @@ int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work,
 		char *xattr_list = NULL, *name;
 		ssize_t xattr_list_len;
 
-		xattr_list_len = ksmbd_vfs_listxattr(dentry, &xattr_list);
+		xattr_list_len = ksmbd_vfs_listxattr(&path, &xattr_list);
 		if (xattr_list_len > 0) {
 			for (name = xattr_list;
 			     name - xattr_list < xattr_list_len;
@@ -1954,14 +1936,14 @@ int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work,
 	return 0;
 }
 
-ssize_t ksmbd_vfs_casexattr_len(const struct mnt_idmap *idmap,
-				struct dentry *dentry, char *attr_name,
+ssize_t ksmbd_vfs_casexattr_len(const struct path *path,
+				char *attr_name,
 				int attr_name_len, char *actual_name)
 {
 	char *name, *xattr_list = NULL;
 	ssize_t value_len = -ENOENT, xattr_list_len;
 
-	xattr_list_len = ksmbd_vfs_listxattr(dentry, &xattr_list);
+	xattr_list_len = ksmbd_vfs_listxattr(path, &xattr_list);
 	if (xattr_list_len < 0) {
 		value_len = xattr_list_len;
 		goto out;
@@ -1977,7 +1959,7 @@ ssize_t ksmbd_vfs_casexattr_len(const struct mnt_idmap *idmap,
 		if (actual_name && strlen(name) + 1 != attr_name_len)
 			continue;
 
-		value_len = ksmbd_vfs_xattr_len(idmap, dentry, name);
+		value_len = ksmbd_vfs_xattr_len(path, name);
 		/* The caller provides attr_name_len bytes for the actual name. */
 		if (value_len >= 0 && actual_name)
 			memcpy(actual_name, name, attr_name_len);
@@ -2133,8 +2115,7 @@ int ksmbd_vfs_copy_file_ranges(struct ksmbd_work *work,
 
 		saved_cred = override_creds(src_fp->filp->f_cred);
 		src_file_size = ksmbd_vfs_casexattr_len(
-				file_mnt_idmap(src_fp->filp),
-				src_fp->filp->f_path.dentry,
+				&src_fp->filp->f_path,
 				src_fp->stream.name, src_fp->stream.size, NULL);
 		revert_creds(saved_cred);
 		if (src_file_size < 0)
@@ -2347,12 +2328,12 @@ int ksmbd_vfs_inherit_posix_acl(const struct mnt_idmap *idmap,
 	return 0;
 }
 
-void ksmbd_vfs_update_compressed_fattr(struct dentry *dentry, __le32 *fattr)
+void ksmbd_vfs_update_compressed_fattr(struct path *path, __le32 *fattr)
 {
 	int rc;
 	struct file_kattr fa = { .flags_valid = true };
 
-	rc = vfs_fileattr_get(dentry, &fa);
+	rc = vfs_fileattr_get(path, &fa);
 	if (rc)
 		return;
 
@@ -2365,7 +2346,7 @@ int ksmbd_vfs_get_compression(struct ksmbd_file *fp, u16 *fmt)
 	struct file_kattr fa = { .flags_valid = true };
 	int rc;
 
-	rc = vfs_fileattr_get(fp->filp->f_path.dentry, &fa);
+	rc = vfs_fileattr_get(&fp->filp->f_path, &fa);
 	if (rc == -ENOIOCTLCMD || rc == -ENOTTY || rc == -EINVAL ||
 	    rc == -EOPNOTSUPP) {
 		if (fp->f_ci->m_fattr & FILE_ATTRIBUTE_COMPRESSED_LE)
@@ -2393,8 +2374,6 @@ static int __ksmbd_vfs_set_compression(struct ksmbd_work *work,
 {
 	const struct cred *saved_cred = NULL;
 	struct file_kattr fa;
-	struct dentry *dentry = fp->filp->f_path.dentry;
-	const struct mnt_idmap *idmap = file_mnt_idmap(fp->filp);
 	u32 flags;
 	__le32 old_fattr;
 	int rc;
@@ -2412,7 +2391,7 @@ static int __ksmbd_vfs_set_compression(struct ksmbd_work *work,
 	}
 
 	saved_cred = override_creds(fp->filp->f_cred);
-	rc = vfs_fileattr_get(dentry, &fa);
+	rc = vfs_fileattr_get(&fp->filp->f_path, &fa);
 	if (rc == -ENOIOCTLCMD || rc == -ENOTTY || rc == -EINVAL ||
 	    rc == -EOPNOTSUPP)
 		goto update_fattr;
@@ -2433,7 +2412,7 @@ static int __ksmbd_vfs_set_compression(struct ksmbd_work *work,
 		if (rc)
 			goto out;
 
-		rc = vfs_fileattr_set(idmap, dentry, &fa);
+		rc = vfs_fileattr_set(&fp->filp->f_path, &fa);
 		mnt_drop_write_file(fp->filp);
 		if (rc == -ENOIOCTLCMD || rc == -ENOTTY || rc == -EINVAL ||
 		    rc == -EOPNOTSUPP)
@@ -2452,7 +2431,7 @@ static int __ksmbd_vfs_set_compression(struct ksmbd_work *work,
 	if (fp->f_ci->m_fattr != old_fattr) {
 		struct xattr_dos_attrib da = {0};
 
-		rc = ksmbd_vfs_get_dos_attrib_xattr(idmap, dentry, &da);
+		rc = ksmbd_vfs_get_dos_attrib_xattr(&fp->filp->f_path, &da);
 		if (rc <= 0) {
 			da.version = 4;
 			da.itime = fp->itime;
@@ -2463,8 +2442,7 @@ static int __ksmbd_vfs_set_compression(struct ksmbd_work *work,
 
 		da.attr = le32_to_cpu(fp->f_ci->m_fattr);
 		da.flags |= XATTR_DOSINFO_ATTRIB;
-		rc = ksmbd_vfs_set_dos_attrib_xattr(idmap,
-						    &fp->filp->f_path,
+		rc = ksmbd_vfs_set_dos_attrib_xattr(&fp->filp->f_path,
 						    &da, true);
 		if (rc)
 			rc = 0;
diff --git a/fs/smb/server/vfs.h b/fs/smb/server/vfs.h
index 21b0d29a3db0b..404cf98fe6074 100644
--- a/fs/smb/server/vfs.h
+++ b/fs/smb/server/vfs.h
@@ -104,27 +104,24 @@ int ksmbd_vfs_copy_file_ranges(struct ksmbd_work *work,
 			       unsigned int *chunk_count_written,
 			       unsigned int *chunk_size_written,
 			       loff_t  *total_size_written);
-ssize_t ksmbd_vfs_listxattr(struct dentry *dentry, char **list);
-ssize_t ksmbd_vfs_getxattr(const struct mnt_idmap *idmap,
-			   struct dentry *dentry,
+ssize_t ksmbd_vfs_listxattr(const struct path *path, char **list);
+ssize_t ksmbd_vfs_getxattr(const struct path *path,
 			   char *xattr_name,
 			   char **xattr_buf);
-ssize_t ksmbd_vfs_xattr_len(const struct mnt_idmap *idmap,
-			    struct dentry *dentry, char *xattr_name);
-ssize_t ksmbd_vfs_getcasexattr(const struct mnt_idmap *idmap,
-			       struct dentry *dentry, char *attr_name,
+ssize_t ksmbd_vfs_xattr_len(const struct path *path,
+			    char *xattr_name);
+ssize_t ksmbd_vfs_getcasexattr(const struct path *path,
+			       char *attr_name,
 			       int attr_name_len, char **attr_value);
-ssize_t ksmbd_vfs_casexattr_len(const struct mnt_idmap *idmap,
-				struct dentry *dentry, char *attr_name,
+ssize_t ksmbd_vfs_casexattr_len(const struct path *path,
+				char *attr_name,
 				int attr_name_len, char *actual_name);
-int ksmbd_vfs_setxattr(const struct mnt_idmap *idmap,
-		       const struct path *path, const char *attr_name,
+int ksmbd_vfs_setxattr(const struct path *path, const char *attr_name,
 		       void *attr_value, size_t attr_size, int flags,
 		       bool get_write);
 int ksmbd_vfs_xattr_stream_name(char *stream_name, char **xattr_stream_name,
 				size_t *xattr_stream_name_size, int s_type);
-int ksmbd_vfs_remove_xattr(const struct mnt_idmap *idmap,
-			   const struct path *path, char *attr_name,
+int ksmbd_vfs_remove_xattr(const struct path *path, char *attr_name,
 			   bool get_write);
 int ksmbd_vfs_kern_path(struct ksmbd_work *work, char *name,
 			unsigned int flags,
@@ -153,36 +150,30 @@ int ksmbd_vfs_query_allocated_ranges(struct ksmbd_file *fp, loff_t start,
 int ksmbd_vfs_unlink(struct file *filp);
 void *ksmbd_vfs_init_kstat(char **p, struct ksmbd_kstat *ksmbd_kstat);
 int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work,
-				const struct mnt_idmap *idmap,
 				struct dentry *dentry,
 				struct ksmbd_kstat *ksmbd_kstat);
 void ksmbd_vfs_posix_lock_wait(struct file_lock *flock);
 void ksmbd_vfs_posix_lock_unblock(struct file_lock *flock);
-int ksmbd_vfs_remove_acl_xattrs(const struct mnt_idmap *idmap,
-				const struct path *path);
-int ksmbd_vfs_remove_sd_xattrs(const struct mnt_idmap *idmap, const struct path *path);
+int ksmbd_vfs_remove_acl_xattrs(const struct path *path);
+int ksmbd_vfs_remove_sd_xattrs(const struct path *path);
 int ksmbd_vfs_set_sd_xattr(struct ksmbd_conn *conn,
-			   const struct mnt_idmap *idmap,
 			   const struct path *path,
 			   struct smb_ntsd *pntsd, int len,
 			   bool get_write);
 int ksmbd_vfs_get_sd_xattr(struct ksmbd_conn *conn,
-			   const struct mnt_idmap *idmap,
-			   struct dentry *dentry,
+			   const struct path *path,
 			   struct smb_ntsd **pntsd);
-int ksmbd_vfs_set_dos_attrib_xattr(const struct mnt_idmap *idmap,
-				   const struct path *path,
+int ksmbd_vfs_set_dos_attrib_xattr(const struct path *path,
 				   struct xattr_dos_attrib *da,
 				   bool get_write);
-int ksmbd_vfs_get_dos_attrib_xattr(const struct mnt_idmap *idmap,
-				   struct dentry *dentry,
+int ksmbd_vfs_get_dos_attrib_xattr(const struct path *path,
 				   struct xattr_dos_attrib *da);
 int ksmbd_vfs_set_init_posix_acl(const struct mnt_idmap *idmap,
 				 const struct path *path);
 int ksmbd_vfs_inherit_posix_acl(const struct mnt_idmap *idmap,
 				const struct path *path,
 				struct inode *parent_inode);
-void ksmbd_vfs_update_compressed_fattr(struct dentry *dentry, __le32 *fattr);
+void ksmbd_vfs_update_compressed_fattr(struct path *path, __le32 *fattr);
 int ksmbd_vfs_get_compression(struct ksmbd_file *fp, u16 *fmt);
 int ksmbd_vfs_set_compression(struct ksmbd_work *work, struct ksmbd_file *fp, u16 fmt);
 int ksmbd_vfs_set_compression_create(struct ksmbd_work *work,
diff --git a/fs/smb/server/vfs_cache.c b/fs/smb/server/vfs_cache.c
index 496055ce4a4d9..96385d1cdbb42 100644
--- a/fs/smb/server/vfs_cache.c
+++ b/fs/smb/server/vfs_cache.c
@@ -538,8 +538,7 @@ static void __ksmbd_inode_close(struct ksmbd_file *fp)
 			const struct cred *saved_cred;
 
 			saved_cred = override_creds(filp->f_cred);
-			err = ksmbd_vfs_remove_xattr(file_mnt_idmap(filp),
-						     &filp->f_path,
+			err = ksmbd_vfs_remove_xattr(&filp->f_path,
 						     fp->stream.name,
 						     true);
 			revert_creds(saved_cred);
diff --git a/fs/stat.c b/fs/stat.c
index a2e63c6c45b77..06e4a5dcea574 100644
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -172,7 +172,7 @@ EXPORT_SYMBOL_GPL(generic_fill_statx_atomic_writes);
  * @request_mask: STATX_xxx flags indicating what the caller wants
  * @query_flags: Query mode (AT_STATX_SYNC_TYPE)
  *
- * Get attributes without calling security_inode_getattr.
+ * Get attributes without calling security_path_getattr.
  *
  * Currently the only caller other than vfs_getattr is internal to the
  * filehandle lookup code, which uses only the inode number and returns no
@@ -260,7 +260,7 @@ int vfs_getattr(const struct path *path, struct kstat *stat,
 {
 	int retval;
 
-	retval = security_inode_getattr(path);
+	retval = security_path_getattr(path);
 	if (unlikely(retval))
 		return retval;
 	return vfs_getattr_nosec(path, stat, request_mask, query_flags);
diff --git a/fs/utimes.c b/fs/utimes.c
index e22664e4115f6..5de794587147c 100644
--- a/fs/utimes.c
+++ b/fs/utimes.c
@@ -64,8 +64,7 @@ int vfs_utimes(const struct path *path, struct timespec64 *times)
 	}
 retry_deleg:
 	inode_lock(inode);
-	error = notify_change(mnt_idmap(path->mnt), path->dentry, &newattrs,
-			      &delegated_inode);
+	error = notify_change(path, &newattrs, &delegated_inode);
 	inode_unlock(inode);
 	if (is_delegated(&delegated_inode)) {
 		error = break_deleg_wait(&delegated_inode);
diff --git a/fs/xattr.c b/fs/xattr.c
index d9f035610f0bf..5e960f4504883 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -285,8 +285,7 @@ int __vfs_setxattr_noperm(const struct mnt_idmap *idmap,
  * __vfs_setxattr_locked - set an extended attribute while holding the inode
  * lock
  *
- *  @idmap: idmap of the mount of the target inode
- *  @dentry: object to perform setxattr on
+ *  @path: object to perform setxattr on
  *  @name: xattr name to set
  *  @value: value to set @name to
  *  @size: size of @value
@@ -295,10 +294,12 @@ int __vfs_setxattr_noperm(const struct mnt_idmap *idmap,
  *  a delegation was broken on, NULL if none.
  */
 int
-__vfs_setxattr_locked(const struct mnt_idmap *idmap, struct dentry *dentry,
-		      const char *name, const void *value, size_t size,
-		      int flags, struct delegated_inode *delegated_inode)
+__vfs_setxattr_locked(const struct path *path, const char *name,
+		      const void *value, size_t size, int flags,
+		      struct delegated_inode *delegated_inode)
 {
+	const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
+	struct dentry *dentry = path->dentry;
 	struct inode *inode = dentry->d_inode;
 	int error;
 
@@ -306,7 +307,7 @@ __vfs_setxattr_locked(const struct mnt_idmap *idmap, struct dentry *dentry,
 	if (error)
 		return error;
 
-	error = security_inode_setxattr(idmap, dentry, name, value, size,
+	error = security_path_setxattr(path, name, value, size,
 					flags);
 	if (error)
 		goto out;
@@ -324,9 +325,11 @@ __vfs_setxattr_locked(const struct mnt_idmap *idmap, struct dentry *dentry,
 EXPORT_SYMBOL_GPL(__vfs_setxattr_locked);
 
 int
-vfs_setxattr(const struct mnt_idmap *idmap, struct dentry *dentry,
-	     const char *name, const void *value, size_t size, int flags)
+vfs_setxattr(const struct path *path, const char *name, const void *value,
+	     size_t size, int flags)
 {
+	const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
+	struct dentry *dentry = path->dentry;
 	struct inode *inode = dentry->d_inode;
 	struct delegated_inode delegated_inode = { };
 	const void  *orig_value = value;
@@ -341,7 +344,7 @@ vfs_setxattr(const struct mnt_idmap *idmap, struct dentry *dentry,
 
 retry_deleg:
 	inode_lock(inode);
-	error = __vfs_setxattr_locked(idmap, dentry, name, value, size,
+	error = __vfs_setxattr_locked(path, name, value, size,
 				      flags, &delegated_inode);
 	inode_unlock(inode);
 
@@ -448,9 +451,11 @@ __vfs_getxattr(struct dentry *dentry, struct inode *inode, const char *name,
 EXPORT_SYMBOL(__vfs_getxattr);
 
 ssize_t
-vfs_getxattr(const struct mnt_idmap *idmap, struct dentry *dentry,
-	     const char *name, void *value, size_t size)
+vfs_getxattr(const struct path *path, const char *name, void *value,
+	     size_t size)
 {
+	const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
+	struct dentry *dentry = path->dentry;
 	struct inode *inode = dentry->d_inode;
 	int error;
 
@@ -458,7 +463,7 @@ vfs_getxattr(const struct mnt_idmap *idmap, struct dentry *dentry,
 	if (error)
 		return error;
 
-	error = security_inode_getxattr(dentry, name);
+	error = security_path_getxattr(path, name);
 	if (error)
 		return error;
 
@@ -482,12 +487,12 @@ EXPORT_SYMBOL_GPL(vfs_getxattr);
 
 /**
  * vfs_listxattr - retrieve \0 separated list of xattr names
- * @dentry: the dentry from whose inode the xattr names are retrieved
+ * @path: the path from whose inode the xattr names are retrieved
  * @list: buffer to store xattr names into
  * @size: size of the buffer
  *
  * This function returns the names of all xattrs associated with the
- * inode of @dentry.
+ * inode of @path->dentry.
  *
  * Note, for legacy reasons the vfs_listxattr() function lists POSIX
  * ACLs as well. Since POSIX ACLs are decoupled from IOP_XATTR the
@@ -503,12 +508,13 @@ EXPORT_SYMBOL_GPL(vfs_getxattr);
  *         negative error code.
  */
 ssize_t
-vfs_listxattr(struct dentry *dentry, char *list, size_t size)
+vfs_listxattr(const struct path *path, char *list, size_t size)
 {
+	struct dentry *dentry = path->dentry;
 	struct inode *inode = d_inode(dentry);
 	ssize_t error;
 
-	error = security_inode_listxattr(dentry);
+	error = security_path_listxattr(path);
 	if (error)
 		return error;
 
@@ -550,17 +556,17 @@ EXPORT_SYMBOL(__vfs_removexattr);
  * __vfs_removexattr_locked - set an extended attribute while holding the inode
  * lock
  *
- *  @idmap: idmap of the mount of the target inode
- *  @dentry: object to perform setxattr on
+ *  @path: object to perform removexattr on
  *  @name: name of xattr to remove
  *  @delegated_inode: on return, will contain an inode pointer that
  *  a delegation was broken on, NULL if none.
  */
 int
-__vfs_removexattr_locked(const struct mnt_idmap *idmap,
-			 struct dentry *dentry, const char *name,
+__vfs_removexattr_locked(const struct path *path, const char *name,
 			 struct delegated_inode *delegated_inode)
 {
+	const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
+	struct dentry *dentry = path->dentry;
 	struct inode *inode = dentry->d_inode;
 	int error;
 
@@ -568,7 +574,7 @@ __vfs_removexattr_locked(const struct mnt_idmap *idmap,
 	if (error)
 		return error;
 
-	error = security_inode_removexattr(idmap, dentry, name);
+	error = security_path_removexattr(path, name);
 	if (error)
 		goto out;
 
@@ -589,17 +595,16 @@ __vfs_removexattr_locked(const struct mnt_idmap *idmap,
 EXPORT_SYMBOL_GPL(__vfs_removexattr_locked);
 
 int
-vfs_removexattr(const struct mnt_idmap *idmap, struct dentry *dentry,
-		const char *name)
+vfs_removexattr(const struct path *path, const char *name)
 {
+	struct dentry *dentry = path->dentry;
 	struct inode *inode = dentry->d_inode;
 	struct delegated_inode delegated_inode = { };
 	int error;
 
 retry_deleg:
 	inode_lock(inode);
-	error = __vfs_removexattr_locked(idmap, dentry,
-					 name, &delegated_inode);
+	error = __vfs_removexattr_locked(path, name, &delegated_inode);
 	inode_unlock(inode);
 
 	if (is_delegated(&delegated_inode)) {
@@ -652,14 +657,13 @@ int setxattr_copy(const char __user *name, struct kernel_xattr_ctx *ctx)
 	return error;
 }
 
-static int do_setxattr(const struct mnt_idmap *idmap, struct dentry *dentry,
-		struct kernel_xattr_ctx *ctx)
+static int do_setxattr(const struct path *path, struct kernel_xattr_ctx *ctx)
 {
 	if (is_posix_acl_xattr(ctx->kname->name))
-		return do_set_acl(idmap, dentry, ctx->kname->name,
+		return do_set_acl(path, ctx->kname->name,
 				  ctx->kvalue, ctx->size);
 
-	return vfs_setxattr(idmap, dentry, ctx->kname->name,
+	return vfs_setxattr(path, ctx->kname->name,
 			ctx->kvalue, ctx->size, ctx->flags);
 }
 
@@ -669,7 +673,7 @@ int file_setxattr(struct file *f, struct kernel_xattr_ctx *ctx)
 
 	if (!error) {
 		audit_file(f);
-		error = do_setxattr(file_mnt_idmap(f), f->f_path.dentry, ctx);
+		error = do_setxattr(&f->f_path, ctx);
 		mnt_drop_write_file(f);
 	}
 	return error;
@@ -687,7 +691,7 @@ int filename_setxattr(int dfd, struct filename *filename,
 		return error;
 	error = mnt_want_write(path.mnt);
 	if (!error) {
-		error = do_setxattr(mnt_idmap(path.mnt), path.dentry, ctx);
+		error = do_setxattr(&path, ctx);
 		mnt_drop_write(path.mnt);
 	}
 	path_put(&path);
@@ -787,8 +791,7 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
  * Extended attribute GET operations
  */
 static ssize_t
-do_getxattr(const struct mnt_idmap *idmap, struct dentry *d,
-	struct kernel_xattr_ctx *ctx)
+do_getxattr(const struct path *path, struct kernel_xattr_ctx *ctx)
 {
 	ssize_t error;
 	char *kname = ctx->kname->name;
@@ -803,9 +806,9 @@ do_getxattr(const struct mnt_idmap *idmap, struct dentry *d,
 	}
 
 	if (is_posix_acl_xattr(kname))
-		error = do_get_acl(idmap, d, kname, kvalue, ctx->size);
+		error = do_get_acl(path, kname, kvalue, ctx->size);
 	else
-		error = vfs_getxattr(idmap, d, kname, kvalue, ctx->size);
+		error = vfs_getxattr(path, kname, kvalue, ctx->size);
 	if (error > 0) {
 		if (ctx->size && copy_to_user(ctx->value, kvalue, error))
 			error = -EFAULT;
@@ -822,7 +825,7 @@ do_getxattr(const struct mnt_idmap *idmap, struct dentry *d,
 ssize_t file_getxattr(struct file *f, struct kernel_xattr_ctx *ctx)
 {
 	audit_file(f);
-	return do_getxattr(file_mnt_idmap(f), f->f_path.dentry, ctx);
+	return do_getxattr(&f->f_path, ctx);
 }
 
 ssize_t filename_getxattr(int dfd, struct filename *filename,
@@ -834,7 +837,7 @@ ssize_t filename_getxattr(int dfd, struct filename *filename,
 	error = filename_lookup(dfd, filename, lookup_flags, &path, NULL);
 	if (error)
 		return error;
-	error = do_getxattr(mnt_idmap(path.mnt), path.dentry, ctx);
+	error = do_getxattr(&path, ctx);
 	path_put(&path);
 	if (retry_estale(error, lookup_flags)) {
 		lookup_flags |= LOOKUP_REVAL;
@@ -925,7 +928,7 @@ SYSCALL_DEFINE4(fgetxattr, int, fd, const char __user *, name,
  * Extended attribute LIST operations
  */
 static ssize_t
-listxattr(struct dentry *d, char __user *list, size_t size)
+listxattr(const struct path *path, char __user *list, size_t size)
 {
 	ssize_t error;
 	char *klist = NULL;
@@ -938,7 +941,7 @@ listxattr(struct dentry *d, char __user *list, size_t size)
 			return -ENOMEM;
 	}
 
-	error = vfs_listxattr(d, klist, size);
+	error = vfs_listxattr(path, klist, size);
 	if (error > 0) {
 		if (size && copy_to_user(list, klist, error))
 			error = -EFAULT;
@@ -957,7 +960,7 @@ static
 ssize_t file_listxattr(struct file *f, char __user *list, size_t size)
 {
 	audit_file(f);
-	return listxattr(f->f_path.dentry, list, size);
+	return listxattr(&f->f_path, list, size);
 }
 
 static
@@ -971,7 +974,7 @@ ssize_t filename_listxattr(int dfd, struct filename *filename,
 	error = filename_lookup(dfd, filename, lookup_flags, &path, NULL);
 	if (error)
 		return error;
-	error = listxattr(path.dentry, list, size);
+	error = listxattr(&path, list, size);
 	path_put(&path);
 	if (retry_estale(error, lookup_flags)) {
 		lookup_flags |= LOOKUP_REVAL;
@@ -1029,11 +1032,11 @@ SYSCALL_DEFINE3(flistxattr, int, fd, char __user *, list, size_t, size)
  * Extended attribute REMOVE operations
  */
 static long
-removexattr(const struct mnt_idmap *idmap, struct dentry *d, const char *name)
+removexattr(const struct path *path, const char *name)
 {
 	if (is_posix_acl_xattr(name))
-		return vfs_remove_acl(idmap, d, name);
-	return vfs_removexattr(idmap, d, name);
+		return vfs_remove_acl(path, name);
+	return vfs_removexattr(path, name);
 }
 
 static int file_removexattr(struct file *f, struct xattr_name *kname)
@@ -1042,8 +1045,7 @@ static int file_removexattr(struct file *f, struct xattr_name *kname)
 
 	if (!error) {
 		audit_file(f);
-		error = removexattr(file_mnt_idmap(f),
-				    f->f_path.dentry, kname->name);
+		error = removexattr(&f->f_path, kname->name);
 		mnt_drop_write_file(f);
 	}
 	return error;
@@ -1061,7 +1063,7 @@ static int filename_removexattr(int dfd, struct filename *filename,
 		return error;
 	error = mnt_want_write(path.mnt);
 	if (!error) {
-		error = removexattr(mnt_idmap(path.mnt), path.dentry, kname->name);
+		error = removexattr(&path, kname->name);
 		mnt_drop_write(path.mnt);
 	}
 	path_put(&path);
diff --git a/include/linux/fileattr.h b/include/linux/fileattr.h
index 09e32b84e02ac..a572cb8500146 100644
--- a/include/linux/fileattr.h
+++ b/include/linux/fileattr.h
@@ -73,9 +73,11 @@ static inline bool fileattr_has_fsx(const struct file_kattr *fa)
 		 fa->fsx_projid != 0 ||	fa->fsx_cowextsize != 0);
 }
 
-int vfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa);
-int vfs_fileattr_set(const struct mnt_idmap *idmap, struct dentry *dentry,
-		     struct file_kattr *fa);
+int __vfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa);
+int __vfs_fileattr_set(const struct mnt_idmap *idmap, struct dentry *dentry,
+		       struct file_kattr *fa);
+int vfs_fileattr_get(const struct path *path, struct file_kattr *fa);
+int vfs_fileattr_set(const struct path *path, struct file_kattr *fa);
 int ioctl_getflags(struct file *file, unsigned int __user *argp);
 int ioctl_setflags(struct file *file, unsigned int __user *argp);
 int ioctl_fsgetxattr(struct file *file, void __user *argp);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index f387c961e0a0a..5db46082906c3 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2488,7 +2488,7 @@ static inline bool is_idmapped_mnt(const struct vfsmount *mnt)
 }
 
 int vfs_truncate(const struct path *, loff_t);
-int do_truncate(const struct mnt_idmap *, struct dentry *, loff_t start,
+int do_truncate(const struct path *path, loff_t length,
 		unsigned int time_attrs, struct file *filp);
 extern int vfs_fallocate(struct file *file, int mode, loff_t offset,
 			loff_t len);
@@ -2712,8 +2712,10 @@ static inline int bmap(struct inode *inode,  sector_t *block)
 }
 #endif
 
-int notify_change(const struct mnt_idmap *, struct dentry *,
-		  struct iattr *, struct delegated_inode *);
+int __notify_change(const struct mnt_idmap *, struct dentry *,
+		    struct iattr *, struct delegated_inode *);
+int notify_change(const struct path *path, struct iattr *attr,
+		  struct delegated_inode *delegated_inode);
 int inode_permission(const struct mnt_idmap *, struct inode *, int);
 int generic_permission(const struct mnt_idmap *, struct inode *, int);
 static inline int file_permission(struct file *file, int mask)
diff --git a/include/linux/landlock.h b/include/linux/landlock.h
index 0ee4880988bab..ee1234fbc9f06 100644
--- a/include/linux/landlock.h
+++ b/include/linux/landlock.h
@@ -41,7 +41,9 @@
 	_LANDLOCK_NAME_ENTRY(LANDLOCK_ACCESS_FS_REFER, "refer"), \
 	_LANDLOCK_NAME_ENTRY(LANDLOCK_ACCESS_FS_TRUNCATE, "truncate"), \
 	_LANDLOCK_NAME_ENTRY(LANDLOCK_ACCESS_FS_IOCTL_DEV, "ioctl_dev"), \
-	_LANDLOCK_NAME_ENTRY(LANDLOCK_ACCESS_FS_RESOLVE_UNIX, "resolve_unix")
+	_LANDLOCK_NAME_ENTRY(LANDLOCK_ACCESS_FS_RESOLVE_UNIX, "resolve_unix"), \
+	_LANDLOCK_NAME_ENTRY(LANDLOCK_ACCESS_FS_READ_METADATA, "read_metadata"), \
+	_LANDLOCK_NAME_ENTRY(LANDLOCK_ACCESS_FS_WRITE_METADATA, "write_metadata")
 
 #define _LANDLOCK_ACCESS_NET_NAMES \
 	_LANDLOCK_NAME_ENTRY(LANDLOCK_ACCESS_NET_BIND_TCP, "bind_tcp"), \
diff --git a/include/linux/lsm_hook_defs.h b/include/linux/lsm_hook_defs.h
index ef16e5343e099..9ea096505ef1f 100644
--- a/include/linux/lsm_hook_defs.h
+++ b/include/linux/lsm_hook_defs.h
@@ -142,33 +142,34 @@ LSM_HOOK(int, 0, inode_follow_link, struct dentry *dentry, struct inode *inode,
 	 bool rcu)
 LSM_HOOK(int, 0, inode_permission, const struct mnt_idmap *idmap,
 	 struct inode *inode, int mask)
-LSM_HOOK(int, 0, inode_setattr, const struct mnt_idmap *idmap, struct dentry *dentry,
+LSM_HOOK(int, 0, path_setattr, const struct path *path,
 	 struct iattr *attr)
 LSM_HOOK(void, LSM_RET_VOID, inode_post_setattr, const struct mnt_idmap *idmap,
 	 struct dentry *dentry, int ia_valid)
-LSM_HOOK(int, 0, inode_getattr, const struct path *path)
+LSM_HOOK(int, 0, path_getattr, const struct path *path)
 LSM_HOOK(int, 0, inode_xattr_skipcap, const char *name)
-LSM_HOOK(int, 0, inode_setxattr, const struct mnt_idmap *idmap,
-	 struct dentry *dentry, const char *name, const void *value,
-	 size_t size, int flags)
+LSM_HOOK(int, 0, path_setxattr, const struct path *path,
+	 const char *name, const void *value, size_t size, int flags)
 LSM_HOOK(void, LSM_RET_VOID, inode_post_setxattr, struct dentry *dentry,
 	 const char *name, const void *value, size_t size, int flags)
-LSM_HOOK(int, 0, inode_getxattr, struct dentry *dentry, const char *name)
-LSM_HOOK(int, 0, inode_listxattr, struct dentry *dentry)
-LSM_HOOK(int, 0, inode_removexattr, const struct mnt_idmap *idmap,
-	 struct dentry *dentry, const char *name)
+LSM_HOOK(int, 0, path_getxattr, const struct path *path, const char *name)
+LSM_HOOK(int, 0, path_listxattr, const struct path *path)
+LSM_HOOK(int, 0, path_removexattr, const struct path *path,
+	 const char *name)
 LSM_HOOK(void, LSM_RET_VOID, inode_post_removexattr, struct dentry *dentry,
 	 const char *name)
-LSM_HOOK(int, 0, inode_file_setattr, struct dentry *dentry, struct file_kattr *fa)
-LSM_HOOK(int, 0, inode_file_getattr, struct dentry *dentry, struct file_kattr *fa)
-LSM_HOOK(int, 0, inode_set_acl, const struct mnt_idmap *idmap,
-	 struct dentry *dentry, const char *acl_name, struct posix_acl *kacl)
+LSM_HOOK(int, 0, path_file_setattr, const struct path *path,
+	 struct file_kattr *fa)
+LSM_HOOK(int, 0, path_file_getattr, const struct path *path,
+	 struct file_kattr *fa)
+LSM_HOOK(int, 0, path_set_acl, const struct path *path,
+	 const char *acl_name, struct posix_acl *kacl)
 LSM_HOOK(void, LSM_RET_VOID, inode_post_set_acl, struct dentry *dentry,
 	 const char *acl_name, struct posix_acl *kacl)
-LSM_HOOK(int, 0, inode_get_acl, const struct mnt_idmap *idmap,
-	 struct dentry *dentry, const char *acl_name)
-LSM_HOOK(int, 0, inode_remove_acl, const struct mnt_idmap *idmap,
-	 struct dentry *dentry, const char *acl_name)
+LSM_HOOK(int, 0, path_get_acl, const struct path *path,
+	 const char *acl_name)
+LSM_HOOK(int, 0, path_remove_acl, const struct path *path,
+	 const char *acl_name)
 LSM_HOOK(void, LSM_RET_VOID, inode_post_remove_acl, const struct mnt_idmap *idmap,
 	 struct dentry *dentry, const char *acl_name)
 LSM_HOOK(int, 0, inode_need_killpriv, struct dentry *dentry)
@@ -314,7 +315,7 @@ LSM_HOOK(int, 0, secctx_to_secid, const char *secdata, u32 seclen, u32 *secid)
 LSM_HOOK(void, LSM_RET_VOID, release_secctx, struct lsm_context *cp)
 LSM_HOOK(void, LSM_RET_VOID, inode_invalidate_secctx, struct inode *inode)
 LSM_HOOK(int, 0, inode_notifysecctx, struct inode *inode, void *ctx, u32 ctxlen)
-LSM_HOOK(int, 0, inode_setsecctx, struct dentry *dentry, void *ctx, u32 ctxlen)
+LSM_HOOK(int, 0, path_setsecctx, const struct path *path, void *ctx, u32 ctxlen)
 LSM_HOOK(int, -EOPNOTSUPP, inode_getsecctx, struct inode *inode,
 	 struct lsm_context *cp)
 
diff --git a/include/linux/posix_acl.h b/include/linux/posix_acl.h
index caf500bed9933..44c23c4e9f946 100644
--- a/include/linux/posix_acl.h
+++ b/include/linux/posix_acl.h
@@ -105,12 +105,11 @@ static inline void cache_no_acl(struct inode *inode)
 	inode->i_default_acl = NULL;
 }
 
-int vfs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
-		const char *acl_name, struct posix_acl *kacl);
-struct posix_acl *vfs_get_acl(const struct mnt_idmap *idmap,
-			      struct dentry *dentry, const char *acl_name);
-int vfs_remove_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
-		   const char *acl_name);
+int vfs_set_acl(const struct path *path, const char *acl_name,
+		struct posix_acl *kacl);
+struct posix_acl *vfs_get_acl(const struct path *path,
+			      const char *acl_name);
+int vfs_remove_acl(const struct path *path, const char *acl_name);
 int posix_acl_listxattr(struct inode *inode, char **buffer,
 			ssize_t *remaining_size);
 #else
@@ -141,22 +140,20 @@ static inline void forget_all_cached_acls(struct inode *inode)
 {
 }
 
-static inline int vfs_set_acl(const struct mnt_idmap *idmap,
-			      struct dentry *dentry, const char *name,
+static inline int vfs_set_acl(const struct path *path, const char *name,
 			      struct posix_acl *acl)
 {
 	return -EOPNOTSUPP;
 }
 
-static inline struct posix_acl *vfs_get_acl(const struct mnt_idmap *idmap,
-					    struct dentry *dentry,
+static inline struct posix_acl *vfs_get_acl(const struct path *path,
 					    const char *acl_name)
 {
 	return ERR_PTR(-EOPNOTSUPP);
 }
 
-static inline int vfs_remove_acl(const struct mnt_idmap *idmap,
-				 struct dentry *dentry, const char *acl_name)
+static inline int vfs_remove_acl(const struct path *path,
+				 const char *acl_name)
 {
 	return -EOPNOTSUPP;
 }
diff --git a/include/linux/security.h b/include/linux/security.h
index 8b8d6b8b802f1..c99a050595c5b 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -185,10 +185,9 @@ extern int cap_capset(struct cred *new, const struct cred *old,
 		      const kernel_cap_t *inheritable,
 		      const kernel_cap_t *permitted);
 extern int cap_bprm_creds_from_file(struct linux_binprm *bprm, const struct file *file);
-int cap_inode_setxattr(struct dentry *dentry, const char *name,
+int cap_inode_setxattr(const struct path *path, const char *name,
 		       const void *value, size_t size, int flags);
-int cap_inode_removexattr(const struct mnt_idmap *idmap,
-			  struct dentry *dentry, const char *name);
+int cap_inode_removexattr(const struct path *path, const char *name);
 int cap_inode_need_killpriv(struct dentry *dentry);
 int cap_inode_killpriv(const struct mnt_idmap *idmap, struct dentry *dentry);
 int cap_inode_getsecurity(const struct mnt_idmap *idmap,
@@ -429,36 +428,32 @@ int security_inode_follow_link(struct dentry *dentry, struct inode *inode,
 			       bool rcu);
 int security_inode_permission(const struct mnt_idmap *idmap, struct inode *inode,
 			      int mask);
-int security_inode_setattr(const struct mnt_idmap *idmap,
-			   struct dentry *dentry, struct iattr *attr);
+int security_path_setattr(const struct path *path, struct iattr *attr);
 void security_inode_post_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
 				 int ia_valid);
-int security_inode_getattr(const struct path *path);
-int security_inode_setxattr(const struct mnt_idmap *idmap,
-			    struct dentry *dentry, const char *name,
-			    const void *value, size_t size, int flags);
-int security_inode_set_acl(const struct mnt_idmap *idmap,
-			   struct dentry *dentry, const char *acl_name,
-			   struct posix_acl *kacl);
+int security_path_getattr(const struct path *path);
+int security_path_setxattr(const struct path *path,
+			    const char *name, const void *value,
+			    size_t size, int flags);
+int security_path_set_acl(const struct path *path,
+			   const char *acl_name, struct posix_acl *kacl);
 void security_inode_post_set_acl(struct dentry *dentry, const char *acl_name,
 				 struct posix_acl *kacl);
-int security_inode_get_acl(const struct mnt_idmap *idmap,
-			   struct dentry *dentry, const char *acl_name);
-int security_inode_remove_acl(const struct mnt_idmap *idmap,
-			      struct dentry *dentry, const char *acl_name);
+int security_path_get_acl(const struct path *path, const char *acl_name);
+int security_path_remove_acl(const struct path *path, const char *acl_name);
 void security_inode_post_remove_acl(const struct mnt_idmap *idmap,
 				    struct dentry *dentry,
 				    const char *acl_name);
 void security_inode_post_setxattr(struct dentry *dentry, const char *name,
 				  const void *value, size_t size, int flags);
-int security_inode_getxattr(struct dentry *dentry, const char *name);
-int security_inode_listxattr(struct dentry *dentry);
-int security_inode_removexattr(const struct mnt_idmap *idmap,
-			       struct dentry *dentry, const char *name);
+int security_path_getxattr(const struct path *path, const char *name);
+int security_path_listxattr(const struct path *path);
+int security_path_removexattr(const struct path *path,
+			       const char *name);
 void security_inode_post_removexattr(struct dentry *dentry, const char *name);
-int security_inode_file_setattr(struct dentry *dentry,
+int security_path_file_setattr(const struct path *path,
 			      struct file_kattr *fa);
-int security_inode_file_getattr(struct dentry *dentry,
+int security_path_file_getattr(const struct path *path,
 			      struct file_kattr *fa);
 int security_inode_need_killpriv(struct dentry *dentry);
 int security_inode_killpriv(const struct mnt_idmap *idmap, struct dentry *dentry);
@@ -589,7 +584,7 @@ int security_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid);
 void security_release_secctx(struct lsm_context *cp);
 void security_inode_invalidate_secctx(struct inode *inode);
 int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen);
-int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen);
+int security_path_setsecctx(const struct path *path, void *ctx, u32 ctxlen);
 int security_inode_getsecctx(struct inode *inode, struct lsm_context *cp);
 int security_locked_down(enum lockdown_reason what);
 int lsm_fill_user_ctx(struct lsm_ctx __user *uctx, u32 *uctx_len,
@@ -1001,8 +996,7 @@ static inline int security_inode_permission(const struct mnt_idmap *idmap,
 	return 0;
 }
 
-static inline int security_inode_setattr(const struct mnt_idmap *idmap,
-					 struct dentry *dentry,
+static inline int security_path_setattr(const struct path *path,
 					 struct iattr *attr)
 {
 	return 0;
@@ -1013,20 +1007,18 @@ security_inode_post_setattr(const struct mnt_idmap *idmap, struct dentry *dentry
 			    int ia_valid)
 { }
 
-static inline int security_inode_getattr(const struct path *path)
+static inline int security_path_getattr(const struct path *path)
 {
 	return 0;
 }
 
-static inline int security_inode_setxattr(const struct mnt_idmap *idmap,
-		struct dentry *dentry, const char *name, const void *value,
-		size_t size, int flags)
+static inline int security_path_setxattr(const struct path *path,
+		const char *name, const void *value, size_t size, int flags)
 {
-	return cap_inode_setxattr(dentry, name, value, size, flags);
+	return cap_inode_setxattr(path, name, value, size, flags);
 }
 
-static inline int security_inode_set_acl(const struct mnt_idmap *idmap,
-					 struct dentry *dentry,
+static inline int security_path_set_acl(const struct path *path,
 					 const char *acl_name,
 					 struct posix_acl *kacl)
 {
@@ -1038,15 +1030,13 @@ static inline void security_inode_post_set_acl(struct dentry *dentry,
 					       struct posix_acl *kacl)
 { }
 
-static inline int security_inode_get_acl(const struct mnt_idmap *idmap,
-					 struct dentry *dentry,
+static inline int security_path_get_acl(const struct path *path,
 					 const char *acl_name)
 {
 	return 0;
 }
 
-static inline int security_inode_remove_acl(const struct mnt_idmap *idmap,
-					    struct dentry *dentry,
+static inline int security_path_remove_acl(const struct path *path,
 					    const char *acl_name)
 {
 	return 0;
@@ -1061,35 +1051,34 @@ static inline void security_inode_post_setxattr(struct dentry *dentry,
 		const char *name, const void *value, size_t size, int flags)
 { }
 
-static inline int security_inode_getxattr(struct dentry *dentry,
+static inline int security_path_getxattr(const struct path *path,
 			const char *name)
 {
 	return 0;
 }
 
-static inline int security_inode_listxattr(struct dentry *dentry)
+static inline int security_path_listxattr(const struct path *path)
 {
 	return 0;
 }
 
-static inline int security_inode_removexattr(const struct mnt_idmap *idmap,
-					     struct dentry *dentry,
+static inline int security_path_removexattr(const struct path *path,
 					     const char *name)
 {
-	return cap_inode_removexattr(idmap, dentry, name);
+	return cap_inode_removexattr(path, name);
 }
 
 static inline void security_inode_post_removexattr(struct dentry *dentry,
 						   const char *name)
 { }
 
-static inline int security_inode_file_setattr(struct dentry *dentry,
+static inline int security_path_file_setattr(const struct path *path,
 					      struct file_kattr *fa)
 {
 	return 0;
 }
 
-static inline int security_inode_file_getattr(struct dentry *dentry,
+static inline int security_path_file_getattr(const struct path *path,
 					      struct file_kattr *fa)
 {
 	return 0;
@@ -1637,7 +1626,7 @@ static inline int security_inode_notifysecctx(struct inode *inode, void *ctx, u3
 {
 	return -EOPNOTSUPP;
 }
-static inline int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen)
+static inline int security_path_setsecctx(const struct path *path, void *ctx, u32 ctxlen)
 {
 	return -EOPNOTSUPP;
 }
diff --git a/include/linux/xattr.h b/include/linux/xattr.h
index 4cc4257de084e..b0c980c7c3361 100644
--- a/include/linux/xattr.h
+++ b/include/linux/xattr.h
@@ -77,22 +77,22 @@ struct xattr {
 };
 
 ssize_t __vfs_getxattr(struct dentry *, struct inode *, const char *, void *, size_t);
-ssize_t vfs_getxattr(const struct mnt_idmap *, struct dentry *, const char *,
-		     void *, size_t);
-ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
+ssize_t vfs_getxattr(const struct path *path, const char *name, void *value,
+		     size_t size);
+ssize_t vfs_listxattr(const struct path *path, char *list, size_t size);
 int __vfs_setxattr(const struct mnt_idmap *, struct dentry *, struct inode *,
 		   const char *, const void *, size_t, int);
 int __vfs_setxattr_noperm(const struct mnt_idmap *, struct dentry *,
 			  const char *, const void *, size_t, int);
-int __vfs_setxattr_locked(const struct mnt_idmap *, struct dentry *,
-			  const char *, const void *, size_t, int,
-			  struct delegated_inode *);
-int vfs_setxattr(const struct mnt_idmap *, struct dentry *, const char *,
-		 const void *, size_t, int);
+int __vfs_setxattr_locked(const struct path *path, const char *name,
+			  const void *value, size_t size, int flags,
+			  struct delegated_inode *delegated_inode);
+int vfs_setxattr(const struct path *path, const char *name,
+		 const void *value, size_t size, int flags);
 int __vfs_removexattr(const struct mnt_idmap *, struct dentry *, const char *);
-int __vfs_removexattr_locked(const struct mnt_idmap *, struct dentry *,
-			     const char *, struct delegated_inode *);
-int vfs_removexattr(const struct mnt_idmap *, struct dentry *, const char *);
+int __vfs_removexattr_locked(const struct path *path, const char *name,
+			     struct delegated_inode *delegated_inode);
+int vfs_removexattr(const struct path *path, const char *name);
 
 ssize_t generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size);
 int vfs_getxattr_alloc(const struct mnt_idmap *idmap,
diff --git a/include/uapi/linux/landlock.h b/include/uapi/linux/landlock.h
index 24510e5d8479a..36dfb499e48e1 100644
--- a/include/uapi/linux/landlock.h
+++ b/include/uapi/linux/landlock.h
@@ -429,6 +429,25 @@ struct landlock_capability_attr {
  *
  *   The rationale for this design is described in
  *   :ref:`Documentation/security/landlock.rst <scoped-flags-interaction>`.
+ * - %LANDLOCK_ACCESS_FS_READ_METADATA: Read file or directory metadata (e.g.
+ *   inode attributes, extended attributes, and POSIX ACLs) through
+ *   :manpage:`stat(2)`, :manpage:`fstat(2)`, :manpage:`lstat(2)`,
+ *   :manpage:`newfstatat(2)`, :manpage:`getxattr(2)`, and
+ *   :manpage:`listxattr(2)`.
+ *
+ *   This access right is available since the thirteenth version of the
+ *   Landlock ABI.
+ * - %LANDLOCK_ACCESS_FS_WRITE_METADATA: Change file or directory metadata
+ *   (e.g. inode attributes, extended attributes, and POSIX ACLs) through
+ *   :manpage:`chmod(2)`, :manpage:`chown(2)`, :manpage:`utimensat(2)`,
+ *   :manpage:`setxattr(2)`, and :manpage:`removexattr(2)`, as well as related
+ *   system calls.  Implicit metadata changes performed by the kernel (e.g.
+ *   timestamp updates with :manpage:`write(2)`, or set-user-ID and
+ *   set-group-ID bit clearing with :manpage:`write(2)` or
+ *   :manpage:`truncate(2)`) are not restricted by this access right.
+ *
+ *   This access right is available since the thirteenth version of the
+ *   Landlock ABI.
  *
  * Whether an opened file can be truncated with :manpage:`ftruncate(2)` or used
  * with `ioctl(2)` is determined during :manpage:`open(2)`, in the same way as
@@ -493,9 +512,7 @@ struct landlock_capability_attr {
  *
  *   It is currently not possible to restrict some file-related actions
  *   accessible through these syscall families: :manpage:`chdir(2)`,
- *   :manpage:`stat(2)`, :manpage:`flock(2)`, :manpage:`chmod(2)`,
- *   :manpage:`chown(2)`, :manpage:`setxattr(2)`, :manpage:`utime(2)`,
- *   :manpage:`fcntl(2)`, :manpage:`access(2)`.
+ *   :manpage:`flock(2)`, :manpage:`fcntl(2)`, :manpage:`access(2)`.
  *   Future Landlock evolutions will enable to restrict them.
  */
 /* clang-format off */
@@ -516,6 +533,8 @@ struct landlock_capability_attr {
 #define LANDLOCK_ACCESS_FS_TRUNCATE			(1ULL << 14)
 #define LANDLOCK_ACCESS_FS_IOCTL_DEV			(1ULL << 15)
 #define LANDLOCK_ACCESS_FS_RESOLVE_UNIX			(1ULL << 16)
+#define LANDLOCK_ACCESS_FS_READ_METADATA		(1ULL << 17)
+#define LANDLOCK_ACCESS_FS_WRITE_METADATA		(1ULL << 18)
 /* clang-format on */
 
 /**
diff --git a/kernel/bpf/bpf_lsm.c b/kernel/bpf/bpf_lsm.c
index f58dce888ff4a..9d77714178127 100644
--- a/kernel/bpf/bpf_lsm.c
+++ b/kernel/bpf/bpf_lsm.c
@@ -335,18 +335,18 @@ BTF_ID(func, bpf_lsm_file_receive)
 
 BTF_ID(func, bpf_lsm_inode_create)
 BTF_ID(func, bpf_lsm_inode_free_security)
-BTF_ID(func, bpf_lsm_inode_getattr)
-BTF_ID(func, bpf_lsm_inode_getxattr)
+BTF_ID(func, bpf_lsm_path_getattr)
+BTF_ID(func, bpf_lsm_path_getxattr)
 BTF_ID(func, bpf_lsm_inode_mknod)
 BTF_ID(func, bpf_lsm_inode_need_killpriv)
 BTF_ID(func, bpf_lsm_inode_post_setxattr)
 BTF_ID(func, bpf_lsm_inode_post_removexattr)
 BTF_ID(func, bpf_lsm_inode_readlink)
-BTF_ID(func, bpf_lsm_inode_removexattr)
+BTF_ID(func, bpf_lsm_path_removexattr)
 BTF_ID(func, bpf_lsm_inode_rename)
 BTF_ID(func, bpf_lsm_inode_rmdir)
-BTF_ID(func, bpf_lsm_inode_setattr)
-BTF_ID(func, bpf_lsm_inode_setxattr)
+BTF_ID(func, bpf_lsm_path_setattr)
+BTF_ID(func, bpf_lsm_path_setxattr)
 BTF_ID(func, bpf_lsm_inode_symlink)
 BTF_ID(func, bpf_lsm_inode_unlink)
 BTF_ID(func, bpf_lsm_kernel_module_request)
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index 195f78db9bdaf..6f36647188429 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -961,7 +961,7 @@ BPF_CALL_3(bpf_d_path, const struct path *, path, char *, buf, u32, sz)
 BTF_SET_START(btf_allowlist_d_path)
 #ifdef CONFIG_SECURITY
 BTF_ID(func, security_file_permission)
-BTF_ID(func, security_inode_getattr)
+BTF_ID(func, security_path_getattr)
 BTF_ID(func, security_file_open)
 #endif
 #ifdef CONFIG_SECURITY_PATH
diff --git a/samples/landlock/sandboxer.c b/samples/landlock/sandboxer.c
index 1362f08ff14b9..29965ef90bed6 100644
--- a/samples/landlock/sandboxer.c
+++ b/samples/landlock/sandboxer.c
@@ -137,6 +137,8 @@ static int parse_path(char *env_path, const char ***const path_list)
 	LANDLOCK_ACCESS_FS_EXECUTE | \
 	LANDLOCK_ACCESS_FS_WRITE_FILE | \
 	LANDLOCK_ACCESS_FS_READ_FILE | \
+	LANDLOCK_ACCESS_FS_READ_METADATA | \
+	LANDLOCK_ACCESS_FS_WRITE_METADATA | \
 	LANDLOCK_ACCESS_FS_TRUNCATE | \
 	LANDLOCK_ACCESS_FS_IOCTL_DEV | \
 	LANDLOCK_ACCESS_FS_RESOLVE_UNIX)
@@ -487,7 +489,8 @@ static bool check_ruleset_scope(const char *const env_var,
 #define ACCESS_FS_ROUGHLY_READ ( \
 	LANDLOCK_ACCESS_FS_EXECUTE | \
 	LANDLOCK_ACCESS_FS_READ_FILE | \
-	LANDLOCK_ACCESS_FS_READ_DIR)
+	LANDLOCK_ACCESS_FS_READ_DIR | \
+	LANDLOCK_ACCESS_FS_READ_METADATA)
 
 #define ACCESS_FS_ROUGHLY_WRITE ( \
 	LANDLOCK_ACCESS_FS_WRITE_FILE | \
@@ -503,7 +506,8 @@ static bool check_ruleset_scope(const char *const env_var,
 	LANDLOCK_ACCESS_FS_REFER | \
 	LANDLOCK_ACCESS_FS_TRUNCATE | \
 	LANDLOCK_ACCESS_FS_IOCTL_DEV | \
-	LANDLOCK_ACCESS_FS_RESOLVE_UNIX)
+	LANDLOCK_ACCESS_FS_RESOLVE_UNIX | \
+	LANDLOCK_ACCESS_FS_WRITE_METADATA)
 
 /* clang-format on */
 
@@ -570,7 +574,7 @@ static int add_quiet_access(const char *const env_var,
 	return 0;
 }
 
-#define LANDLOCK_ABI_LAST 12
+#define LANDLOCK_ABI_LAST 13
 
 #define XSTR(s) #s
 #define STR(s) XSTR(s)
@@ -780,6 +784,12 @@ int main(const int argc, char *const argv[], char *const *const envp)
 		ruleset_attr.handled_permissions &=
 			~(LANDLOCK_PERMISSION_NAMESPACE_USE |
 			  LANDLOCK_PERMISSION_CAPABILITY_USE);
+		__attribute__((fallthrough));
+	case 12:
+		/* Removes metadata rights for ABI < 13 */
+		ruleset_attr.handled_access_fs &=
+			~(LANDLOCK_ACCESS_FS_READ_METADATA |
+			  LANDLOCK_ACCESS_FS_WRITE_METADATA);
 		/* Must be printed for any ABI < LANDLOCK_ABI_LAST. */
 		fprintf(stderr,
 			"Hint: You should update the running kernel "
diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
index 9d572cf8486b2..a2886f6ece786 100644
--- a/security/apparmor/lsm.c
+++ b/security/apparmor/lsm.c
@@ -456,7 +456,7 @@ static int apparmor_path_chown(const struct path *path, kuid_t uid, kgid_t gid)
 	return common_perm_cond(OP_CHOWN, path, AA_MAY_CHOWN);
 }
 
-static int apparmor_inode_getattr(const struct path *path)
+static int apparmor_path_getattr(const struct path *path)
 {
 	return common_perm_cond(OP_GETATTR, path, AA_MAY_GETATTR);
 }
@@ -1785,7 +1785,7 @@ static struct security_hook_list apparmor_hooks[] __ro_after_init = {
 	LSM_HOOK_INIT(path_chmod, apparmor_path_chmod),
 	LSM_HOOK_INIT(path_chown, apparmor_path_chown),
 	LSM_HOOK_INIT(path_truncate, apparmor_path_truncate),
-	LSM_HOOK_INIT(inode_getattr, apparmor_inode_getattr),
+	LSM_HOOK_INIT(path_getattr, apparmor_path_getattr),
 
 	LSM_HOOK_INIT(file_open, apparmor_file_open),
 	LSM_HOOK_INIT(file_receive, apparmor_file_receive),
diff --git a/security/commoncap.c b/security/commoncap.c
index 565c893c6d4b4..971994e9553e6 100644
--- a/security/commoncap.c
+++ b/security/commoncap.c
@@ -14,6 +14,7 @@
 #include <linux/netlink.h>
 #include <linux/ptrace.h>
 #include <linux/xattr.h>
+#include <linux/path.h>
 #include <linux/mount.h>
 #include <linux/sched.h>
 #include <linux/prctl.h>
@@ -1007,7 +1008,7 @@ int cap_bprm_creds_from_file(struct linux_binprm *bprm, const struct file *file)
 
 /**
  * cap_inode_setxattr - Determine whether an xattr may be altered
- * @dentry: The inode/dentry being altered
+ * @path: The inode/path being altered
  * @name: The name of the xattr to be changed
  * @value: The value that the xattr will be changed to
  * @size: The size of value
@@ -1019,9 +1020,10 @@ int cap_bprm_creds_from_file(struct linux_binprm *bprm, const struct file *file)
  * This is used to make sure security xattrs don't get updated or set by those
  * who aren't privileged to do so.
  */
-int cap_inode_setxattr(struct dentry *dentry, const char *name,
+int cap_inode_setxattr(const struct path *path, const char *name,
 		       const void *value, size_t size, int flags)
 {
+	struct dentry *dentry = path->dentry;
 	struct user_namespace *user_ns = dentry->d_sb->s_user_ns;
 
 	/* Ignore non-security xattrs */
@@ -1044,25 +1046,18 @@ int cap_inode_setxattr(struct dentry *dentry, const char *name,
 /**
  * cap_inode_removexattr - Determine whether an xattr may be removed
  *
- * @idmap:	idmap of the mount the inode was found from
- * @dentry:	The inode/dentry being altered
+ * @path:	The inode/path being altered
  * @name:	The name of the xattr to be changed
  *
  * Determine whether an xattr may be removed from an inode, returning 0 if
  * permission is granted, -ve if denied.
  *
- * If the inode has been found through an idmapped mount the idmap of
- * the vfsmount must be passed through @idmap. This function will then
- * take care to map the inode according to @idmap before checking
- * permissions. On non-idmapped mounts or if permission checking is to be
- * performed on the raw inode simply pass @nop_mnt_idmap.
- *
  * This is used to make sure security xattrs don't get removed by those who
  * aren't privileged to remove them.
  */
-int cap_inode_removexattr(const struct mnt_idmap *idmap,
-			  struct dentry *dentry, const char *name)
+int cap_inode_removexattr(const struct path *path, const char *name)
 {
+	struct dentry *dentry = path->dentry;
 	struct user_namespace *user_ns = dentry->d_sb->s_user_ns;
 
 	/* Ignore non-security xattrs */
@@ -1075,7 +1070,8 @@ int cap_inode_removexattr(const struct mnt_idmap *idmap,
 		struct inode *inode = d_backing_inode(dentry);
 		if (!inode)
 			return -EINVAL;
-		if (!capable_wrt_inode_uidgid(idmap, inode, CAP_SETFCAP))
+		if (!capable_wrt_inode_uidgid(mnt_idmap(path->mnt), inode,
+					      CAP_SETFCAP))
 			return -EPERM;
 		return 0;
 	}
diff --git a/security/integrity/evm/evm_crypto.c b/security/integrity/evm/evm_crypto.c
index 1c41af2f91a60..3d759efd3c6c3 100644
--- a/security/integrity/evm/evm_crypto.c
+++ b/security/integrity/evm/evm_crypto.c
@@ -237,7 +237,7 @@ static int evm_calc_hmac_or_hash(struct dentry *dentry,
 	size_t xattr_size = 0;
 	char *xattr_value = NULL;
 	int error;
-	int size, user_space_size;
+	int size;
 	bool ima_present = false;
 	u64 i_version = 0;
 
@@ -287,12 +287,6 @@ static int evm_calc_hmac_or_hash(struct dentry *dentry,
 		if (size < 0)
 			continue;
 
-		user_space_size = vfs_getxattr(&nop_mnt_idmap, dentry,
-					       xattr->name, NULL, 0);
-		if (user_space_size != size)
-			pr_debug("file %s: xattr %s size mismatch (kernel: %d, user: %d)\n",
-				 dentry->d_name.name, xattr->name, size,
-				 user_space_size);
 		error = 0;
 		xattr_size = size;
 		crypto_shash_update(desc, (const u8 *)xattr_value, xattr_size);
diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c
index ac8328812e6ef..5c2ce1d00fb88 100644
--- a/security/integrity/evm/evm_main.c
+++ b/security/integrity/evm/evm_main.c
@@ -7,8 +7,8 @@
  * Kylene Hall <kjhall@us.ibm.com>
  *
  * File: evm_main.c
- *	implements evm_inode_setxattr, evm_inode_post_setxattr,
- *	evm_inode_removexattr, evm_verifyxattr, and evm_inode_set_acl.
+ *	implements evm_path_setxattr, evm_inode_post_setxattr,
+ *	evm_path_removexattr, evm_verifyxattr, and evm_path_set_acl.
  */
 
 #define pr_fmt(fmt) "EVM: "fmt
@@ -593,9 +593,8 @@ static int evm_protect_xattr(const struct mnt_idmap *idmap,
 }
 
 /**
- * evm_inode_setxattr - protect the EVM extended attribute
- * @idmap: idmap of the mount
- * @dentry: pointer to the affected dentry
+ * evm_path_setxattr - protect the EVM extended attribute
+ * @path: pointer to the affected object
  * @xattr_name: pointer to the affected extended attribute name
  * @xattr_value: pointer to the new extended attribute value
  * @xattr_value_len: pointer to the new extended attribute value length
@@ -607,11 +606,13 @@ static int evm_protect_xattr(const struct mnt_idmap *idmap,
  * userspace from writing HMAC value.  Writing 'security.evm' requires
  * requires CAP_SYS_ADMIN privileges.
  */
-static int evm_inode_setxattr(const struct mnt_idmap *idmap, struct dentry *dentry,
+static int evm_path_setxattr(const struct path *path,
 			      const char *xattr_name, const void *xattr_value,
 			      size_t xattr_value_len, int flags)
 {
 	const struct evm_ima_xattr_data *xattr_data = xattr_value;
+	struct dentry *dentry = path->dentry;
+	const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
 
 	/* Policy permits modification of the protected xattrs even though
 	 * there's no HMAC key loaded
@@ -631,17 +632,19 @@ static int evm_inode_setxattr(const struct mnt_idmap *idmap, struct dentry *dent
 }
 
 /**
- * evm_inode_removexattr - protect the EVM extended attribute
- * @idmap: idmap of the mount
- * @dentry: pointer to the affected dentry
+ * evm_path_removexattr - protect the EVM extended attribute
+ * @path: pointer to the affected object
  * @xattr_name: pointer to the affected extended attribute name
  *
  * Removing 'security.evm' requires CAP_SYS_ADMIN privileges and that
  * the current value is valid.
  */
-static int evm_inode_removexattr(const struct mnt_idmap *idmap, struct dentry *dentry,
+static int evm_path_removexattr(const struct path *path,
 				 const char *xattr_name)
 {
+	struct dentry *dentry = path->dentry;
+	const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
+
 	/* Policy permits modification of the protected xattrs even though
 	 * there's no HMAC key loaded
 	 */
@@ -681,9 +684,8 @@ static inline int evm_inode_set_acl_change(const struct mnt_idmap *idmap,
 #endif
 
 /**
- * evm_inode_set_acl - protect the EVM extended attribute from posix acls
- * @idmap: idmap of the idmapped mount
- * @dentry: pointer to the affected dentry
+ * evm_path_set_acl - protect the EVM extended attribute from posix acls
+ * @path: pointer to the affected object
  * @acl_name: name of the posix acl
  * @kacl: pointer to the posix acls
  *
@@ -693,10 +695,12 @@ static inline int evm_inode_set_acl_change(const struct mnt_idmap *idmap,
  *
  * Return: zero on success, -EPERM on failure.
  */
-static int evm_inode_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
+static int evm_path_set_acl(const struct path *path,
 			     const char *acl_name, struct posix_acl *kacl)
 {
 	enum integrity_status evm_status;
+	struct dentry *dentry = path->dentry;
+	const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
 
 	/* Policy permits modification of the protected xattrs even though
 	 * there's no HMAC key loaded
@@ -734,9 +738,8 @@ static int evm_inode_set_acl(const struct mnt_idmap *idmap, struct dentry *dentr
 }
 
 /**
- * evm_inode_remove_acl - Protect the EVM extended attribute from posix acls
- * @idmap: idmap of the mount
- * @dentry: pointer to the affected dentry
+ * evm_path_remove_acl - Protect the EVM extended attribute from posix acls
+ * @path: pointer to the affected object
  * @acl_name: name of the posix acl
  *
  * Prevent removing posix acls causing the EVM HMAC to be re-calculated
@@ -745,10 +748,10 @@ static int evm_inode_set_acl(const struct mnt_idmap *idmap, struct dentry *dentr
  *
  * Return: zero on success, -EPERM on failure.
  */
-static int evm_inode_remove_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
+static int evm_path_remove_acl(const struct path *path,
 				const char *acl_name)
 {
-	return evm_inode_set_acl(idmap, dentry, acl_name, NULL);
+	return evm_path_set_acl(path, acl_name, NULL);
 }
 
 static void evm_reset_status(struct inode *inode)
@@ -948,19 +951,20 @@ static int evm_attr_change(const struct mnt_idmap *idmap,
 }
 
 /**
- * evm_inode_setattr - prevent updating an invalid EVM extended attribute
- * @idmap: idmap of the mount
- * @dentry: pointer to the affected dentry
+ * evm_path_setattr - prevent updating an invalid EVM extended attribute
+ * @path: pointer to the affected object
  * @attr: iattr structure containing the new file attributes
  *
  * Permit update of file attributes when files have a valid EVM signature,
  * except in the case of them having an immutable portable signature.
  */
-static int evm_inode_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
+static int evm_path_setattr(const struct path *path,
 			     struct iattr *attr)
 {
 	unsigned int ia_valid = attr->ia_valid;
 	enum integrity_status evm_status;
+	struct dentry *dentry = path->dentry;
+	const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
 
 	/* Policy permits modification of the protected attrs even though
 	 * there's no HMAC key loaded
@@ -1195,16 +1199,16 @@ static int __init init_evm(void)
 }
 
 static struct security_hook_list evm_hooks[] __ro_after_init = {
-	LSM_HOOK_INIT(inode_setattr, evm_inode_setattr),
+	LSM_HOOK_INIT(path_setattr, evm_path_setattr),
 	LSM_HOOK_INIT(inode_post_setattr, evm_inode_post_setattr),
 	LSM_HOOK_INIT(inode_copy_up_xattr, evm_inode_copy_up_xattr),
-	LSM_HOOK_INIT(inode_setxattr, evm_inode_setxattr),
+	LSM_HOOK_INIT(path_setxattr, evm_path_setxattr),
 	LSM_HOOK_INIT(inode_post_setxattr, evm_inode_post_setxattr),
-	LSM_HOOK_INIT(inode_set_acl, evm_inode_set_acl),
+	LSM_HOOK_INIT(path_set_acl, evm_path_set_acl),
 	LSM_HOOK_INIT(inode_post_set_acl, evm_inode_post_set_acl),
-	LSM_HOOK_INIT(inode_remove_acl, evm_inode_remove_acl),
+	LSM_HOOK_INIT(path_remove_acl, evm_path_remove_acl),
 	LSM_HOOK_INIT(inode_post_remove_acl, evm_inode_post_remove_acl),
-	LSM_HOOK_INIT(inode_removexattr, evm_inode_removexattr),
+	LSM_HOOK_INIT(path_removexattr, evm_path_removexattr),
 	LSM_HOOK_INIT(inode_post_removexattr, evm_inode_post_removexattr),
 	LSM_HOOK_INIT(inode_init_security, evm_inode_init_security),
 	LSM_HOOK_INIT(inode_alloc_security, evm_inode_alloc_security),
diff --git a/security/integrity/ima/ima_appraise.c b/security/integrity/ima/ima_appraise.c
index 134174d2e3f0e..f5068f881a245 100644
--- a/security/integrity/ima/ima_appraise.c
+++ b/security/integrity/ima/ima_appraise.c
@@ -759,11 +759,12 @@ static int validate_hash_algo(struct dentry *dentry,
 	return -EACCES;
 }
 
-static int ima_inode_setxattr(const struct mnt_idmap *idmap, struct dentry *dentry,
+static int ima_path_setxattr(const struct path *path,
 			      const char *xattr_name, const void *xattr_value,
 			      size_t xattr_value_len, int flags)
 {
 	const struct evm_ima_xattr_data *xvalue = xattr_value;
+	struct dentry *dentry = path->dentry;
 	int digsig = 0;
 	int result;
 	int err;
@@ -792,43 +793,43 @@ static int ima_inode_setxattr(const struct mnt_idmap *idmap, struct dentry *dent
 	return result;
 }
 
-static int ima_inode_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
+static int ima_path_set_acl(const struct path *path,
 			     const char *acl_name, struct posix_acl *kacl)
 {
 	if (evm_revalidate_status(acl_name))
-		ima_reset_appraise_flags(d_backing_inode(dentry), -1);
+		ima_reset_appraise_flags(d_backing_inode(path->dentry), -1);
 
 	return 0;
 }
 
-static int ima_inode_removexattr(const struct mnt_idmap *idmap, struct dentry *dentry,
+static int ima_path_removexattr(const struct path *path,
 				 const char *xattr_name)
 {
 	int result, digsig = -1;
 
-	result = ima_protect_xattr(dentry, xattr_name, NULL, 0);
+	result = ima_protect_xattr(path->dentry, xattr_name, NULL, 0);
 	if (result == 1 || evm_revalidate_status(xattr_name)) {
 		if (!strcmp(xattr_name, XATTR_NAME_IMA))
 			digsig = 0;
-		ima_reset_appraise_flags(d_backing_inode(dentry), digsig);
+		ima_reset_appraise_flags(d_backing_inode(path->dentry), digsig);
 		if (result == 1)
 			result = 0;
 	}
 	return result;
 }
 
-static int ima_inode_remove_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
+static int ima_path_remove_acl(const struct path *path,
 				const char *acl_name)
 {
-	return ima_inode_set_acl(idmap, dentry, acl_name, NULL);
+	return ima_path_set_acl(path, acl_name, NULL);
 }
 
 static struct security_hook_list ima_appraise_hooks[] __ro_after_init = {
 	LSM_HOOK_INIT(inode_post_setattr, ima_inode_post_setattr),
-	LSM_HOOK_INIT(inode_setxattr, ima_inode_setxattr),
-	LSM_HOOK_INIT(inode_set_acl, ima_inode_set_acl),
-	LSM_HOOK_INIT(inode_removexattr, ima_inode_removexattr),
-	LSM_HOOK_INIT(inode_remove_acl, ima_inode_remove_acl),
+	LSM_HOOK_INIT(path_setxattr, ima_path_setxattr),
+	LSM_HOOK_INIT(path_set_acl, ima_path_set_acl),
+	LSM_HOOK_INIT(path_removexattr, ima_path_removexattr),
+	LSM_HOOK_INIT(path_remove_acl, ima_path_remove_acl),
 };
 
 void __init init_ima_appraise_lsm(const struct lsm_id *lsmid)
diff --git a/security/landlock/fs.c b/security/landlock/fs.c
index a8fa8f77e775d..1bca7558ea9f9 100644
--- a/security/landlock/fs.c
+++ b/security/landlock/fs.c
@@ -318,6 +318,8 @@ static struct landlock_object *get_inode_object(struct inode *const inode)
 	LANDLOCK_ACCESS_FS_EXECUTE | \
 	LANDLOCK_ACCESS_FS_WRITE_FILE | \
 	LANDLOCK_ACCESS_FS_READ_FILE | \
+	LANDLOCK_ACCESS_FS_READ_METADATA | \
+	LANDLOCK_ACCESS_FS_WRITE_METADATA | \
 	LANDLOCK_ACCESS_FS_TRUNCATE | \
 	LANDLOCK_ACCESS_FS_IOCTL_DEV | \
 	LANDLOCK_ACCESS_FS_RESOLVE_UNIX)
@@ -1676,6 +1678,119 @@ static int hook_path_truncate(const struct path *const path)
 	return current_check_access_path(path, LANDLOCK_ACCESS_FS_TRUNCATE);
 }
 
+static int hook_path_getattr(const struct path *const path)
+{
+	return current_check_access_path(path,
+					LANDLOCK_ACCESS_FS_READ_METADATA);
+}
+
+static int hook_path_file_getattr(const struct path *const path,
+				   struct file_kattr *const fa)
+{
+	return current_check_access_path(path,
+					LANDLOCK_ACCESS_FS_READ_METADATA);
+}
+
+static int hook_path_setattr(const struct path *const path,
+			      struct iattr *const attr)
+{
+	unsigned int ia_valid = attr->ia_valid;
+
+	/*
+	 * Only explicit metadata changes are checked: implicit
+	 * timestamp updates never go through notify_change(), and size
+	 * changes (ATTR_SIZE) are governed by the truncate hooks
+	 * instead.  See the "File metadata" section in the user space
+	 * documentation for the full semantics.
+	 *
+	 * Clearing the setuid and setgid bits on write(2) or
+	 * truncate(2) is also an implicit change: callers request it
+	 * with ATTR_KILL_S[UG]ID, and do_notify_change() then adds a
+	 * synthesized ATTR_MODE (with these bits removed) before
+	 * calling this hook.  As do_notify_change() makes it a bug for
+	 * callers to pass ATTR_MODE together with a kill flag, an
+	 * ATTR_MODE seen along with ATTR_KILL_S[UG]ID is always
+	 * kernel-synthesized and must not be checked.  An explicit
+	 * chmod(2) never sets a kill flag, and an explicit chown(2) on
+	 * a privileged file is still checked thanks to ATTR_UID and
+	 * ATTR_GID.
+	 */
+	if (ia_valid & (ATTR_KILL_SUID | ATTR_KILL_SGID))
+		ia_valid &= ~ATTR_MODE;
+
+	if (!(ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID |
+			  ATTR_TIMES_SET | ATTR_TOUCH)))
+		return 0;
+
+	return current_check_access_path(path,
+					LANDLOCK_ACCESS_FS_WRITE_METADATA);
+}
+
+static int hook_path_file_setattr(const struct path *const path,
+				   struct file_kattr *const fa)
+{
+	/*
+	 * The chattr(2) style flags (e.g. FS_IMMUTABLE_FL) and fsxattr
+	 * fields are metadata: writing them requires WRITE_METADATA.  The
+	 * user-facing path is checked here; stacking filesystems skip this
+	 * hook on their internal forwards because they were already
+	 * checked on the user-facing path.
+	 */
+	return current_check_access_path(path,
+					LANDLOCK_ACCESS_FS_WRITE_METADATA);
+}
+
+static int hook_path_setxattr(const struct path *const path,
+			       const char *const name,
+			       const void *const value, const size_t size,
+			       const int flags)
+{
+	return current_check_access_path(path,
+					LANDLOCK_ACCESS_FS_WRITE_METADATA);
+}
+
+static int hook_path_getxattr(const struct path *const path,
+			       const char *const name)
+{
+	return current_check_access_path(path,
+					LANDLOCK_ACCESS_FS_READ_METADATA);
+}
+
+static int hook_path_listxattr(const struct path *const path)
+{
+	return current_check_access_path(path,
+					LANDLOCK_ACCESS_FS_READ_METADATA);
+}
+
+static int hook_path_removexattr(const struct path *const path,
+				  const char *const name)
+{
+	return current_check_access_path(path,
+					LANDLOCK_ACCESS_FS_WRITE_METADATA);
+}
+
+static int hook_path_set_acl(const struct path *const path,
+			      const char *const acl_name,
+			      struct posix_acl *const kacl)
+{
+	return current_check_access_path(path,
+					LANDLOCK_ACCESS_FS_WRITE_METADATA);
+}
+
+static int hook_path_get_acl(const struct path *const path,
+			      const char *const acl_name)
+{
+	return current_check_access_path(path,
+					LANDLOCK_ACCESS_FS_READ_METADATA);
+}
+
+static int hook_path_remove_acl(const struct path *const path,
+				 const char *const acl_name)
+{
+	return current_check_access_path(path,
+					LANDLOCK_ACCESS_FS_WRITE_METADATA);
+}
+
 /**
  * unmask_scoped_access - Remove access right bits in @masks in all layers
  *                        where @client and @server have the same domain
@@ -2100,6 +2215,17 @@ static struct security_hook_list landlock_hooks[] __ro_after_init = {
 	LSM_HOOK_INIT(path_unlink, hook_path_unlink),
 	LSM_HOOK_INIT(path_rmdir, hook_path_rmdir),
 	LSM_HOOK_INIT(path_truncate, hook_path_truncate),
+	LSM_HOOK_INIT(path_getattr, hook_path_getattr),
+	LSM_HOOK_INIT(path_file_getattr, hook_path_file_getattr),
+	LSM_HOOK_INIT(path_setattr, hook_path_setattr),
+	LSM_HOOK_INIT(path_file_setattr, hook_path_file_setattr),
+	LSM_HOOK_INIT(path_setxattr, hook_path_setxattr),
+	LSM_HOOK_INIT(path_getxattr, hook_path_getxattr),
+	LSM_HOOK_INIT(path_listxattr, hook_path_listxattr),
+	LSM_HOOK_INIT(path_removexattr, hook_path_removexattr),
+	LSM_HOOK_INIT(path_set_acl, hook_path_set_acl),
+	LSM_HOOK_INIT(path_get_acl, hook_path_get_acl),
+	LSM_HOOK_INIT(path_remove_acl, hook_path_remove_acl),
 	LSM_HOOK_INIT(unix_find, hook_unix_find),
 
 	LSM_HOOK_INIT(file_alloc_security, hook_file_alloc_security),
diff --git a/security/landlock/limits.h b/security/landlock/limits.h
index ddd300e10689f..ed606ee3102f4 100644
--- a/security/landlock/limits.h
+++ b/security/landlock/limits.h
@@ -21,7 +21,7 @@
 #define LANDLOCK_MAX_NUM_LAYERS		16
 #define LANDLOCK_MAX_NUM_RULES		U32_MAX
 
-#define LANDLOCK_LAST_ACCESS_FS		LANDLOCK_ACCESS_FS_RESOLVE_UNIX
+#define LANDLOCK_LAST_ACCESS_FS		LANDLOCK_ACCESS_FS_WRITE_METADATA
 #define LANDLOCK_MASK_ACCESS_FS		((LANDLOCK_LAST_ACCESS_FS << 1) - 1)
 #define LANDLOCK_NUM_ACCESS_FS		__const_hweight64(LANDLOCK_MASK_ACCESS_FS)
 
diff --git a/security/landlock/syscalls.c b/security/landlock/syscalls.c
index fb5af318b69bb..11d3a2abcec13 100644
--- a/security/landlock/syscalls.c
+++ b/security/landlock/syscalls.c
@@ -191,7 +191,7 @@ static const struct file_operations ruleset_fops = {
  * If the change involves a fix that requires userspace awareness, also update
  * the errata documentation in Documentation/userspace-api/landlock.rst .
  */
-const int landlock_abi_version = 12;
+const int landlock_abi_version = 13;
 
 /**
  * sys_landlock_create_ruleset - Create a new ruleset
diff --git a/security/security.c b/security/security.c
index da8d48cd0a2a4..7c17300989b67 100644
--- a/security/security.c
+++ b/security/security.c
@@ -1890,9 +1890,8 @@ int security_inode_permission(const struct mnt_idmap *idmap, struct inode *inode
 }
 
 /**
- * security_inode_setattr() - Check if setting file attributes is allowed
- * @idmap: idmap of the mount
- * @dentry: file
+ * security_path_setattr() - Check if setting file attributes is allowed
+ * @path: file
  * @attr: new attributes
  *
  * Check permission before setting file attributes.  Note that the kernel call
@@ -1902,14 +1901,13 @@ int security_inode_permission(const struct mnt_idmap *idmap, struct inode *inode
  *
  * Return: Returns 0 if permission is granted.
  */
-int security_inode_setattr(const struct mnt_idmap *idmap,
-			   struct dentry *dentry, struct iattr *attr)
+int security_path_setattr(const struct path *path, struct iattr *attr)
 {
-	if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
+	if (unlikely(IS_PRIVATE(d_backing_inode(path->dentry))))
 		return 0;
-	return call_int_hook(inode_setattr, idmap, dentry, attr);
+	return call_int_hook(path_setattr, path, attr);
 }
-EXPORT_SYMBOL_GPL(security_inode_setattr);
+EXPORT_SYMBOL_GPL(security_path_setattr);
 
 /**
  * security_inode_post_setattr() - Update the inode after a setattr operation
@@ -1928,31 +1926,30 @@ void security_inode_post_setattr(const struct mnt_idmap *idmap, struct dentry *d
 }
 
 /**
- * security_inode_getattr() - Check if getting file attributes is allowed
+ * security_path_getattr() - Check if getting file attributes is allowed
  * @path: file
  *
  * Check permission before obtaining file attributes.
  *
  * Return: Returns 0 if permission is granted.
  */
-int security_inode_getattr(const struct path *path)
+int security_path_getattr(const struct path *path)
 {
 	if (unlikely(IS_PRIVATE(d_backing_inode(path->dentry))))
 		return 0;
-	return call_int_hook(inode_getattr, path);
+	return call_int_hook(path_getattr, path);
 }
 
 /**
- * security_inode_setxattr() - Check if setting file xattrs is allowed
- * @idmap: idmap of the mount
- * @dentry: file
+ * security_path_setxattr() - Check if setting file xattrs is allowed
+ * @path: file
  * @name: xattr name
  * @value: xattr value
  * @size: size of xattr value
  * @flags: flags
  *
  * This hook performs the desired permission checks before setting the extended
- * attributes (xattrs) on @dentry.  It is important to note that we have some
+ * attributes (xattrs) on @path.  It is important to note that we have some
  * additional logic before the main LSM implementation calls to detect if we
  * need to perform an additional capability check at the LSM layer.
  *
@@ -1968,30 +1965,29 @@ int security_inode_getattr(const struct path *path)
  *
  * Return: Returns 0 if permission is granted.
  */
-int security_inode_setxattr(const struct mnt_idmap *idmap,
-			    struct dentry *dentry, const char *name,
-			    const void *value, size_t size, int flags)
+int security_path_setxattr(const struct path *path,
+			    const char *name, const void *value,
+			    size_t size, int flags)
 {
 	int rc;
 
-	if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
+	if (unlikely(IS_PRIVATE(d_backing_inode(path->dentry))))
 		return 0;
 
 	/* enforce the capability checks at the lsm layer, if needed */
 	if (!call_int_hook(inode_xattr_skipcap, name)) {
-		rc = cap_inode_setxattr(dentry, name, value, size, flags);
+		rc = cap_inode_setxattr(path, name, value, size, flags);
 		if (rc)
 			return rc;
 	}
 
-	return call_int_hook(inode_setxattr, idmap, dentry, name, value, size,
+	return call_int_hook(path_setxattr, path, name, value, size,
 			     flags);
 }
 
 /**
- * security_inode_set_acl() - Check if setting posix acls is allowed
- * @idmap: idmap of the mount
- * @dentry: file
+ * security_path_set_acl() - Check if setting posix acls is allowed
+ * @path: file
  * @acl_name: acl name
  * @kacl: acl struct
  *
@@ -2000,13 +1996,12 @@ int security_inode_setxattr(const struct mnt_idmap *idmap,
  *
  * Return: Returns 0 if permission is granted.
  */
-int security_inode_set_acl(const struct mnt_idmap *idmap,
-			   struct dentry *dentry, const char *acl_name,
-			   struct posix_acl *kacl)
+int security_path_set_acl(const struct path *path,
+			   const char *acl_name, struct posix_acl *kacl)
 {
-	if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
+	if (unlikely(IS_PRIVATE(d_backing_inode(path->dentry))))
 		return 0;
-	return call_int_hook(inode_set_acl, idmap, dentry, acl_name, kacl);
+	return call_int_hook(path_set_acl, path, acl_name, kacl);
 }
 
 /**
@@ -2027,9 +2022,8 @@ void security_inode_post_set_acl(struct dentry *dentry, const char *acl_name,
 }
 
 /**
- * security_inode_get_acl() - Check if reading posix acls is allowed
- * @idmap: idmap of the mount
- * @dentry: file
+ * security_path_get_acl() - Check if reading posix acls is allowed
+ * @path: file
  * @acl_name: acl name
  *
  * Check permission before getting osix acls, the posix acls are identified by
@@ -2037,18 +2031,16 @@ void security_inode_post_set_acl(struct dentry *dentry, const char *acl_name,
  *
  * Return: Returns 0 if permission is granted.
  */
-int security_inode_get_acl(const struct mnt_idmap *idmap,
-			   struct dentry *dentry, const char *acl_name)
+int security_path_get_acl(const struct path *path, const char *acl_name)
 {
-	if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
+	if (unlikely(IS_PRIVATE(d_backing_inode(path->dentry))))
 		return 0;
-	return call_int_hook(inode_get_acl, idmap, dentry, acl_name);
+	return call_int_hook(path_get_acl, path, acl_name);
 }
 
 /**
- * security_inode_remove_acl() - Check if removing a posix acl is allowed
- * @idmap: idmap of the mount
- * @dentry: file
+ * security_path_remove_acl() - Check if removing a posix acl is allowed
+ * @path: file
  * @acl_name: acl name
  *
  * Check permission before removing posix acls, the posix acls are identified
@@ -2056,12 +2048,11 @@ int security_inode_get_acl(const struct mnt_idmap *idmap,
  *
  * Return: Returns 0 if permission is granted.
  */
-int security_inode_remove_acl(const struct mnt_idmap *idmap,
-			      struct dentry *dentry, const char *acl_name)
+int security_path_remove_acl(const struct path *path, const char *acl_name)
 {
-	if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
+	if (unlikely(IS_PRIVATE(d_backing_inode(path->dentry))))
 		return 0;
-	return call_int_hook(inode_remove_acl, idmap, dentry, acl_name);
+	return call_int_hook(path_remove_acl, path, acl_name);
 }
 
 /**
@@ -2100,46 +2091,45 @@ void security_inode_post_setxattr(struct dentry *dentry, const char *name,
 }
 
 /**
- * security_inode_getxattr() - Check if xattr access is allowed
- * @dentry: file
+ * security_path_getxattr() - Check if xattr access is allowed
+ * @path: file
  * @name: xattr name
  *
  * Check permission before obtaining the extended attributes identified by
- * @name for @dentry.
+ * @name for @path.
  *
  * Return: Returns 0 if permission is granted.
  */
-int security_inode_getxattr(struct dentry *dentry, const char *name)
+int security_path_getxattr(const struct path *path, const char *name)
 {
-	if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
+	if (unlikely(IS_PRIVATE(d_backing_inode(path->dentry))))
 		return 0;
-	return call_int_hook(inode_getxattr, dentry, name);
+	return call_int_hook(path_getxattr, path, name);
 }
 
 /**
- * security_inode_listxattr() - Check if listing xattrs is allowed
- * @dentry: file
+ * security_path_listxattr() - Check if listing xattrs is allowed
+ * @path: file
  *
  * Check permission before obtaining the list of extended attribute names for
- * @dentry.
+ * @path.
  *
  * Return: Returns 0 if permission is granted.
  */
-int security_inode_listxattr(struct dentry *dentry)
+int security_path_listxattr(const struct path *path)
 {
-	if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
+	if (unlikely(IS_PRIVATE(d_backing_inode(path->dentry))))
 		return 0;
-	return call_int_hook(inode_listxattr, dentry);
+	return call_int_hook(path_listxattr, path);
 }
 
 /**
- * security_inode_removexattr() - Check if removing an xattr is allowed
- * @idmap: idmap of the mount
- * @dentry: file
+ * security_path_removexattr() - Check if removing an xattr is allowed
+ * @path: file
  * @name: xattr name
  *
  * This hook performs the desired permission checks before setting the extended
- * attributes (xattrs) on @dentry.  It is important to note that we have some
+ * attributes (xattrs) on @path.  It is important to note that we have some
  * additional logic before the main LSM implementation calls to detect if we
  * need to perform an additional capability check at the LSM layer.
  *
@@ -2155,22 +2145,21 @@ int security_inode_listxattr(struct dentry *dentry)
  *
  * Return: Returns 0 if permission is granted.
  */
-int security_inode_removexattr(const struct mnt_idmap *idmap,
-			       struct dentry *dentry, const char *name)
+int security_path_removexattr(const struct path *path, const char *name)
 {
 	int rc;
 
-	if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
+	if (unlikely(IS_PRIVATE(d_backing_inode(path->dentry))))
 		return 0;
 
 	/* enforce the capability checks at the lsm layer, if needed */
 	if (!call_int_hook(inode_xattr_skipcap, name)) {
-		rc = cap_inode_removexattr(idmap, dentry, name);
+		rc = cap_inode_removexattr(path, name);
 		if (rc)
 			return rc;
 	}
 
-	return call_int_hook(inode_removexattr, idmap, dentry, name);
+	return call_int_hook(path_removexattr, path, name);
 }
 
 /**
@@ -2188,8 +2177,8 @@ void security_inode_post_removexattr(struct dentry *dentry, const char *name)
 }
 
 /**
- * security_inode_file_setattr() - check if setting fsxattr is allowed
- * @dentry: file to set filesystem extended attributes on
+ * security_path_file_setattr() - check if setting fsxattr is allowed
+ * @path: file to set filesystem extended attributes on
  * @fa: extended attributes to set on the inode
  *
  * Called when file_setattr() syscall or FS_IOC_FSSETXATTR ioctl() is called on
@@ -2197,14 +2186,14 @@ void security_inode_post_removexattr(struct dentry *dentry, const char *name)
  *
  * Return: Returns 0 if permission is granted.
  */
-int security_inode_file_setattr(struct dentry *dentry, struct file_kattr *fa)
+int security_path_file_setattr(const struct path *path, struct file_kattr *fa)
 {
-	return call_int_hook(inode_file_setattr, dentry, fa);
+	return call_int_hook(path_file_setattr, path, fa);
 }
 
 /**
- * security_inode_file_getattr() - check if retrieving fsxattr is allowed
- * @dentry: file to retrieve filesystem extended attributes from
+ * security_path_file_getattr() - check if retrieving fsxattr is allowed
+ * @path: file to retrieve filesystem extended attributes from
  * @fa: extended attributes to get
  *
  * Called when file_getattr() syscall or FS_IOC_FSGETXATTR ioctl() is called on
@@ -2212,9 +2201,9 @@ int security_inode_file_setattr(struct dentry *dentry, struct file_kattr *fa)
  *
  * Return: Returns 0 if permission is granted.
  */
-int security_inode_file_getattr(struct dentry *dentry, struct file_kattr *fa)
+int security_path_file_getattr(const struct path *path, struct file_kattr *fa)
 {
-	return call_int_hook(inode_file_getattr, dentry, fa);
+	return call_int_hook(path_file_getattr, path, fa);
 }
 
 /**
@@ -4133,8 +4122,8 @@ int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen)
 EXPORT_SYMBOL(security_inode_notifysecctx);
 
 /**
- * security_inode_setsecctx() - Change the security label of an inode
- * @dentry: inode
+ * security_path_setsecctx() - Change the security label of an inode
+ * @path: inode
  * @ctx: secctx
  * @ctxlen: length of secctx
  *
@@ -4148,11 +4137,11 @@ EXPORT_SYMBOL(security_inode_notifysecctx);
  *
  * Return: Returns 0 on success, error on failure.
  */
-int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen)
+int security_path_setsecctx(const struct path *path, void *ctx, u32 ctxlen)
 {
-	return call_int_hook(inode_setsecctx, dentry, ctx, ctxlen);
+	return call_int_hook(path_setsecctx, path, ctx, ctxlen);
 }
-EXPORT_SYMBOL(security_inode_setsecctx);
+EXPORT_SYMBOL(security_path_setsecctx);
 
 /**
  * security_inode_getsecctx() - Get the security label of an inode
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 51454c411a038..81b7be7181e79 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -3346,10 +3346,11 @@ static int selinux_inode_permission(const struct mnt_idmap *idmap,
 	return rc;
 }
 
-static int selinux_inode_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
+static int selinux_path_setattr(const struct path *path,
 				 struct iattr *iattr)
 {
 	const struct cred *cred = current_cred();
+	struct dentry *dentry = path->dentry;
 	struct inode *inode = d_backing_inode(dentry);
 	unsigned int ia_valid = iattr->ia_valid;
 	u32 av = FILE__WRITE;
@@ -3375,7 +3376,7 @@ static int selinux_inode_setattr(const struct mnt_idmap *idmap, struct dentry *d
 	return dentry_has_perm(cred, dentry, av);
 }
 
-static int selinux_inode_getattr(const struct path *path)
+static int selinux_path_getattr(const struct path *path)
 {
 	struct task_security_struct *tsec;
 
@@ -3416,10 +3417,12 @@ static int selinux_inode_xattr_skipcap(const char *name)
 	return !strcmp(name, XATTR_NAME_SELINUX);
 }
 
-static int selinux_inode_setxattr(const struct mnt_idmap *idmap,
-				  struct dentry *dentry, const char *name,
-				  const void *value, size_t size, int flags)
+static int selinux_path_setxattr(const struct path *path,
+				  const char *name, const void *value,
+				  size_t size, int flags)
 {
+	struct dentry *dentry = path->dentry;
+	const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
 	struct inode *inode = d_backing_inode(dentry);
 	struct inode_security_struct *isec;
 	struct superblock_security_struct *sbsec;
@@ -3502,23 +3505,22 @@ static int selinux_inode_setxattr(const struct mnt_idmap *idmap,
 			    &ad);
 }
 
-static int selinux_inode_set_acl(const struct mnt_idmap *idmap,
-				 struct dentry *dentry, const char *acl_name,
-				 struct posix_acl *kacl)
+static int selinux_path_set_acl(const struct path *path,
+				 const char *acl_name, struct posix_acl *kacl)
 {
-	return dentry_has_perm(current_cred(), dentry, FILE__SETATTR);
+	return dentry_has_perm(current_cred(), path->dentry, FILE__SETATTR);
 }
 
-static int selinux_inode_get_acl(const struct mnt_idmap *idmap,
-				 struct dentry *dentry, const char *acl_name)
+static int selinux_path_get_acl(const struct path *path,
+				 const char *acl_name)
 {
-	return dentry_has_perm(current_cred(), dentry, FILE__GETATTR);
+	return dentry_has_perm(current_cred(), path->dentry, FILE__GETATTR);
 }
 
-static int selinux_inode_remove_acl(const struct mnt_idmap *idmap,
-				    struct dentry *dentry, const char *acl_name)
+static int selinux_path_remove_acl(const struct path *path,
+				    const char *acl_name)
 {
-	return dentry_has_perm(current_cred(), dentry, FILE__SETATTR);
+	return dentry_has_perm(current_cred(), path->dentry, FILE__SETATTR);
 }
 
 static void selinux_inode_post_setxattr(struct dentry *dentry, const char *name,
@@ -3561,26 +3563,27 @@ static void selinux_inode_post_setxattr(struct dentry *dentry, const char *name,
 	spin_unlock(&isec->lock);
 }
 
-static int selinux_inode_getxattr(struct dentry *dentry, const char *name)
+static int selinux_path_getxattr(const struct path *path, const char *name)
 {
 	const struct cred *cred = current_cred();
 
-	return dentry_has_perm(cred, dentry, FILE__GETATTR);
+	return dentry_has_perm(cred, path->dentry, FILE__GETATTR);
 }
 
-static int selinux_inode_listxattr(struct dentry *dentry)
+static int selinux_path_listxattr(const struct path *path)
 {
 	const struct cred *cred = current_cred();
 
-	return dentry_has_perm(cred, dentry, FILE__GETATTR);
+	return dentry_has_perm(cred, path->dentry, FILE__GETATTR);
 }
 
-static int selinux_inode_removexattr(const struct mnt_idmap *idmap,
-				     struct dentry *dentry, const char *name)
+static int selinux_path_removexattr(const struct path *path,
+				     const char *name)
 {
 	/* if not a selinux xattr, only check the ordinary setattr perm */
 	if (strcmp(name, XATTR_NAME_SELINUX))
-		return dentry_has_perm(current_cred(), dentry, FILE__SETATTR);
+		return dentry_has_perm(current_cred(), path->dentry,
+				       FILE__SETATTR);
 
 	if (!selinux_initialized())
 		return 0;
@@ -3590,16 +3593,16 @@ static int selinux_inode_removexattr(const struct mnt_idmap *idmap,
 	return -EACCES;
 }
 
-static int selinux_inode_file_setattr(struct dentry *dentry,
+static int selinux_path_file_setattr(const struct path *path,
 				      struct file_kattr *fa)
 {
-	return dentry_has_perm(current_cred(), dentry, FILE__SETATTR);
+	return dentry_has_perm(current_cred(), path->dentry, FILE__SETATTR);
 }
 
-static int selinux_inode_file_getattr(struct dentry *dentry,
+static int selinux_path_file_getattr(const struct path *path,
 				      struct file_kattr *fa)
 {
-	return dentry_has_perm(current_cred(), dentry, FILE__GETATTR);
+	return dentry_has_perm(current_cred(), path->dentry, FILE__GETATTR);
 }
 
 static int selinux_path_notify(const struct path *path, u64 mask,
@@ -3653,7 +3656,7 @@ static int selinux_path_notify(const struct path *path, u64 mask,
 /*
  * Copy the inode security context value to the user.
  *
- * Permission check is handled by selinux_inode_getxattr hook.
+ * Permission check is handled by selinux_path_getxattr hook.
  */
 static int selinux_inode_getsecurity(const struct mnt_idmap *idmap,
 				     struct inode *inode, const char *name,
@@ -7173,9 +7176,9 @@ static int selinux_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen
 /*
  *	called with inode->i_mutex locked
  */
-static int selinux_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen)
+static int selinux_path_setsecctx(const struct path *path, void *ctx, u32 ctxlen)
 {
-	return __vfs_setxattr_locked(&nop_mnt_idmap, dentry, XATTR_NAME_SELINUX,
+	return __vfs_setxattr_locked(path, XATTR_NAME_SELINUX,
 				     ctx, ctxlen, 0, NULL);
 }
 
@@ -7752,19 +7755,19 @@ static struct security_hook_list selinux_hooks[] __ro_after_init = {
 	LSM_HOOK_INIT(inode_readlink, selinux_inode_readlink),
 	LSM_HOOK_INIT(inode_follow_link, selinux_inode_follow_link),
 	LSM_HOOK_INIT(inode_permission, selinux_inode_permission),
-	LSM_HOOK_INIT(inode_setattr, selinux_inode_setattr),
-	LSM_HOOK_INIT(inode_getattr, selinux_inode_getattr),
+	LSM_HOOK_INIT(path_setattr, selinux_path_setattr),
+	LSM_HOOK_INIT(path_getattr, selinux_path_getattr),
 	LSM_HOOK_INIT(inode_xattr_skipcap, selinux_inode_xattr_skipcap),
-	LSM_HOOK_INIT(inode_setxattr, selinux_inode_setxattr),
+	LSM_HOOK_INIT(path_setxattr, selinux_path_setxattr),
 	LSM_HOOK_INIT(inode_post_setxattr, selinux_inode_post_setxattr),
-	LSM_HOOK_INIT(inode_getxattr, selinux_inode_getxattr),
-	LSM_HOOK_INIT(inode_listxattr, selinux_inode_listxattr),
-	LSM_HOOK_INIT(inode_removexattr, selinux_inode_removexattr),
-	LSM_HOOK_INIT(inode_file_getattr, selinux_inode_file_getattr),
-	LSM_HOOK_INIT(inode_file_setattr, selinux_inode_file_setattr),
-	LSM_HOOK_INIT(inode_set_acl, selinux_inode_set_acl),
-	LSM_HOOK_INIT(inode_get_acl, selinux_inode_get_acl),
-	LSM_HOOK_INIT(inode_remove_acl, selinux_inode_remove_acl),
+	LSM_HOOK_INIT(path_getxattr, selinux_path_getxattr),
+	LSM_HOOK_INIT(path_listxattr, selinux_path_listxattr),
+	LSM_HOOK_INIT(path_removexattr, selinux_path_removexattr),
+	LSM_HOOK_INIT(path_file_getattr, selinux_path_file_getattr),
+	LSM_HOOK_INIT(path_file_setattr, selinux_path_file_setattr),
+	LSM_HOOK_INIT(path_set_acl, selinux_path_set_acl),
+	LSM_HOOK_INIT(path_get_acl, selinux_path_get_acl),
+	LSM_HOOK_INIT(path_remove_acl, selinux_path_remove_acl),
 	LSM_HOOK_INIT(inode_getsecurity, selinux_inode_getsecurity),
 	LSM_HOOK_INIT(inode_setsecurity, selinux_inode_setsecurity),
 	LSM_HOOK_INIT(inode_listsecurity, selinux_inode_listsecurity),
@@ -7848,7 +7851,7 @@ static struct security_hook_list selinux_hooks[] __ro_after_init = {
 	LSM_HOOK_INIT(release_secctx, selinux_release_secctx),
 	LSM_HOOK_INIT(inode_invalidate_secctx, selinux_inode_invalidate_secctx),
 	LSM_HOOK_INIT(inode_notifysecctx, selinux_inode_notifysecctx),
-	LSM_HOOK_INIT(inode_setsecctx, selinux_inode_setsecctx),
+	LSM_HOOK_INIT(path_setsecctx, selinux_path_setsecctx),
 
 	LSM_HOOK_INIT(unix_stream_connect, selinux_socket_unix_stream_connect),
 	LSM_HOOK_INIT(unix_may_send, selinux_socket_unix_may_send),
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index 3524649f402da..43f407ae007fe 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -1265,17 +1265,18 @@ static int smack_inode_permission(const struct mnt_idmap *idmap, struct inode *i
 }
 
 /**
- * smack_inode_setattr - Smack check for setting attributes
+ * smack_path_setattr - Smack check for setting attributes
  * @idmap: idmap of the mount
  * @dentry: the object
  * @iattr: for the force flag
  *
  * Returns 0 if access is permitted, an error code otherwise
  */
-static int smack_inode_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
+static int smack_path_setattr(const struct path *path,
 			       struct iattr *iattr)
 {
 	struct smk_audit_info ad;
+	struct dentry *dentry = path->dentry;
 	int rc;
 
 	/*
@@ -1292,12 +1293,12 @@ static int smack_inode_setattr(const struct mnt_idmap *idmap, struct dentry *den
 }
 
 /**
- * smack_inode_getattr - Smack check for getting attributes
+ * smack_path_getattr - Smack check for getting attributes
  * @path: path to extract the info from
  *
  * Returns 0 if access is permitted, an error code otherwise
  */
-static int smack_inode_getattr(const struct path *path)
+static int smack_path_getattr(const struct path *path)
 {
 	struct smk_audit_info ad;
 	struct inode *inode = d_backing_inode(path->dentry);
@@ -1338,7 +1339,7 @@ static int smack_inode_xattr_skipcap(const char *name)
 }
 
 /**
- * smack_inode_setxattr - Smack check for setting xattrs
+ * smack_path_setxattr - Smack check for setting xattrs
  * @idmap: idmap of the mount
  * @dentry: the object
  * @name: name of the attribute
@@ -1350,11 +1351,12 @@ static int smack_inode_xattr_skipcap(const char *name)
  *
  * Returns 0 if access is permitted, an error code otherwise
  */
-static int smack_inode_setxattr(const struct mnt_idmap *idmap,
-				struct dentry *dentry, const char *name,
-				const void *value, size_t size, int flags)
+static int smack_path_setxattr(const struct path *path,
+				const char *name, const void *value,
+				size_t size, int flags)
 {
 	struct smk_audit_info ad;
+	struct dentry *dentry = path->dentry;
 	struct smack_known *skp;
 	int check_priv = 0;
 	int check_import = 0;
@@ -1455,15 +1457,16 @@ static void smack_inode_post_setxattr(struct dentry *dentry, const char *name,
 }
 
 /**
- * smack_inode_getxattr - Smack check on getxattr
+ * smack_path_getxattr - Smack check on getxattr
  * @dentry: the object
  * @name: unused
  *
  * Returns 0 if access is permitted, an error code otherwise
  */
-static int smack_inode_getxattr(struct dentry *dentry, const char *name)
+static int smack_path_getxattr(const struct path *path, const char *name)
 {
 	struct smk_audit_info ad;
+	struct dentry *dentry = path->dentry;
 	int rc;
 
 	smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY);
@@ -1475,20 +1478,20 @@ static int smack_inode_getxattr(struct dentry *dentry, const char *name)
 }
 
 /**
- * smack_inode_removexattr - Smack check on removexattr
- * @idmap: idmap of the mount
- * @dentry: the object
+ * smack_path_removexattr - Smack check on removexattr
+ * @path: the object
  * @name: name of the attribute
  *
  * Removing the Smack attribute requires CAP_MAC_ADMIN
  *
  * Returns 0 if access is permitted, an error code otherwise
  */
-static int smack_inode_removexattr(const struct mnt_idmap *idmap,
-				   struct dentry *dentry, const char *name)
+static int smack_path_removexattr(const struct path *path,
+				   const char *name)
 {
 	struct inode_smack *isp;
 	struct smk_audit_info ad;
+	struct dentry *dentry = path->dentry;
 	int rc = 0;
 
 	if (strcmp(name, XATTR_NAME_SMACK) == 0 ||
@@ -1537,7 +1540,7 @@ static int smack_inode_removexattr(const struct mnt_idmap *idmap,
 }
 
 /**
- * smack_inode_set_acl - Smack check for setting posix acls
+ * smack_path_set_acl - Smack check for setting posix acls
  * @idmap: idmap of the mnt this request came from
  * @dentry: the object
  * @acl_name: name of the posix acl
@@ -1545,62 +1548,59 @@ static int smack_inode_removexattr(const struct mnt_idmap *idmap,
  *
  * Returns 0 if access is permitted, an error code otherwise
  */
-static int smack_inode_set_acl(const struct mnt_idmap *idmap,
-			       struct dentry *dentry, const char *acl_name,
-			       struct posix_acl *kacl)
+static int smack_path_set_acl(const struct path *path,
+			       const char *acl_name, struct posix_acl *kacl)
 {
 	struct smk_audit_info ad;
 	int rc;
 
 	smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY);
-	smk_ad_setfield_u_fs_path_dentry(&ad, dentry);
+	smk_ad_setfield_u_fs_path_dentry(&ad, path->dentry);
 
-	rc = smk_curacc(smk_of_inode(d_backing_inode(dentry)), MAY_WRITE, &ad);
-	rc = smk_bu_inode(d_backing_inode(dentry), MAY_WRITE, rc);
+	rc = smk_curacc(smk_of_inode(d_backing_inode(path->dentry)), MAY_WRITE, &ad);
+	rc = smk_bu_inode(d_backing_inode(path->dentry), MAY_WRITE, rc);
 	return rc;
 }
 
 /**
- * smack_inode_get_acl - Smack check for getting posix acls
- * @idmap: idmap of the mnt this request came from
- * @dentry: the object
+ * smack_path_get_acl - Smack check for getting posix acls
+ * @path: the object
  * @acl_name: name of the posix acl
  *
  * Returns 0 if access is permitted, an error code otherwise
  */
-static int smack_inode_get_acl(const struct mnt_idmap *idmap,
-			       struct dentry *dentry, const char *acl_name)
+static int smack_path_get_acl(const struct path *path,
+			       const char *acl_name)
 {
 	struct smk_audit_info ad;
 	int rc;
 
 	smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY);
-	smk_ad_setfield_u_fs_path_dentry(&ad, dentry);
+	smk_ad_setfield_u_fs_path_dentry(&ad, path->dentry);
 
-	rc = smk_curacc(smk_of_inode(d_backing_inode(dentry)), MAY_READ, &ad);
-	rc = smk_bu_inode(d_backing_inode(dentry), MAY_READ, rc);
+	rc = smk_curacc(smk_of_inode(d_backing_inode(path->dentry)), MAY_READ, &ad);
+	rc = smk_bu_inode(d_backing_inode(path->dentry), MAY_READ, rc);
 	return rc;
 }
 
 /**
- * smack_inode_remove_acl - Smack check for getting posix acls
- * @idmap: idmap of the mnt this request came from
- * @dentry: the object
+ * smack_path_remove_acl - Smack check for getting posix acls
+ * @path: the object
  * @acl_name: name of the posix acl
  *
  * Returns 0 if access is permitted, an error code otherwise
  */
-static int smack_inode_remove_acl(const struct mnt_idmap *idmap,
-				  struct dentry *dentry, const char *acl_name)
+static int smack_path_remove_acl(const struct path *path,
+				  const char *acl_name)
 {
 	struct smk_audit_info ad;
 	int rc;
 
 	smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY);
-	smk_ad_setfield_u_fs_path_dentry(&ad, dentry);
+	smk_ad_setfield_u_fs_path_dentry(&ad, path->dentry);
 
-	rc = smk_curacc(smk_of_inode(d_backing_inode(dentry)), MAY_WRITE, &ad);
-	rc = smk_bu_inode(d_backing_inode(dentry), MAY_WRITE, rc);
+	rc = smk_curacc(smk_of_inode(d_backing_inode(path->dentry)), MAY_WRITE, &ad);
+	rc = smk_bu_inode(d_backing_inode(path->dentry), MAY_WRITE, rc);
 	return rc;
 }
 
@@ -4978,9 +4978,9 @@ static int smack_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen)
 				       ctxlen, 0);
 }
 
-static int smack_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen)
+static int smack_path_setsecctx(const struct path *path, void *ctx, u32 ctxlen)
 {
-	return __vfs_setxattr_locked(&nop_mnt_idmap, dentry, XATTR_NAME_SMACK,
+	return __vfs_setxattr_locked(path, XATTR_NAME_SMACK,
 				     ctx, ctxlen, 0, NULL);
 }
 
@@ -5178,16 +5178,16 @@ static struct security_hook_list smack_hooks[] __ro_after_init = {
 	LSM_HOOK_INIT(inode_rmdir, smack_inode_rmdir),
 	LSM_HOOK_INIT(inode_rename, smack_inode_rename),
 	LSM_HOOK_INIT(inode_permission, smack_inode_permission),
-	LSM_HOOK_INIT(inode_setattr, smack_inode_setattr),
-	LSM_HOOK_INIT(inode_getattr, smack_inode_getattr),
+	LSM_HOOK_INIT(path_setattr, smack_path_setattr),
+	LSM_HOOK_INIT(path_getattr, smack_path_getattr),
 	LSM_HOOK_INIT(inode_xattr_skipcap, smack_inode_xattr_skipcap),
-	LSM_HOOK_INIT(inode_setxattr, smack_inode_setxattr),
+	LSM_HOOK_INIT(path_setxattr, smack_path_setxattr),
 	LSM_HOOK_INIT(inode_post_setxattr, smack_inode_post_setxattr),
-	LSM_HOOK_INIT(inode_getxattr, smack_inode_getxattr),
-	LSM_HOOK_INIT(inode_removexattr, smack_inode_removexattr),
-	LSM_HOOK_INIT(inode_set_acl, smack_inode_set_acl),
-	LSM_HOOK_INIT(inode_get_acl, smack_inode_get_acl),
-	LSM_HOOK_INIT(inode_remove_acl, smack_inode_remove_acl),
+	LSM_HOOK_INIT(path_getxattr, smack_path_getxattr),
+	LSM_HOOK_INIT(path_removexattr, smack_path_removexattr),
+	LSM_HOOK_INIT(path_set_acl, smack_path_set_acl),
+	LSM_HOOK_INIT(path_get_acl, smack_path_get_acl),
+	LSM_HOOK_INIT(path_remove_acl, smack_path_remove_acl),
 	LSM_HOOK_INIT(inode_getsecurity, smack_inode_getsecurity),
 	LSM_HOOK_INIT(inode_setsecurity, smack_inode_setsecurity),
 	LSM_HOOK_INIT(inode_listsecurity, smack_inode_listsecurity),
@@ -5303,7 +5303,7 @@ static struct security_hook_list smack_hooks[] __ro_after_init = {
 	LSM_HOOK_INIT(lsmprop_to_secctx, smack_lsmprop_to_secctx),
 	LSM_HOOK_INIT(secctx_to_secid, smack_secctx_to_secid),
 	LSM_HOOK_INIT(inode_notifysecctx, smack_inode_notifysecctx),
-	LSM_HOOK_INIT(inode_setsecctx, smack_inode_setsecctx),
+	LSM_HOOK_INIT(path_setsecctx, smack_path_setsecctx),
 	LSM_HOOK_INIT(inode_getsecctx, smack_inode_getsecctx),
 	LSM_HOOK_INIT(inode_copy_up, smack_inode_copy_up),
 	LSM_HOOK_INIT(inode_copy_up_xattr, smack_inode_copy_up_xattr),
diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
index c66e02ed8ee3b..901eefa84ea6c 100644
--- a/security/tomoyo/tomoyo.c
+++ b/security/tomoyo/tomoyo.c
@@ -112,13 +112,13 @@ static int tomoyo_bprm_check_security(struct linux_binprm *bprm)
 }
 
 /**
- * tomoyo_inode_getattr - Target for security_inode_getattr().
+ * tomoyo_path_getattr - Target for security_path_getattr().
  *
  * @path: Pointer to "struct path".
  *
  * Returns 0 on success, negative value otherwise.
  */
-static int tomoyo_inode_getattr(const struct path *path)
+static int tomoyo_path_getattr(const struct path *path)
 {
 	return tomoyo_path_perm(TOMOYO_TYPE_GETATTR, path, NULL);
 }
@@ -570,7 +570,7 @@ static struct security_hook_list tomoyo_hooks[] __ro_after_init = {
 	LSM_HOOK_INIT(path_mknod, tomoyo_path_mknod),
 	LSM_HOOK_INIT(path_link, tomoyo_path_link),
 	LSM_HOOK_INIT(path_rename, tomoyo_path_rename),
-	LSM_HOOK_INIT(inode_getattr, tomoyo_inode_getattr),
+	LSM_HOOK_INIT(path_getattr, tomoyo_path_getattr),
 	LSM_HOOK_INIT(file_ioctl, tomoyo_file_ioctl),
 	LSM_HOOK_INIT(file_ioctl_compat, tomoyo_file_ioctl),
 	LSM_HOOK_INIT(path_chmod, tomoyo_path_chmod),
diff --git a/tools/testing/selftests/bpf/prog_tests/d_path.c b/tools/testing/selftests/bpf/prog_tests/d_path.c
index 1a2a2f1abf033..9877c098e5c14 100644
--- a/tools/testing/selftests/bpf/prog_tests/d_path.c
+++ b/tools/testing/selftests/bpf/prog_tests/d_path.c
@@ -160,7 +160,7 @@ static void test_d_path_basic(void)
 
 	if (CHECK(!bss->called_stat,
 		  "stat",
-		  "trampoline for security_inode_getattr was not called\n"))
+		  "trampoline for security_path_getattr was not called\n"))
 		goto cleanup;
 
 	if (CHECK(!bss->called_close,
diff --git a/tools/testing/selftests/bpf/prog_tests/fs_kfuncs.c b/tools/testing/selftests/bpf/prog_tests/fs_kfuncs.c
index 43a26ec69a8e3..5145b1f03cac2 100644
--- a/tools/testing/selftests/bpf/prog_tests/fs_kfuncs.c
+++ b/tools/testing/selftests/bpf/prog_tests/fs_kfuncs.c
@@ -53,7 +53,7 @@ static void test_get_xattr(const char *name, const char *value, bool allow_acces
 	if (!ASSERT_GE(fd, 0, "open_file"))
 		goto out;
 
-	/* Trigger security_inode_getxattr */
+	/* Trigger security_path_getxattr */
 	err = getxattr(testfile, name, v, sizeof(v));
 
 	if (allow_access) {
@@ -148,13 +148,13 @@ static void test_set_remove_xattr(void)
 
 	/* First, test not _locked version of the kfuncs with getxattr. */
 
-	/* Read security.bpf.foo and trigger test_inode_getxattr. This
+	/* Read security.bpf.foo and trigger test_path_getxattr. This
 	 * bpf program will set security.bpf.bar to "world".
 	 */
 	read_and_validate_foo(skel);
 	validate_bar_match(skel);
 
-	/* Read security.bpf.foo and trigger test_inode_getxattr again.
+	/* Read security.bpf.foo and trigger test_path_getxattr again.
 	 * This will remove xattr security.bpf.bar.
 	 */
 	read_and_validate_foo(skel);
@@ -167,13 +167,13 @@ static void test_set_remove_xattr(void)
 
 	/* Second, test _locked version of the kfuncs, with setxattr */
 
-	/* Set security.bpf.foo and trigger test_inode_setxattr. This
+	/* Set security.bpf.foo and trigger test_path_setxattr. This
 	 * bpf program will set security.bpf.bar to "world".
 	 */
 	set_foo(skel);
 	validate_bar_match(skel);
 
-	/* Set security.bpf.foo and trigger test_inode_setxattr again.
+	/* Set security.bpf.foo and trigger test_path_setxattr again.
 	 * This will remove xattr security.bpf.bar.
 	 */
 	set_foo(skel);
diff --git a/tools/testing/selftests/bpf/progs/test_d_path.c b/tools/testing/selftests/bpf/progs/test_d_path.c
index 561b2f861808e..b97c203e3992d 100644
--- a/tools/testing/selftests/bpf/progs/test_d_path.c
+++ b/tools/testing/selftests/bpf/progs/test_d_path.c
@@ -19,7 +19,7 @@ int called_stat = 0;
 int called_close = 0;
 int path_match_fallocate = 0;
 
-SEC("fentry/security_inode_getattr")
+SEC("fentry/security_path_getattr")
 int BPF_PROG(prog_stat, struct path *path, struct kstat *stat,
 	     __u32 request_mask, unsigned int query_flags)
 {
diff --git a/tools/testing/selftests/bpf/progs/test_d_path_check_rdonly_mem.c b/tools/testing/selftests/bpf/progs/test_d_path_check_rdonly_mem.c
index 27c27cff6a3aa..5e0e3d4828d79 100644
--- a/tools/testing/selftests/bpf/progs/test_d_path_check_rdonly_mem.c
+++ b/tools/testing/selftests/bpf/progs/test_d_path_check_rdonly_mem.c
@@ -7,7 +7,7 @@
 
 extern const int bpf_prog_active __ksym;
 
-SEC("fentry/security_inode_getattr")
+SEC("fentry/security_path_getattr")
 int BPF_PROG(d_path_check_rdonly_mem, struct path *path, struct kstat *stat,
 	     __u32 request_mask, unsigned int query_flags)
 {
diff --git a/tools/testing/selftests/bpf/progs/test_d_path_check_types.c b/tools/testing/selftests/bpf/progs/test_d_path_check_types.c
index 7e02b7361307c..fba3d527b4df6 100644
--- a/tools/testing/selftests/bpf/progs/test_d_path_check_types.c
+++ b/tools/testing/selftests/bpf/progs/test_d_path_check_types.c
@@ -11,7 +11,7 @@ struct {
 	__uint(max_entries, 1 << 12);
 } ringbuf SEC(".maps");
 
-SEC("fentry/security_inode_getattr")
+SEC("fentry/security_path_getattr")
 int BPF_PROG(d_path_check_rdonly_mem, struct path *path, struct kstat *stat,
 	     __u32 request_mask, unsigned int query_flags)
 {
diff --git a/tools/testing/selftests/bpf/progs/test_get_xattr.c b/tools/testing/selftests/bpf/progs/test_get_xattr.c
index 54305f4c9f2dd..eea89016f96f1 100644
--- a/tools/testing/selftests/bpf/progs/test_get_xattr.c
+++ b/tools/testing/selftests/bpf/progs/test_get_xattr.c
@@ -55,8 +55,8 @@ int BPF_PROG(test_file_open, struct file *f)
 	return 0;
 }
 
-SEC("lsm.s/inode_getxattr")
-int BPF_PROG(test_inode_getxattr, struct dentry *dentry, char *name)
+SEC("lsm.s/path_getxattr")
+int BPF_PROG(test_path_getxattr, const struct path *path, char *name)
 {
 	struct bpf_dynptr value_ptr;
 	__u32 pid;
@@ -69,7 +69,7 @@ int BPF_PROG(test_inode_getxattr, struct dentry *dentry, char *name)
 	bpf_dynptr_from_mem(value2, sizeof(value2), 0, &value_ptr);
 
 	for (i = 0; i < ARRAY_SIZE(xattr_names); i++) {
-		ret = bpf_get_dentry_xattr(dentry, xattr_names[i], &value_ptr);
+		ret = bpf_get_dentry_xattr(path->dentry, xattr_names[i], &value_ptr);
 		if (ret == sizeof(expected_value))
 			break;
 	}
diff --git a/tools/testing/selftests/bpf/progs/test_set_remove_xattr.c b/tools/testing/selftests/bpf/progs/test_set_remove_xattr.c
index 6a612cf168d3f..f7438081d630e 100644
--- a/tools/testing/selftests/bpf/progs/test_set_remove_xattr.c
+++ b/tools/testing/selftests/bpf/progs/test_set_remove_xattr.c
@@ -32,8 +32,8 @@ static inline bool name_match_foo(const char *name)
 }
 
 /* Test bpf_set_dentry_xattr and bpf_remove_dentry_xattr */
-SEC("lsm.s/inode_getxattr")
-int BPF_PROG(test_inode_getxattr, struct dentry *dentry, char *name)
+SEC("lsm.s/path_getxattr")
+int BPF_PROG(test_path_getxattr, const struct path *path, char *name)
 {
 	struct bpf_dynptr value_ptr;
 	__u32 pid;
@@ -50,25 +50,25 @@ int BPF_PROG(test_inode_getxattr, struct dentry *dentry, char *name)
 	bpf_dynptr_from_mem(read_value, sizeof(read_value), 0, &value_ptr);
 
 	/* read security.bpf.bar */
-	ret = bpf_get_dentry_xattr(dentry, xattr_bar, &value_ptr);
+	ret = bpf_get_dentry_xattr(path->dentry, xattr_bar, &value_ptr);
 
 	if (ret < 0) {
 		/* If security.bpf.bar doesn't exist, set it */
 		bpf_dynptr_from_mem(value_bar, sizeof(value_bar), 0, &value_ptr);
 
-		ret = bpf_set_dentry_xattr(dentry, xattr_bar, &value_ptr, 0);
+		ret = bpf_set_dentry_xattr(path->dentry, xattr_bar, &value_ptr, 0);
 		if (!ret)
 			set_security_bpf_bar_success = true;
-		ret = bpf_set_dentry_xattr(dentry, xattr_selinux, &value_ptr, 0);
+		ret = bpf_set_dentry_xattr(path->dentry, xattr_selinux, &value_ptr, 0);
 		if (ret)
 			set_security_selinux_fail = true;
 	} else {
 		/* If security.bpf.bar exists, remove it */
-		ret = bpf_remove_dentry_xattr(dentry, xattr_bar);
+		ret = bpf_remove_dentry_xattr(path->dentry, xattr_bar);
 		if (!ret)
 			remove_security_bpf_bar_success = true;
 
-		ret = bpf_remove_dentry_xattr(dentry, xattr_selinux);
+		ret = bpf_remove_dentry_xattr(path->dentry, xattr_selinux);
 		if (ret)
 			remove_security_selinux_fail = true;
 	}
@@ -86,10 +86,9 @@ bool locked_remove_security_selinux_fail;
  * not-_locked version in the BPF program. The verifier will fix them up
  * properly.
  */
-SEC("lsm.s/inode_setxattr")
-int BPF_PROG(test_inode_setxattr, struct mnt_idmap *idmap,
-	     struct dentry *dentry, const char *name,
-	     const void *value, size_t size, int flags)
+SEC("lsm.s/path_setxattr")
+int BPF_PROG(test_path_setxattr, const struct path *path,
+	     const char *name, const void *value, size_t size, int flags)
 {
 	struct bpf_dynptr value_ptr;
 	__u32 pid;
@@ -106,25 +105,25 @@ int BPF_PROG(test_inode_setxattr, struct mnt_idmap *idmap,
 	bpf_dynptr_from_mem(read_value, sizeof(read_value), 0, &value_ptr);
 
 	/* read security.bpf.bar */
-	ret = bpf_get_dentry_xattr(dentry, xattr_bar, &value_ptr);
+	ret = bpf_get_dentry_xattr(path->dentry, xattr_bar, &value_ptr);
 
 	if (ret < 0) {
 		/* If security.bpf.bar doesn't exist, set it */
 		bpf_dynptr_from_mem(value_bar, sizeof(value_bar), 0, &value_ptr);
 
-		ret = bpf_set_dentry_xattr(dentry, xattr_bar, &value_ptr, 0);
+		ret = bpf_set_dentry_xattr(path->dentry, xattr_bar, &value_ptr, 0);
 		if (!ret)
 			locked_set_security_bpf_bar_success = true;
-		ret = bpf_set_dentry_xattr(dentry, xattr_selinux, &value_ptr, 0);
+		ret = bpf_set_dentry_xattr(path->dentry, xattr_selinux, &value_ptr, 0);
 		if (ret)
 			locked_set_security_selinux_fail = true;
 	} else {
 		/* If security.bpf.bar exists, remove it */
-		ret = bpf_remove_dentry_xattr(dentry, xattr_bar);
+		ret = bpf_remove_dentry_xattr(path->dentry, xattr_bar);
 		if (!ret)
 			locked_remove_security_bpf_bar_success = true;
 
-		ret = bpf_remove_dentry_xattr(dentry, xattr_selinux);
+		ret = bpf_remove_dentry_xattr(path->dentry, xattr_selinux);
 		if (ret)
 			locked_remove_security_selinux_fail = true;
 	}
diff --git a/tools/testing/selftests/bpf/progs/verifier_lsm_init_xattr.c b/tools/testing/selftests/bpf/progs/verifier_lsm_init_xattr.c
index b706bf17b5560..a9b09e559d7e4 100644
--- a/tools/testing/selftests/bpf/progs/verifier_lsm_init_xattr.c
+++ b/tools/testing/selftests/bpf/progs/verifier_lsm_init_xattr.c
@@ -232,9 +232,9 @@ int BPF_PROG(reject_lsm_cgroup, struct inode *inode, struct inode *dir,
 	return 0;
 }
 
-SEC("lsm/inode_setxattr")
+SEC("lsm/path_setxattr")
 __failure __msg("calling kernel function bpf_inode_init_xattr is not allowed")
-int BPF_PROG(reject_wrong_hook, struct mnt_idmap *idmap, struct dentry *dentry,
+int BPF_PROG(reject_wrong_hook, const struct path *path,
 	     const char *name, const void *value, size_t size, int flags)
 {
 	struct bpf_dynptr val;
diff --git a/tools/testing/selftests/bpf/progs/verifier_vfs_accept.c b/tools/testing/selftests/bpf/progs/verifier_vfs_accept.c
index 55398c04290a8..55e292a41d304 100644
--- a/tools/testing/selftests/bpf/progs/verifier_vfs_accept.c
+++ b/tools/testing/selftests/bpf/progs/verifier_vfs_accept.c
@@ -54,7 +54,7 @@ int BPF_PROG(get_task_exe_file_and_put_kfunc_from_argument,
 	return 0;
 }
 
-SEC("lsm.s/inode_getattr")
+SEC("lsm.s/path_getattr")
 __success
 int BPF_PROG(path_d_path_from_path_argument, struct path *path)
 {
diff --git a/tools/testing/selftests/bpf/progs/verifier_vfs_reject.c b/tools/testing/selftests/bpf/progs/verifier_vfs_reject.c
index b5f456d57669e..1337effeb46be 100644
--- a/tools/testing/selftests/bpf/progs/verifier_vfs_reject.c
+++ b/tools/testing/selftests/bpf/progs/verifier_vfs_reject.c
@@ -27,7 +27,7 @@ int BPF_PROG(get_task_exe_file_kfunc_null)
 	return 0;
 }
 
-SEC("lsm.s/inode_getxattr")
+SEC("lsm.s/path_getxattr")
 __failure __msg("R1 type=fp expected=ptr_, trusted_ptr_, rcu_ptr_")
 int BPF_PROG(get_task_exe_file_kfunc_fp)
 {
diff --git a/tools/testing/selftests/landlock/base_test.c b/tools/testing/selftests/landlock/base_test.c
index 89c0d96607deb..14078ad203d8b 100644
--- a/tools/testing/selftests/landlock/base_test.c
+++ b/tools/testing/selftests/landlock/base_test.c
@@ -76,7 +76,7 @@ TEST(abi_version)
 	const struct landlock_ruleset_attr ruleset_attr = {
 		.handled_access_fs = LANDLOCK_ACCESS_FS_READ_FILE,
 	};
-	ASSERT_EQ(12, landlock_create_ruleset(NULL, 0,
+	ASSERT_EQ(13, landlock_create_ruleset(NULL, 0,
 					      LANDLOCK_CREATE_RULESET_VERSION));
 
 	ASSERT_EQ(-1, landlock_create_ruleset(&ruleset_attr, 0,
diff --git a/tools/testing/selftests/landlock/fs_test.c b/tools/testing/selftests/landlock/fs_test.c
index f725882fa4a78..ce865955c5794 100644
--- a/tools/testing/selftests/landlock/fs_test.c
+++ b/tools/testing/selftests/landlock/fs_test.c
@@ -12,6 +12,7 @@
 #include <fcntl.h>
 #include <libgen.h>
 #include <linux/fiemap.h>
+#include <linux/fs.h>
 #include <linux/landlock.h>
 #include <linux/magic.h>
 #include <sched.h>
@@ -26,8 +27,10 @@
 #include <sys/sendfile.h>
 #include <sys/socket.h>
 #include <sys/stat.h>
+#include <sys/syscall.h>
 #include <sys/sysmacros.h>
 #include <sys/un.h>
+#include <sys/xattr.h>
 #include <sys/vfs.h>
 #include <unistd.h>
 
@@ -571,11 +574,13 @@ TEST_F_FORK(layout1, inval)
 	LANDLOCK_ACCESS_FS_EXECUTE | \
 	LANDLOCK_ACCESS_FS_WRITE_FILE | \
 	LANDLOCK_ACCESS_FS_READ_FILE | \
+	LANDLOCK_ACCESS_FS_READ_METADATA | \
+	LANDLOCK_ACCESS_FS_WRITE_METADATA | \
 	LANDLOCK_ACCESS_FS_TRUNCATE | \
 	LANDLOCK_ACCESS_FS_IOCTL_DEV | \
 	LANDLOCK_ACCESS_FS_RESOLVE_UNIX)
 
-#define ACCESS_LAST LANDLOCK_ACCESS_FS_RESOLVE_UNIX
+#define ACCESS_LAST LANDLOCK_ACCESS_FS_WRITE_METADATA
 
 #define ACCESS_ALL ( \
 	ACCESS_FILE | \
@@ -10916,4 +10921,603 @@ TEST_F(trace_layout1, check_rule_fs_empty_grant)
 	free(buf);
 }
 
+/* Invokes chmod(2) and returns its errno or 0. */
+static int test_chmod(const char *const path, mode_t mode)
+{
+	if (chmod(path, mode) < 0)
+		return errno;
+	return 0;
+}
+
+/* Invokes fchmod(2) and returns its errno or 0. */
+static int test_fchmod(int fd, mode_t mode)
+{
+	if (fchmod(fd, mode) < 0)
+		return errno;
+	return 0;
+}
+
+/* Invokes chown(2) and returns its errno or 0. */
+static int test_chown(const char *const path, uid_t uid, gid_t gid)
+{
+	if (chown(path, uid, gid) < 0)
+		return errno;
+	return 0;
+}
+
+/* Invokes fchown(2) and returns its errno or 0. */
+static int test_fchown(int fd, uid_t uid, gid_t gid)
+{
+	if (fchown(fd, uid, gid) < 0)
+		return errno;
+	return 0;
+}
+
+/* Invokes lchown(2) and returns its errno or 0. */
+static int test_lchown(const char *const path, uid_t uid, gid_t gid)
+{
+	if (lchown(path, uid, gid) < 0)
+		return errno;
+	return 0;
+}
+
+/* Invokes utimensat(2) with explicit times and returns its errno or 0. */
+static int test_utimensat(const char *const path)
+{
+	const struct timespec times[] = {
+		{
+			.tv_sec = 0,
+			.tv_nsec = UTIME_OMIT,
+		},
+		{
+			.tv_sec = 1,
+			.tv_nsec = 0,
+		},
+	};
+
+	if (utimensat(AT_FDCWD, path, times, 0) < 0)
+		return errno;
+	return 0;
+}
+
+/* Invokes utimensat(2) with UTIME_NOW and returns its errno or 0. */
+static int test_utimensat_now(const char *const path)
+{
+	if (utimensat(AT_FDCWD, path, NULL, 0) < 0)
+		return errno;
+	return 0;
+}
+
+/* Invokes setxattr(2) and returns its errno or 0. */
+static int test_setxattr(const char *const path, const char *const name,
+			 const void *const value, const size_t size)
+{
+	if (setxattr(path, name, value, size, 0) < 0)
+		return errno;
+	return 0;
+}
+
+/* Invokes getxattr(2) and returns its errno or 0. */
+static int test_getxattr(const char *const path, const char *const name,
+			 void *const value, const size_t size)
+{
+	if (getxattr(path, name, value, size) < 0)
+		return errno;
+	return 0;
+}
+
+/* Invokes listxattr(2) and returns its errno or 0. */
+static int test_listxattr(const char *const path, void *const list,
+			  const size_t size)
+{
+	if (listxattr(path, list, size) < 0)
+		return errno;
+	return 0;
+}
+
+/* Invokes removexattr(2) and returns its errno or 0. */
+static int test_removexattr(const char *const path, const char *const name)
+{
+	if (removexattr(path, name) < 0)
+		return errno;
+	return 0;
+}
+
+/* Invokes stat(2) and returns its errno or 0. */
+static int test_stat(const char *const path, struct stat *statbuf)
+{
+	if (stat(path, statbuf) < 0)
+		return errno;
+	return 0;
+}
+
+/* Invokes fstat(2) and returns its errno or 0. */
+static int test_fstat(int fd, struct stat *statbuf)
+{
+	if (fstat(fd, statbuf) < 0)
+		return errno;
+	return 0;
+}
+
+TEST_F_FORK(layout1, unhandled_metadata)
+{
+	int file_fd;
+	int ruleset_fd;
+	const char *const file1 = file1_s1d1;
+	const char *const file2 = file2_s1d1;
+	const char *const dir1 = dir_s1d1;
+	struct stat statbuf;
+	const struct rule rules[] = {
+		{
+			.path = file1,
+			.access = LANDLOCK_ACCESS_FS_WRITE_FILE,
+		},
+		{
+			.path = file2,
+			.access = LANDLOCK_ACCESS_FS_READ_FILE |
+				  LANDLOCK_ACCESS_FS_WRITE_FILE,
+		},
+		{
+			.path = dir1,
+			.access = ACCESS_RW,
+		},
+		{},
+	};
+
+	/*
+	 * READ_METADATA and WRITE_METADATA are not handled, so metadata
+	 * access should be allowed.
+	 */
+	ruleset_fd = create_ruleset(_metadata, ACCESS_RW, rules);
+	ASSERT_LE(0, ruleset_fd);
+	file_fd = open(file1, O_WRONLY | O_CLOEXEC);
+	ASSERT_LE(0, file_fd);
+
+	enforce_ruleset(_metadata, ruleset_fd);
+	ASSERT_EQ(0, close(ruleset_fd));
+
+	EXPECT_EQ(0, test_chmod(file1, 0644));
+	EXPECT_EQ(0, test_fchmod(file_fd, 0644));
+	EXPECT_EQ(0, test_chmod(file2, 0400));
+	EXPECT_EQ(0, test_chmod(dir1, 0700));
+
+	EXPECT_EQ(0, test_chown(file1, -1, 0));
+	EXPECT_EQ(0, test_fchown(file_fd, -1, 0));
+	EXPECT_EQ(0, test_lchown(file1, -1, 0));
+
+	EXPECT_EQ(0, test_utimensat(file1));
+	EXPECT_EQ(0, test_utimensat_now(file1));
+
+	EXPECT_EQ(0, test_setxattr(file1, "user.test", "a", 1));
+	EXPECT_EQ(0, test_getxattr(file1, "user.test", NULL, 0));
+	EXPECT_EQ(0, test_listxattr(file1, NULL, 0));
+	EXPECT_EQ(0, test_removexattr(file1, "user.test"));
+
+	EXPECT_EQ(0, test_stat(file1, &statbuf));
+	EXPECT_EQ(0, test_fstat(file_fd, &statbuf));
+	EXPECT_EQ(0, test_stat(dir1, &statbuf));
+
+	ASSERT_EQ(0, close(file_fd));
+}
+
+TEST_F_FORK(layout1, write_metadata)
+{
+	int file_fd, file2_fd, trunc_fd;
+	int ruleset_fd;
+	const char *const file1 = file1_s1d1;
+	const char *const file2 = file2_s1d1;
+	const char *const trunc_file = file1_s1d2;
+	const char *const dir1 = dir_s1d1;
+	struct stat statbuf;
+	const struct rule rules[] = {
+		{
+			.path = file1,
+			.access = LANDLOCK_ACCESS_FS_WRITE_FILE |
+				  LANDLOCK_ACCESS_FS_WRITE_METADATA,
+		},
+		{
+			.path = file2,
+			.access = LANDLOCK_ACCESS_FS_READ_FILE |
+				  LANDLOCK_ACCESS_FS_WRITE_FILE,
+		},
+		{
+			.path = dir1,
+			.access = ACCESS_RW,
+		},
+		{},
+	};
+
+	ruleset_fd = create_ruleset(_metadata, ACCESS_RW |
+				    LANDLOCK_ACCESS_FS_WRITE_METADATA, rules);
+	ASSERT_LE(0, ruleset_fd);
+	file_fd = open(file1, O_WRONLY | O_CLOEXEC);
+	ASSERT_LE(0, file_fd);
+	file2_fd = open(file2, O_RDWR | O_CLOEXEC);
+	ASSERT_LE(0, file2_fd);
+	trunc_fd = open(trunc_file, O_RDWR | O_CLOEXEC);
+	ASSERT_LE(0, trunc_fd);
+
+	/*
+	 * Arm the setuid bit for the implicit clearing tests below:
+	 * writing or truncating a setuid file clears that bit when the
+	 * caller has no CAP_FSETID, which is the case here because
+	 * tests run without capabilities (see disable_caps() in
+	 * prepare_layout()).
+	 */
+	ASSERT_EQ(0, fchmod(file2_fd, 04666));
+	ASSERT_EQ(0, fchmod(trunc_fd, 04666));
+
+	enforce_ruleset(_metadata, ruleset_fd);
+	ASSERT_EQ(0, close(ruleset_fd));
+
+	/* file1 has WRITE_METADATA: allowed */
+	EXPECT_EQ(0, test_chmod(file1, 0644));
+	EXPECT_EQ(0, test_fchmod(file_fd, 0644));
+	EXPECT_EQ(0, test_chown(file1, -1, 0));
+	EXPECT_EQ(0, test_fchown(file_fd, -1, 0));
+	EXPECT_EQ(0, test_lchown(file1, -1, 0));
+	EXPECT_EQ(0, test_utimensat(file1));
+	EXPECT_EQ(0, test_utimensat_now(file1));
+	EXPECT_EQ(0, test_setxattr(file1, "user.test", "a", 1));
+	EXPECT_EQ(0, test_removexattr(file1, "user.test"));
+
+	/*
+	 * Writing is not an explicit metadata change: implicit timestamp
+	 * updates and the implicit setuid-bit clearing are allowed
+	 * without WRITE_METADATA.
+	 */
+	EXPECT_EQ(1, write(file2_fd, "a", 1));
+	ASSERT_EQ(0, fstat(file2_fd, &statbuf));
+	EXPECT_EQ(0, statbuf.st_mode & S_ISUID);
+
+	/* file2 does not have WRITE_METADATA: denied */
+	EXPECT_EQ(EACCES, test_chmod(file2, 0400));
+	EXPECT_EQ(EACCES, test_chown(file2, -1, 0));
+	EXPECT_EQ(EACCES, test_lchown(file2, -1, 0));
+	EXPECT_EQ(EACCES, test_utimensat(file2));
+	EXPECT_EQ(EACCES, test_utimensat_now(file2));
+	EXPECT_EQ(EACCES, test_setxattr(file2, "user.test", "a", 1));
+	EXPECT_EQ(EACCES, test_removexattr(file2, "user.test"));
+
+	/* dir1 does not have WRITE_METADATA: denied */
+	EXPECT_EQ(EACCES, test_chmod(dir1, 0700));
+	EXPECT_EQ(EACCES, test_chown(dir1, -1, 0));
+
+	/*
+	 * Truncating a setuid file implicitly clears the setuid bit as
+	 * well: this must not require WRITE_METADATA, which trunc_file
+	 * does not have.
+	 */
+	EXPECT_EQ(0, ftruncate(trunc_fd, 0));
+	ASSERT_EQ(0, fstat(trunc_fd, &statbuf));
+	EXPECT_EQ(0, statbuf.st_mode & S_ISUID);
+
+	ASSERT_EQ(0, close(file_fd));
+	ASSERT_EQ(0, close(file2_fd));
+	ASSERT_EQ(0, close(trunc_fd));
+}
+
+TEST_F_FORK(layout1, read_metadata)
+{
+	int file_fd;
+	int ruleset_fd;
+	const char *const file1 = file1_s1d1;
+	const char *const file2 = file2_s1d1;
+	const char *const dir1 = dir_s1d1;
+	struct stat statbuf;
+	const struct rule rules[] = {
+		{
+			.path = file1,
+			.access = LANDLOCK_ACCESS_FS_READ_FILE |
+				  LANDLOCK_ACCESS_FS_READ_METADATA,
+		},
+		{
+			.path = file2,
+			.access = LANDLOCK_ACCESS_FS_READ_FILE |
+				  LANDLOCK_ACCESS_FS_WRITE_FILE,
+		},
+		{
+			.path = dir1,
+			.access = ACCESS_RW,
+		},
+		{},
+	};
+
+	ruleset_fd = create_ruleset(_metadata, ACCESS_RW |
+				    LANDLOCK_ACCESS_FS_READ_METADATA, rules);
+	ASSERT_LE(0, ruleset_fd);
+
+	ASSERT_EQ(0, setxattr(file1, "user.test", "a", 1, 0));
+	ASSERT_EQ(0, setxattr(file2, "user.test", "a", 1, 0));
+
+	file_fd = open(file1, O_RDONLY | O_CLOEXEC);
+	ASSERT_LE(0, file_fd);
+
+	enforce_ruleset(_metadata, ruleset_fd);
+	ASSERT_EQ(0, close(ruleset_fd));
+
+	/* file1 has READ_METADATA: allowed */
+	EXPECT_EQ(0, test_stat(file1, &statbuf));
+	EXPECT_EQ(0, test_fstat(file_fd, &statbuf));
+	EXPECT_EQ(0, test_getxattr(file1, "user.test", NULL, 0));
+	EXPECT_EQ(0, test_listxattr(file1, NULL, 0));
+
+	/* file2 does not have READ_METADATA: denied */
+	EXPECT_EQ(EACCES, test_stat(file2, &statbuf));
+	EXPECT_EQ(EACCES, test_getxattr(file2, "user.test", NULL, 0));
+	EXPECT_EQ(EACCES, test_listxattr(file2, NULL, 0));
+	/* dir1 does not have READ_METADATA: denied */
+	EXPECT_EQ(EACCES, test_stat(dir1, &statbuf));
+
+	ASSERT_EQ(0, close(file_fd));
+}
+
+/* Invokes ioctl(FS_IOC_GETFLAGS) and returns its errno or 0. */
+static int test_getflags(int fd, unsigned int *const flags)
+{
+	if (ioctl(fd, FS_IOC_GETFLAGS, flags) < 0)
+		return errno;
+	return 0;
+}
+
+/* Invokes ioctl(FS_IOC_SETFLAGS) and returns its errno or 0. */
+static int test_setflags(int fd, const unsigned int flags)
+{
+	unsigned int flags_ = flags;
+
+	if (ioctl(fd, FS_IOC_SETFLAGS, &flags_) < 0)
+		return errno;
+	return 0;
+}
+
+#ifndef __NR_file_getattr
+#define __NR_file_getattr 468
+#endif
+#ifndef __NR_file_setattr
+#define __NR_file_setattr 469
+#endif
+
+/* Invokes file_getattr(2) and returns its errno or 0. */
+static int test_file_getattr(int dfd, const char *const path,
+			     struct file_attr *const fattr,
+			     const unsigned int at_flags)
+{
+	if (syscall(__NR_file_getattr, dfd, path, fattr, sizeof(*fattr),
+		    at_flags) < 0)
+		return errno;
+	return 0;
+}
+
+/* Invokes file_setattr(2) and returns its errno or 0. */
+static int test_file_setattr(int dfd, const char *const path,
+			     struct file_attr *const fattr,
+			     const unsigned int at_flags)
+{
+	if (syscall(__NR_file_setattr, dfd, path, fattr, sizeof(*fattr),
+		    at_flags) < 0)
+		return errno;
+	return 0;
+}
+
+TEST_F_FORK(layout1, fileattr)
+{
+	const struct rule rules[] = {
+		{
+			.path = file1_s1d1,
+			.access = LANDLOCK_ACCESS_FS_READ_METADATA |
+				  LANDLOCK_ACCESS_FS_WRITE_METADATA,
+		},
+		{},
+	};
+	struct file_attr fattr;
+	unsigned int flags;
+	int fd, fd2, ruleset_fd;
+
+	ruleset_fd = create_ruleset(
+		_metadata,
+		LANDLOCK_ACCESS_FS_READ_METADATA |
+			LANDLOCK_ACCESS_FS_WRITE_METADATA,
+		rules);
+	ASSERT_LE(0, ruleset_fd);
+
+	fd = open(file1_s1d1, O_RDONLY | O_CLOEXEC);
+	ASSERT_LE(0, fd);
+
+	enforce_ruleset(_metadata, ruleset_fd);
+	ASSERT_EQ(0, close(ruleset_fd));
+
+	/* Allowed file: FS_IOC_GETFLAGS */
+	flags = 0;
+	EXPECT_EQ(0, test_getflags(fd, &flags));
+	EXPECT_EQ(0, flags & FS_NODUMP_FL);
+
+	/* Allowed file: FS_IOC_SETFLAGS */
+	EXPECT_EQ(0, test_setflags(fd, FS_NODUMP_FL));
+	flags = 0;
+	EXPECT_EQ(0, test_getflags(fd, &flags));
+	EXPECT_EQ(FS_NODUMP_FL, flags & FS_NODUMP_FL);
+	EXPECT_EQ(0, test_setflags(fd, 0));
+
+	/* Allowed file: file_getattr(2), with a path and with AT_EMPTY_PATH */
+	memset(&fattr, 0, sizeof(fattr));
+	EXPECT_EQ(0, test_file_getattr(AT_FDCWD, file1_s1d1, &fattr, 0));
+	EXPECT_EQ(0, fattr.fa_xflags & FS_XFLAG_NODUMP);
+	memset(&fattr, 0, sizeof(fattr));
+	EXPECT_EQ(0, test_file_getattr(fd, NULL, &fattr, AT_EMPTY_PATH));
+
+	/* Allowed file: file_setattr(2), with a path and with AT_EMPTY_PATH */
+	memset(&fattr, 0, sizeof(fattr));
+	fattr.fa_xflags = FS_XFLAG_NODUMP;
+	EXPECT_EQ(0, test_file_setattr(AT_FDCWD, file1_s1d1, &fattr, 0));
+	memset(&fattr, 0, sizeof(fattr));
+	EXPECT_EQ(0, test_file_getattr(AT_FDCWD, file1_s1d1, &fattr, 0));
+	EXPECT_EQ(FS_XFLAG_NODUMP, fattr.fa_xflags & FS_XFLAG_NODUMP);
+	memset(&fattr, 0, sizeof(fattr));
+	fattr.fa_xflags = 0;
+	EXPECT_EQ(0, test_file_setattr(fd, NULL, &fattr, AT_EMPTY_PATH));
+
+	/* Non-allowed file: FS_IOC_GETFLAGS and FS_IOC_SETFLAGS */
+	fd2 = open(file2_s1d1, O_RDONLY | O_CLOEXEC);
+	ASSERT_LE(0, fd2);
+	EXPECT_EQ(EACCES, test_getflags(fd2, &flags));
+	EXPECT_EQ(EACCES, test_setflags(fd2, FS_NODUMP_FL));
+
+	/* Non-allowed file: file_getattr(2) and file_setattr(2) */
+	memset(&fattr, 0, sizeof(fattr));
+	EXPECT_EQ(EACCES, test_file_getattr(AT_FDCWD, file2_s1d1, &fattr, 0));
+	fattr.fa_xflags = FS_XFLAG_NODUMP;
+	EXPECT_EQ(EACCES, test_file_setattr(AT_FDCWD, file2_s1d1, &fattr, 0));
+
+	ASSERT_EQ(0, close(fd));
+	ASSERT_EQ(0, close(fd2));
+}
+
+TEST_F_FORK(layout1, fileattr_write_only)
+{
+	const struct rule rules[] = {
+		{
+			.path = file1_s1d1,
+			.access = LANDLOCK_ACCESS_FS_WRITE_METADATA,
+		},
+		{},
+	};
+	unsigned int flags;
+	int fd, ruleset_fd;
+
+	ruleset_fd = create_ruleset(_metadata,
+				    LANDLOCK_ACCESS_FS_WRITE_METADATA, rules);
+	ASSERT_LE(0, ruleset_fd);
+
+	fd = open(file1_s1d1, O_RDONLY | O_CLOEXEC);
+	ASSERT_LE(0, fd);
+
+	enforce_ruleset(_metadata, ruleset_fd);
+	ASSERT_EQ(0, close(ruleset_fd));
+
+	/*
+	 * WRITE_METADATA alone must be enough to set flags: the kernel-side
+	 * read of the old flags must not require READ_METADATA.
+	 */
+	EXPECT_EQ(0, test_setflags(fd, FS_NODUMP_FL));
+	flags = 0;
+	/* READ_METADATA is not handled: reading is allowed. */
+	EXPECT_EQ(0, test_getflags(fd, &flags));
+	EXPECT_EQ(FS_NODUMP_FL, flags & FS_NODUMP_FL);
+	EXPECT_EQ(0, test_setflags(fd, 0));
+
+	ASSERT_EQ(0, close(fd));
+}
+
+TEST_F_FORK(layout2_overlay, fileattr)
+{
+	const struct rule rules[] = {
+		{
+			.path = MERGE_DATA,
+			.access = LANDLOCK_ACCESS_FS_READ_METADATA |
+				  LANDLOCK_ACCESS_FS_WRITE_METADATA,
+		},
+		{},
+	};
+	unsigned int flags;
+	int fd, fd2, ruleset_fd;
+
+	if (self->skip_test)
+		SKIP(return, "overlayfs is not supported (test)");
+
+	ruleset_fd = create_ruleset(
+		_metadata,
+		LANDLOCK_ACCESS_FS_READ_METADATA |
+			LANDLOCK_ACCESS_FS_WRITE_METADATA,
+		rules);
+	ASSERT_LE(0, ruleset_fd);
+
+	enforce_ruleset(_metadata, ruleset_fd);
+	ASSERT_EQ(0, close(ruleset_fd));
+
+	/*
+	 * The overlay mount was created before the ruleset was enforced
+	 * (i.e. as an administrator): the internal forwards to the real
+	 * paths must not interfere with the allowed accesses below.
+	 */
+	fd = open(merge_fl1, O_RDONLY | O_CLOEXEC);
+	ASSERT_LE(0, fd);
+
+	flags = 0;
+	EXPECT_EQ(0, test_getflags(fd, &flags));
+	EXPECT_EQ(0, flags & FS_NODUMP_FL);
+	/* Copies the file up and sets the flag on the upper real file. */
+	EXPECT_EQ(0, test_setflags(fd, FS_NODUMP_FL));
+	flags = 0;
+	EXPECT_EQ(0, test_getflags(fd, &flags));
+	EXPECT_EQ(FS_NODUMP_FL, flags & FS_NODUMP_FL);
+	EXPECT_EQ(0, test_setflags(fd, 0));
+
+	ASSERT_EQ(0, close(fd));
+
+	/* Non-allowed path: raw lower tmpfs path, outside of MERGE_DATA. */
+	fd2 = open(lower_fl1, O_RDONLY | O_CLOEXEC);
+	ASSERT_LE(0, fd2);
+	EXPECT_EQ(EACCES, test_getflags(fd2, &flags));
+	EXPECT_EQ(EACCES, test_setflags(fd2, FS_NODUMP_FL));
+	ASSERT_EQ(0, close(fd2));
+
+	/*
+	 * Removes the copied-up file to keep the upper tree in the state
+	 * expected by FIXTURE_TEARDOWN_PARENT().
+	 */
+	EXPECT_EQ(0, remove_path(merge_fl1));
+}
+
+/*
+ * A landlocked process cannot change the mount topology with mount(2),
+ * even with CAP_SYS_ADMIN (see hook_sb_mount()).  An overlay filesystem
+ * can therefore not be mounted this way by a restricted process.
+ */
+TEST_F_FORK(layout1, overlay_mount_denied)
+{
+	const char lower_dir[] = TMP_DIR "/ovl-lower";
+	const char upper_dir[] = TMP_DIR "/ovl-upper";
+	const char work_dir[] = TMP_DIR "/ovl-work";
+	const char merge_dir[] = TMP_DIR "/ovl-merge";
+	char mount_data[256];
+	const struct rule rules[] = {
+		{
+			.path = merge_dir,
+			.access = LANDLOCK_ACCESS_FS_READ_METADATA |
+				  LANDLOCK_ACCESS_FS_WRITE_METADATA,
+		},
+		{},
+	};
+	int ruleset_fd;
+
+	ASSERT_EQ(0, mkdir(lower_dir, 0700));
+	ASSERT_EQ(0, mkdir(upper_dir, 0700));
+	ASSERT_EQ(0, mkdir(work_dir, 0700));
+	ASSERT_EQ(0, mkdir(merge_dir, 0700));
+
+	snprintf(mount_data, sizeof(mount_data),
+		 "lowerdir=%s,upperdir=%s,workdir=%s", lower_dir, upper_dir,
+		 work_dir);
+
+	ruleset_fd = create_ruleset(
+		_metadata,
+		LANDLOCK_ACCESS_FS_READ_METADATA |
+			LANDLOCK_ACCESS_FS_WRITE_METADATA,
+		rules);
+	ASSERT_LE(0, ruleset_fd);
+
+	enforce_ruleset(_metadata, ruleset_fd);
+	ASSERT_EQ(0, close(ruleset_fd));
+
+	set_cap(_metadata, CAP_SYS_ADMIN);
+	EXPECT_EQ(-1, mount("overlay", merge_dir, "overlay", 0, mount_data));
+	EXPECT_EQ(EPERM, errno);
+	clear_cap(_metadata, CAP_SYS_ADMIN);
+
+	EXPECT_EQ(0, rmdir(lower_dir));
+	EXPECT_EQ(0, rmdir(upper_dir));
+	EXPECT_EQ(0, rmdir(work_dir));
+	EXPECT_EQ(0, rmdir(merge_dir));
+}
+
 TEST_HARNESS_MAIN
diff --git a/tools/testing/selftests/landlock/trace_fs_test.c b/tools/testing/selftests/landlock/trace_fs_test.c
index 64014ade3a0e9..97506d249c4f1 100644
--- a/tools/testing/selftests/landlock/trace_fs_test.c
+++ b/tools/testing/selftests/landlock/trace_fs_test.c
@@ -252,7 +252,8 @@ TEST_F(trace_fs, add_rule_path_beneath)
 TEST_F(trace_fs, add_rule_path_beneath_escaped_path_overflow)
 {
 	static const char access_prefix[] = "execute|write_file|read_file|";
-	static const char access_suffix[] = "|ioctl_dev|resolve_unix";
+	static const char access_suffix[] =
+		"|ioctl_dev|resolve_unix|read_metadata|write_metadata";
 	struct landlock_ruleset_attr ruleset_attr = {
 		.handled_access_fs = LANDLOCK_ACCESS_FS_READ_FILE,
 	};

21/3 2026/10/15 15:57 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 93348
							output: 21
							thoughts: 2898
						

Thoughts:
**KMSAN Analysis of Landlock Path Refactoring**

Alright, let's break down this patch series and determine if a KMSAN fuzzing session is warranted. The goal is to identify if the code changes introduce risks of uninitialized memory reads or information leaks that standard bug detectors wouldn't catch.  The key is to avoid unnecessary KMSAN runs because of the resource cost.

This patch refactors the VFS LSM hooks to use `struct path` instead of inode/dentry.  Essentially, we're transitioning functions like `security_inode_setattr` to `security_path_setattr`, and so on, updating various kernel subsystems to use this new path-based interface.  It seems to involve updates in documentation and changes across several drivers and filesystems, which have been noted. Crucially, the patch also introduces metadata access rights in Landlock.

My immediate focus is pinpointing any instances where *uninitialized* memory could be exposed, particularly in `struct path` or other new or modified structures that are passed around, especially to user space or used in conditional logic.  The guidelines state that this is the primary reason to use KMSAN. I need to be vigilant for cases where structure fields might be read before being assigned a value.

I've carefully examined various files like `devtmpfs.c`, `zloop.c`, `attr.c`, `cachefiles/xattr.c`, `file_attr.c`, `nfsd/vfs.c`, and `overlayfs/` to check where `struct path` is being created, initialized, and passed.  In most cases, the `struct path` instances are initialized in a safe way using designated initializers, or fully initialized by assigning the `mnt` and `dentry` fields. This seems safe.

Specifically, I zoned in on `fs/file_attr.c` because this file has added Landlock support. I was alerted to `ioctl_getflags` and similar functions which use `struct file_kattr`, in case those routines exposed uninitialized members. I reviewed `ioctl_getflags` and it makes calls like `vfs_fileattr_get(&file->f_path, &fa)`. The earlier revision of `vfs_fileattr_get()` had called `security_inode_file_getattr`, so I needed to check what the function `security_path_file_getattr` does. I confirmed that it *doesn't* read `fa` before setting it, which is good.  It calls `current_check_access_path` or `dentry_has_perm`.  It also calls `__vfs_fileattr_get(path->dentry, fa)` and calls `inode->i_op->fileattr_get(dentry, fa)`.

Based on this analysis, I don't see any obvious introduction of uninitialized memory reads or information leaks that would be exposed *only* by KMSAN.  All the places where `struct path` is created and used appear to be handled correctly, with fields being initialized before being used. The changes in `fs/file_attr.c` seem safe. Therefore, this patch does not warrant a dedicated KMSAN fuzzing session. The result is set to "NeedsKMSAN=false".



22/3 2026/10/15 15:58 tool grepper
0m Error:
no matches

Args:
{
  "Expression": "void ovl_path_real"
}

Results:
{
  "error": "no matches"
}

23/3 2026/10/15 15:58 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 96977
							output: 32
							thoughts: 19
						

Thoughts:
Okay, here's my take on those thoughts, tailored for an expert audience and presented in the first person:

**Investigating OverlayFS Path Realization**

Alright, time to get to the bottom of this. My initial instinct is to dive directly into the overlayfs source code. Specifically, I'm thinking about how the kernel handles the "real" paths within an overlay filesystem. The best place to start, I believe, is in the `fs/overlayfs/` directory.

I want to quickly locate the relevant code that deals with determining the underlying path representation for overlay files and directories. To do that, I'm going to leverage my standard workflow and use `grep`. I'll focus on searching for the string `ovl_path_real`. This seems like a reasonable naming convention for a function or variable that's responsible for, or involved in, resolving the real path for an overlay filesystem entry. It's concise and suggests a specific purpose. Let's see what `grep` uncovers. Hopefully, this narrows the playing field down quickly, and gives me a good entry point to understand how overlayfs handles the complexities of its layer-based path mapping.



24/3 2026/10/15 15:58 tool grepper
0m Args:
{
  "Expression": "ovl_path_real",
  "PathPrefixes": [
    "fs/overlayfs/"
  ]
}

Results:
{
  "Output": "fs/overlayfs/file.c=174=static struct file *ovl_real_file(const struct file *file)\n--\nfs/overlayfs/file.c-192-\nfs/overlayfs/file.c:193:\tovl_path_realdata(dentry, \u0026realpath);\nfs/overlayfs/file.c-194-\n--\nfs/overlayfs/file.c=198=static int ovl_open(struct inode *inode, struct file *file)\n--\nfs/overlayfs/file.c-217-\nfs/overlayfs/file.c:218:\tovl_path_realdata(dentry, \u0026realpath);\nfs/overlayfs/file.c-219-\tif (!realpath.dentry)\n--\nfs/overlayfs/inode.c=171=int ovl_getattr(const struct mnt_idmap *idmap, const struct path *path,\n--\nfs/overlayfs/inode.c-187-\nfs/overlayfs/inode.c:188:\ttype = ovl_path_real(dentry, \u0026realpath);\nfs/overlayfs/inode.c-189-\terr = ovl_real_getattr_nosec(sb, \u0026realpath, stat, request_mask, flags);\n--\nfs/overlayfs/inode.c=616=int ovl_fileattr_set(const struct mnt_idmap *idmap,\n--\nfs/overlayfs/inode.c-625-\tif (!err) {\nfs/overlayfs/inode.c:626:\t\tovl_path_real(dentry, \u0026upperpath);\nfs/overlayfs/inode.c-627-\n--\nfs/overlayfs/inode.c=689=int ovl_fileattr_get(struct dentry *dentry, struct file_kattr *fa)\n--\nfs/overlayfs/inode.c-694-\nfs/overlayfs/inode.c:695:\tovl_path_real(dentry, \u0026realpath);\nfs/overlayfs/inode.c-696-\n--\nfs/overlayfs/namei.c=954=static int ovl_maybe_validate_verity(struct dentry *dentry)\n--\nfs/overlayfs/namei.c-978-\nfs/overlayfs/namei.c:979:\tovl_path_real(dentry, \u0026metapath);\nfs/overlayfs/namei.c-980-\tif (!metapath.dentry)\n--\nfs/overlayfs/overlayfs.h=521=struct inode *ovl_i_path_real(struct inode *inode, struct path *path);\nfs/overlayfs/overlayfs.h:522:enum ovl_path_type ovl_path_real(struct dentry *dentry, struct path *path);\nfs/overlayfs/overlayfs.h:523:enum ovl_path_type ovl_path_realdata(struct dentry *dentry, struct path *path);\nfs/overlayfs/overlayfs.h-524-struct dentry *ovl_dentry_upper(struct dentry *dentry);\n--\nfs/overlayfs/readdir.c=1040=static int ovl_dir_open(struct inode *inode, struct file *file)\n--\nfs/overlayfs/readdir.c-1050-\nfs/overlayfs/readdir.c:1051:\ttype = ovl_path_real(file-\u003ef_path.dentry, \u0026realpath);\nfs/overlayfs/readdir.c-1052-\trealfile = ovl_dir_open_realfile(file, \u0026realpath);\n--\nfs/overlayfs/super.c=276=static int ovl_statfs(struct dentry *dentry, struct kstatfs *buf)\n--\nfs/overlayfs/super.c-283-\nfs/overlayfs/super.c:284:\tovl_path_real(root_dentry, \u0026path);\nfs/overlayfs/super.c-285-\n--\nfs/overlayfs/util.c=266=void ovl_path_lowerdata(struct dentry *dentry, struct path *path)\n--\nfs/overlayfs/util.c-285-\nfs/overlayfs/util.c:286:enum ovl_path_type ovl_path_real(struct dentry *dentry, struct path *path)\nfs/overlayfs/util.c-287-{\n--\nfs/overlayfs/util.c-297-\nfs/overlayfs/util.c:298:enum ovl_path_type ovl_path_realdata(struct dentry *dentry, struct path *path)\nfs/overlayfs/util.c-299-{\n--\nfs/overlayfs/xattrs.c=106=ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size)\n--\nfs/overlayfs/xattrs.c-114-\nfs/overlayfs/xattrs.c:115:\tovl_path_real(dentry, \u0026realpath);\nfs/overlayfs/xattrs.c-116-\n"
}

25/3 2026/10/15 15:58 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 98568
							output: 36
							thoughts: 24
						

Thoughts:
Here's my take on those thoughts:

**Peering into the OverlayFS Depths**

Okay, so I need to understand how this overlay filesystem is handling paths internally. My gut tells me that `ovl_path_real` is the key function I need to understand, and it's almost certainly involved in resolving the "real" underlying path within the merged view. Time to crack open `fs/overlayfs/util.c` and dig into that definition. Let's see how this thing actually *works* under the hood. Hopefully, the comments are clear enough... I'm already anticipating having to trace some calls to get the complete picture. This feels like a core operation, so I expect it to be well-written and optimized. Let's get to it!



26/3 2026/10/15 15:58 tool read-file
0m Args:
{
  "File": "fs/overlayfs/util.c",
  "FirstLine": 280,
  "LineCount": 25
}

Results:
{
  "Contents": " 280:\t\t\tpath-\u003emnt = READ_ONCE(lowerdata-\u003elayer)-\u003emnt;\n 281:\t\t} else {\n 282:\t\t\t*path = (struct path) { };\n 283:\t\t}\n 284:\t}\n 285:\t\n 286:\tenum ovl_path_type ovl_path_real(struct dentry *dentry, struct path *path)\n 287:\t{\n 288:\t\tenum ovl_path_type type = ovl_path_type(dentry);\n 289:\t\n 290:\t\tif (!OVL_TYPE_UPPER(type))\n 291:\t\t\tovl_path_lower(dentry, path);\n 292:\t\telse\n 293:\t\t\tovl_path_upper(dentry, path);\n 294:\t\n 295:\t\treturn type;\n 296:\t}\n 297:\t\n 298:\tenum ovl_path_type ovl_path_realdata(struct dentry *dentry, struct path *path)\n 299:\t{\n 300:\t\tenum ovl_path_type type = ovl_path_type(dentry);\n 301:\t\n 302:\t\tWARN_ON_ONCE(d_is_dir(dentry));\n 303:\t\n 304:\t\tif (!OVL_TYPE_UPPER(type) || OVL_TYPE_MERGE(type))\n"
}

27/3 2026/10/15 15:58 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 99184
							output: 34
							thoughts: 1866
						

Thoughts:
**Analyzing the Transition to `struct path` in LSM Hooks**

Okay, so `ovl_path_real` is definitely setting `*path` correctly; that's good. Now, I'm digging into how the `struct path` is being used throughout the filesystem. I checked some specific instances in `fs/smb` to confirm my understanding of the `parent_path` struct initialization. I've noted that it appears to be properly initialized in those SMB-related functions.

Next, I turned my attention to `notify_change` in `fs/attr.c`. I noticed the call stack and how it now includes `security_path_setattr` if the `path` isn't `NULL`.  This is a key point, because I remembered that `notify_change` *used* to call `security_inode_setattr`. The switch to `security_path_setattr` is significant, and I need to consider the implications of this change, in light of how `path` is constructed and passed in those different call-paths.

Now, let's bring Landlock into the picture. I'm reviewing the Landlock LSM hooks that have been added for the new `path_*` functions: `path_getattr`, `path_setattr`, and so on. They all call `current_check_access_path`. I confirmed that `current_check_access_path` doesn't read uninitialized memory; it's using the path to traverse the dentry hierarchy to match against Landlock rules. That's what I expect.

The core of this is the renaming of the LSM hooks to the `path` version: `inode_*` becomes `path_*`. Specifically, I am thinking about the VFS functions that *call* these hooks and how they've been modified to pass `const struct path *path`. This means that functions like `notify_change`, `vfs_setxattr`, etc. now take and pass `struct path`, rather than just `dentry`.

So, the next step is to methodically check every single place in the kernel diff where `struct path` is involved to see if there are any subtle bugs or uninitialized data being passed. I've already checked a few files, like `devtmpfs`, `zloop`, and `cachefiles`, and I didn't see any obvious issues where the `struct path` is being passed uninitialized or partially initialized. However, I need to be *sure*. This is crucial. I still need to go through the complete list of files I generated: `coredump`, `ecryptfs`, `exfat`, `fat`, `file_attr`, `inode`, `namei`, `nfsd`, `ntfs`, `open`, `overlayfs`, `posix_acl`, `ksmbd`, `stat`, `utimes`, and `xattr`. I'll need to double-check that every `struct path` is correctly initialized before it is passed to the VFS or LSM functions.



28/3 2026/10/15 15:58 tool grepper
0m Args:
{
  "Expression": "ecryptfs_lower_path",
  "PathPrefixes": [
    "fs/ecryptfs/"
  ]
}

Results:
{
  "Output": "fs/ecryptfs/ecryptfs_kernel.h=502=static inline struct path\nfs/ecryptfs/ecryptfs_kernel.h:503:ecryptfs_lower_path(struct dentry *dentry)\nfs/ecryptfs/ecryptfs_kernel.h-504-{\n--\nfs/ecryptfs/file.c=32=static ssize_t ecryptfs_read_update_atime(struct kiocb *iocb,\n--\nfs/ecryptfs/file.c-39-\tif (rc \u003e= 0) {\nfs/ecryptfs/file.c:40:\t\tstruct path path = ecryptfs_lower_path(file-\u003ef_path.dentry);\nfs/ecryptfs/file.c-41-\t\ttouch_atime(\u0026path);\n--\nfs/ecryptfs/file.c=56=static ssize_t ecryptfs_splice_read_update_atime(struct file *in, loff_t *ppos,\n--\nfs/ecryptfs/file.c-63-\tif (rc \u003e= 0) {\nfs/ecryptfs/file.c:64:\t\tstruct path path = ecryptfs_lower_path(in-\u003ef_path.dentry);\nfs/ecryptfs/file.c-65-\t\ttouch_atime(\u0026path);\n--\nfs/ecryptfs/file.c=277=static int ecryptfs_dir_open(struct inode *inode, struct file *file)\n--\nfs/ecryptfs/file.c-293-\t}\nfs/ecryptfs/file.c:294:\tpath = ecryptfs_lower_path(ecryptfs_dentry);\nfs/ecryptfs/file.c-295-\tlower_file = dentry_open(\u0026path, file-\u003ef_flags, current_cred());\n--\nfs/ecryptfs/inode.c=733=static int __ecryptfs_truncate(struct dentry *dentry, const struct iattr *ia)\nfs/ecryptfs/inode.c-734-{\nfs/ecryptfs/inode.c:735:\tstruct path lower_path = ecryptfs_lower_path(dentry);\nfs/ecryptfs/inode.c-736-\tstruct dentry *lower_dentry = lower_path.dentry;\n--\nfs/ecryptfs/inode.c=873=static int ecryptfs_setattr(const struct mnt_idmap *idmap,\n--\nfs/ecryptfs/inode.c-927-\t} else {\nfs/ecryptfs/inode.c:928:\t\tstruct path lower_path = ecryptfs_lower_path(dentry);\nfs/ecryptfs/inode.c-929-\t\tstruct iattr lower_ia;\n--\nfs/ecryptfs/inode.c=968=static int ecryptfs_getattr(const struct mnt_idmap *idmap,\n--\nfs/ecryptfs/inode.c-973-\tstruct kstat lower_stat;\nfs/ecryptfs/inode.c:974:\tstruct path lower_path = ecryptfs_lower_path(dentry);\nfs/ecryptfs/inode.c-975-\tint rc;\n--\nfs/ecryptfs/inode.c=989=ecryptfs_setxattr(struct dentry *dentry, struct inode *inode,\n--\nfs/ecryptfs/inode.c-996-\nfs/ecryptfs/inode.c:997:\tlower_path = ecryptfs_lower_path(dentry);\nfs/ecryptfs/inode.c-998-\tlower_inode = d_inode(lower_path.dentry);\n--\nfs/ecryptfs/inode.c=1093=static struct posix_acl *ecryptfs_get_acl(const struct mnt_idmap *idmap,\n--\nfs/ecryptfs/inode.c-1095-{\nfs/ecryptfs/inode.c:1096:\tstruct path lower_path = ecryptfs_lower_path(dentry);\nfs/ecryptfs/inode.c-1097-\n--\nfs/ecryptfs/inode.c=1101=static int ecryptfs_set_acl(const struct mnt_idmap *idmap,\n--\nfs/ecryptfs/inode.c-1105-\tint rc;\nfs/ecryptfs/inode.c:1106:\tstruct path lower_path = ecryptfs_lower_path(dentry);\nfs/ecryptfs/inode.c-1107-\tstruct inode *lower_inode = d_inode(lower_path.dentry);\n--\nfs/ecryptfs/main.c=107=static int ecryptfs_init_lower_file(struct dentry *dentry,\n--\nfs/ecryptfs/main.c-110-\tconst struct cred *cred = current_cred();\nfs/ecryptfs/main.c:111:\tstruct path path = ecryptfs_lower_path(dentry);\nfs/ecryptfs/main.c-112-\tint rc;\n"
}

29/3 2026/10/15 15:58 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 103008
							output: 42
							thoughts: 595
						

Thoughts:
**Path Validation in the Filesystem**

Okay, let's break down this path-handling logic. I see that `ecryptfs_lower_path` appears to be returning a correctly initialized `struct path`, which is a good starting point. Now, let's move onto some further checks.

Points 6 and 7 look promising. We have `file->f_path` being used in `security_path_setattr` (in `exfat` and `fat` file systems) and then subsequently with `vfs_fileattr_get` and `vfs_fileattr_set`. The implication is that `file->f_path` is valid, and we are not seeing any obvious initialization issues. We also see what seems like the same operations, with other paths.

Moving on to point 8, the use of `__remove_privs` with `file->f_path` gives no immediate alarms.

Point 9 shows `handle_truncate` calling `do_truncate` with the `file->f_path` again, and that is as expected, so no problem there.

Finally, in point 10, the NFS code presents some interesting uses of `struct path`. I can see a couple different initialization patterns with `.mnt` and `.dentry` being assigned. It's a bit more involved, but the intent seems clear: build a valid `struct path` from constituent parts, like an export's path and a dentry. In particular I need to check `nfsd4_deleg_getattr_conflict` to verify how path is set, I'll review `fs/nfsd/nfs4xdr.c` at line 4083 to confirm what is really going on.



30/3 2026/10/15 15:59 tool read-file
0m Args:
{
  "File": "fs/nfsd/nfs4xdr.c",
  "FirstLine": 4075,
  "LineCount": 25
}

Results:
{
  "Contents": "4075:\t\tif (exp-\u003eex_fslocs.migrated) {\n4076:\t\t\tstatus = fattr_handle_absent_fs(\u0026attrmask[0], \u0026attrmask[1],\n4077:\t\t\t\t\t\t\t\u0026attrmask[2], \u0026args.rdattr_err);\n4078:\t\t\tif (status)\n4079:\t\t\t\tgoto out;\n4080:\t\t}\n4081:\t\tif ((attrmask[0] \u0026 (FATTR4_WORD0_CHANGE |\n4082:\t\t\t\t    FATTR4_WORD0_SIZE)) ||\n4083:\t\t    (attrmask[1] \u0026 (FATTR4_WORD1_TIME_ACCESS |\n4084:\t\t\t\t    FATTR4_WORD1_TIME_MODIFY |\n4085:\t\t\t\t    FATTR4_WORD1_TIME_METADATA))) {\n4086:\t\t\tstatus = nfsd4_deleg_getattr_conflict(rqstp, \u0026path, \u0026dp);\n4087:\t\t\tif (status)\n4088:\t\t\t\tgoto out;\n4089:\t\t}\n4090:\t\n4091:\t\terr = vfs_getattr(\u0026path, \u0026args.stat,\n4092:\t\t\t\t  STATX_BASIC_STATS | STATX_BTIME | STATX_CHANGE_COOKIE,\n4093:\t\t\t\t  AT_STATX_SYNC_AS_STAT);\n4094:\t\tif (dp) {\n4095:\t\t\tstruct nfs4_cb_fattr *ncf = \u0026dp-\u003edl_cb_fattr;\n4096:\t\n4097:\t\t\tif (ncf-\u003encf_file_modified) {\n4098:\t\t\t\t++ncf-\u003encf_initial_cinfo;\n4099:\t\t\t\targs.stat.size = ncf-\u003encf_cur_fsize;\n"
}

31/3 2026/10/15 15:59 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 104494
							output: 33
							thoughts: 523
						

Thoughts:
**Analyzing Potential Uninitialized Memory Reads in NFS and Related Filesystems**

Okay, so I'm looking at `nfsd4_encode_fattr4` and I see a `struct path path` is created, and it's *definitely* initialized with `.mnt` and `.dentry` right before we use it in `vfs_getattr`. So `&path` is completely initialized. That's good. No issues there.

Now, let's cast a wider net and check other areas. I'm thinking about those SMB modules; `fs/smb/server/...`... Let's see... in `smb2pdu.c`, `smbacl.c`, `vfs.c`, and `vfs_cache.c`, I'm seeing patterns similar to what I expect; `struct path parent_path = { .mnt = path->mnt, .dentry = parent };` and `struct path parent_path = { .mnt = path->mnt, .dentry = path->dentry->d_parent };` are being initialized appropriately. Furthermore, references like `&file->f_path` and `&fp->filp->f_path` are *also* fully initialized. Nothing jumps out as problematic here.

My focus is on making sure there aren't any sneaky data leaks to user space, or uninitialized memory reads occurring. I need to be sure any file or directory path structure is fully initialized when used. Let's dig deeper:

I'm specifically looking at functions like `vfs_fileattr_get`, `ioctl_getflags`, and `ioctl_fsgetxattr` to see if there are any issues...
`ioctl_getflags` uses `struct file_kattr fa = { .flags_valid = true };` and then populates it with `vfs_fileattr_get(&file->f_path, &fa);` and then passes that to user space; no issues, it seems good. Similarly, `ioctl_fsgetxattr` also uses a similar construct, which is also fine. That data flow looks safe.

Ah, I need to investigate Landlock now. New ABI version, new flags... I'm a little concerned. The Landlock subsystem is based on rulesets and path walking which looks at permissions, it should be fine. I'll need to check the code that creates the rulesets, and checks the rules. I'll start by taking a look at `security/landlock/syscalls.c` to see if there's anything concerning in the path usage.



32/3 2026/10/15 15:59 tool grepper
0m Args:
{
  "Expression": "landlock_create_ruleset",
  "PathPrefixes": [
    "security/landlock/"
  ]
}

Results:
{
  "Output": "security/landlock/Kconfig=3=config SECURITY_LANDLOCK\n--\nsecurity/landlock/Kconfig-14-\t  configured and enforced by any processes for themselves using the\nsecurity/landlock/Kconfig:15:\t  dedicated system calls: landlock_create_ruleset(),\nsecurity/landlock/Kconfig-16-\t  landlock_add_rule(), and landlock_restrict_self().\n--\nsecurity/landlock/ruleset.c-33-\nsecurity/landlock/ruleset.c:34:struct landlock_ruleset *landlock_create_ruleset(\nsecurity/landlock/ruleset.c-35-\tconst access_mask_t fs_access_mask, const access_mask_t net_access_mask,\n--\nsecurity/landlock/ruleset.h=154=struct landlock_ruleset {\n--\nsecurity/landlock/ruleset.h-204-\nsecurity/landlock/ruleset.h:205:struct landlock_ruleset *landlock_create_ruleset(\nsecurity/landlock/ruleset.h-206-\tconst access_mask_t access_mask_fs, const access_mask_t access_mask_net,\n--\nsecurity/landlock/syscalls.c=194=const int landlock_abi_version = 13;\n--\nsecurity/landlock/syscalls.c-196-/**\nsecurity/landlock/syscalls.c:197: * sys_landlock_create_ruleset - Create a new ruleset\nsecurity/landlock/syscalls.c-198- *\n--\nsecurity/landlock/syscalls.c-227- * .. kernel-doc:: include/uapi/linux/landlock.h\nsecurity/landlock/syscalls.c:228: *     :identifiers: landlock_create_ruleset_flags\nsecurity/landlock/syscalls.c-229- */\nsecurity/landlock/syscalls.c:230:SYSCALL_DEFINE3(landlock_create_ruleset,\nsecurity/landlock/syscalls.c-231-\t\tconst struct landlock_ruleset_attr __user *const, attr,\n--\nsecurity/landlock/syscalls.c-299-\t/* Checks arguments and transforms to kernel struct. */\nsecurity/landlock/syscalls.c:300:\truleset = landlock_create_ruleset(ruleset_attr.handled_access_fs,\nsecurity/landlock/syscalls.c-301-\t\t\t\t\t  ruleset_attr.handled_access_net,\n--\nsecurity/landlock/syscalls.c-317-\t */\nsecurity/landlock/syscalls.c:318:\ttrace_landlock_create_ruleset(ruleset);\nsecurity/landlock/syscalls.c-319-\n"
}

33/3 2026/10/15 15:59 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 106301
							output: 37
							thoughts: 29
						

Thoughts:
Here's my take on the thought process, from an expert's perspective:

**Diving into the Landlock Kernel Implementation**

Okay, so I need to understand how Landlock is handling its versioning and ruleset creation. My gut tells me that the implementation details around `landlock_abi_version` and `landlock_create_ruleset` are going to be key to any in-depth analysis. I immediately jump to the `syscalls.c` file; that's where the core interaction with user space happens. I anticipate that the kernel's handling of the Landlock ABI version – how it ensures compatibility, or, crucially, handles *in*compatibility – will be tied directly to the system call definition. `landlock_create_ruleset` itself is likely the entry point for configuring Landlock security profiles. I expect to see the meat of the permission checks, ruleset setup, and potentially error handling or resource management within or closely related to this function. I'm especially interested in how it validates rule arguments, and the internal data structures used to store and manage the Landlock rules. Let's see what the code reveals...



34/3 2026/10/15 15:59 tool read-file
0m Args:
{
  "File": "security/landlock/syscalls.c",
  "FirstLine": 230,
  "LineCount": 50
}

Results:
{
  "Contents": " 230:\tSYSCALL_DEFINE3(landlock_create_ruleset,\n 231:\t\t\tconst struct landlock_ruleset_attr __user *const, attr,\n 232:\t\t\tconst size_t, size, const __u32, flags)\n 233:\t{\n 234:\t\tstruct landlock_ruleset_attr ruleset_attr;\n 235:\t\tstruct landlock_ruleset *ruleset;\n 236:\t\tint err, ruleset_fd;\n 237:\t\n 238:\t\t/* Build-time checks. */\n 239:\t\tbuild_check_abi();\n 240:\t\n 241:\t\tif (!is_initialized())\n 242:\t\t\treturn -EOPNOTSUPP;\n 243:\t\n 244:\t\tif (flags) {\n 245:\t\t\tif (attr || size)\n 246:\t\t\t\treturn -EINVAL;\n 247:\t\n 248:\t\t\tif (flags == LANDLOCK_CREATE_RULESET_VERSION)\n 249:\t\t\t\treturn landlock_abi_version;\n 250:\t\n 251:\t\t\tif (flags == LANDLOCK_CREATE_RULESET_ERRATA)\n 252:\t\t\t\treturn landlock_errata;\n 253:\t\n 254:\t\t\treturn -EINVAL;\n 255:\t\t}\n 256:\t\n 257:\t\t/* Copies raw user space buffer. */\n 258:\t\terr = copy_min_struct_from_user(\u0026ruleset_attr, sizeof(ruleset_attr),\n 259:\t\t\t\t\t\toffsetofend(typeof(ruleset_attr),\n 260:\t\t\t\t\t\t\t    handled_access_fs),\n 261:\t\t\t\t\t\tattr, size);\n 262:\t\tif (err)\n 263:\t\t\treturn err;\n 264:\t\n 265:\t\t/* Checks content (and 32-bits cast). */\n 266:\t\tif ((ruleset_attr.handled_access_fs | LANDLOCK_MASK_ACCESS_FS) !=\n 267:\t\t    LANDLOCK_MASK_ACCESS_FS)\n 268:\t\t\treturn -EINVAL;\n 269:\t\n 270:\t\t/* Checks network content (and 32-bits cast). */\n 271:\t\tif ((ruleset_attr.handled_access_net | LANDLOCK_MASK_ACCESS_NET) !=\n 272:\t\t    LANDLOCK_MASK_ACCESS_NET)\n 273:\t\t\treturn -EINVAL;\n 274:\t\n 275:\t\t/* Checks IPC scoping content (and 32-bits cast). */\n 276:\t\tif ((ruleset_attr.scoped | LANDLOCK_MASK_SCOPE) != LANDLOCK_MASK_SCOPE)\n 277:\t\t\treturn -EINVAL;\n 278:\t\n 279:\t\t/*\n"
}

35/3 2026/10/15 15:59 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 107351
							output: 374
							thoughts: 2383
						

Thoughts:
**KMSAN Assessment: No Need for Dedicated Fuzzing**

Alright, let's break this down. My goal is to determine if this patch series necessitates a `NeedsKMSAN=true` flag. The general rule is: if standard bug detectors (KASAN, LOCKDEP, etc.) cover the risks, no KMSAN. We want KMSAN for uninitialized memory risks *only*.

First, I looked at the code changes. The primary function of this patch series is to refactor LSM hooks to accept `struct path` instead of `struct dentry`. This enables path-based access control, which is the whole point of Landlock's metadata rights. Now, here's what I've identified:

*   **No Data Leaks:** The core alteration changes the function signatures to pass file paths. No new methods have been developed which can leak uninitialized memory to user space. There's no modification of `copy_to_user`, `put_user`, netlink, ioctl, BPF, or socket options which would require zeroing.

*   **Initialization is Key:** I've meticulously checked every instance of the `struct path` introduced by these changes. They're all either initialized with designated initializers or through helper functions (e.g., `ovl_path_real`, `ecryptfs_lower_path`). No chance for uninitialized memory usage there.

*   **No Uninitialized Logic Dependence:** The conditional logic isn't dependent on uninitialized data. The `ia_valid` field in `hook_path_setattr` is always initialized by its callers. This eliminates any risk.

*   **No Complex Structures:** There are no complex data structures being introduced that rely on uninitialized fields. `struct path` is just two pointers, and those are always explicitly set.

*   **Bounds Are Okay:** No modifications to bounds checking or the way memory is accessed that introduces uninitialized bytes.

So, the potential bugs are: broken access control and incorrect permission checks or dereferencing invalid paths (like NULL paths). All of these are problems which would be caught by KASAN, normal testing, and functional tests. They are not KMSAN problems. No uninitialized memory is being leaked or used.

Therefore, because this patch series doesn't introduce any *new* risks specifically related to uninitialized memory, `NeedsKMSAN` should definitely be `false`. We can rely on existing bug detectors to catch the bugs that could arise from the changes in path-based LSM checks. This patch's risk is entirely in logic bugs, not KMSAN-detectable memory initialization bugs.

`set-results`.



36/3 2026/10/15 15:59 tool set-results
0m Args:
{
  "KMSANReasoning": "The patch series primarily refactors VFS and LSM interfaces by converting metadata hooks (getattr, setattr, getxattr, setxattr, listxattr, removexattr, get_acl, set_acl, remove_acl, and fileattr get/set) from accepting raw dentries to accepting `const struct path *`, enabling Landlock to enforce access control on file/directory metadata (introducing LANDLOCK_ACCESS_FS_READ_METADATA and LANDLOCK_ACCESS_FS_WRITE_METADATA for Landlock ABI v13).\n\nReviewing memory initialization and data flow:\n1. No uninitialized memory or info-leak vectors: The patch does not introduce or modify any kernel structures copied to user space, nor does it alter data buffer sizing, bounds checks, or padding exposure.\n2. Stack variables: Every newly introduced `struct path` stack variable across drivers and filesystems (devtmpfs, cachefiles, overlayfs, nfsd, ksmbd) is fully initialized via designated initializers (e.g. `{ .mnt = ..., .dentry = ... }`) or helper initializers (`ovl_path_real`, `ecryptfs_lower_path`).\n3. Branching and logic: Control flow changes in Landlock and VFS depend on validated permissions, struct paths, and `iattr` flags; no branching depends on uninitialized data.\n\nAny potential bugs in this patch series would pertain to access control correctness, permission checks, or pointer validity, which are covered by functional tests and standard detectors (KASAN). There are no uninitialized memory risks that would require or benefit from a dedicated KMSAN fuzzing session.",
  "NeedsKMSAN": false
}

Results:
{
  "KMSANReasoning": "The patch series primarily refactors VFS and LSM interfaces by converting metadata hooks (getattr, setattr, getxattr, setxattr, listxattr, removexattr, get_acl, set_acl, remove_acl, and fileattr get/set) from accepting raw dentries to accepting `const struct path *`, enabling Landlock to enforce access control on file/directory metadata (introducing LANDLOCK_ACCESS_FS_READ_METADATA and LANDLOCK_ACCESS_FS_WRITE_METADATA for Landlock ABI v13).\n\nReviewing memory initialization and data flow:\n1. No uninitialized memory or info-leak vectors: The patch does not introduce or modify any kernel structures copied to user space, nor does it alter data buffer sizing, bounds checks, or padding exposure.\n2. Stack variables: Every newly introduced `struct path` stack variable across drivers and filesystems (devtmpfs, cachefiles, overlayfs, nfsd, ksmbd) is fully initialized via designated initializers (e.g. `{ .mnt = ..., .dentry = ... }`) or helper initializers (`ovl_path_real`, `ecryptfs_lower_path`).\n3. Branching and logic: Control flow changes in Landlock and VFS depend on validated permissions, struct paths, and `iattr` flags; no branching depends on uninitialized data.\n\nAny potential bugs in this patch series would pertain to access control correctness, permission checks, or pointer validity, which are covered by functional tests and standard detectors (KASAN). There are no uninitialized memory risks that would require or benefit from a dedicated KMSAN fuzzing session.",
  "NeedsKMSAN": false
}

LLM Calls Summary:
Total Calls Total Tokens Avg Tokens Total Duration (Seconds) Avg Duration (Seconds)
Tool Calls Summary:
Total Calls Total Duration (Seconds) Avg Duration (Seconds)