Files
Centos-kernel-stream-10/security/apparmor
Rafael Aquini c68e37cd85 Change inode_operations.mkdir to return struct dentry *
JIRA: https://redhat.atlassian.net/browse/RHEL-145694
Conflicts:
  * fs/smb/client/inode.c: minor difference in the 2nd hunk due to out-of-order
    backport of upstream commit f80ac7eda1cf ("cifs: Add a tracepoint to log EIO errors")

commit 88d5baf69082e5b410296435008329676b687549
Author: NeilBrown <neilb@suse.de>
Date:   Thu Feb 27 12:32:53 2025 +1100

    Change inode_operations.mkdir to return struct dentry *

    Some filesystems, such as NFS, cifs, ceph, and fuse, do not have
    complete control of sequencing on the actual filesystem (e.g.  on a
    different server) and may find that the inode created for a mkdir
    request already exists in the icache and dcache by the time the mkdir
    request returns.  For example, if the filesystem is mounted twice the
    directory could be visible on the other mount before it is on the
    original mount, and a pair of name_to_handle_at(), open_by_handle_at()
    calls could instantiate the directory inode with an IS_ROOT() dentry
    before the first mkdir returns.

    This means that the dentry passed to ->mkdir() may not be the one that
    is associated with the inode after the ->mkdir() completes.  Some
    callers need to interact with the inode after the ->mkdir completes and
    they currently need to perform a lookup in the (rare) case that the
    dentry is no longer hashed.

    This lookup-after-mkdir requires that the directory remains locked to
    avoid races.  Planned future patches to lock the dentry rather than the
    directory will mean that this lookup cannot be performed atomically with
    the mkdir.

    To remove this barrier, this patch changes ->mkdir to return the
    resulting dentry if it is different from the one passed in.
    Possible returns are:
      NULL - the directory was created and no other dentry was used
      ERR_PTR() - an error occurred
      non-NULL - this other dentry was spliced in

    This patch only changes file-systems to return "ERR_PTR(err)" instead of
    "err" or equivalent transformations.  Subsequent patches will make
    further changes to some file-systems to return a correct dentry.

    Not all filesystems reliably result in a positive hashed dentry:

    - NFS, cifs, hostfs will sometimes need to perform a lookup of
      the name to get inode information.  Races could result in this
      returning something different. Note that this lookup is
      non-atomic which is what we are trying to avoid.  Placing the
      lookup in filesystem code means it only happens when the filesystem
      has no other option.
    - kernfs and tracefs leave the dentry negative and the ->revalidate
      operation ensures that lookup will be called to correctly populate
      the dentry.  This could be fixed but I don't think it is important
      to any of the users of vfs_mkdir() which look at the dentry.

    The recommendation to use
        d_drop();d_splice_alias()
    is ugly but fits with current practice.  A planned future patch will
    change this.

    Reviewed-by: Jeff Layton <jlayton@kernel.org>
    Reviewed-by: Jan Kara <jack@suse.cz>
    Signed-off-by: NeilBrown <neilb@suse.de>
    Link: https://lore.kernel.org/r/20250227013949.536172-2-neilb@suse.de
    Signed-off-by: Christian Brauner <brauner@kernel.org>

Signed-off-by: Rafael Aquini <raquini@redhat.com>
2026-07-01 16:16:07 -04:00
..
2026-04-07 11:35:55 -03:00
2023-11-19 00:48:12 -08:00
2023-10-18 15:30:47 -07:00
2023-10-18 15:30:47 -07:00
2023-10-18 15:30:47 -07:00
2023-11-12 22:54:42 -05:00