linux-test-project / ltp

Linux Test Project (mailing list: https://lists.linux.it/listinfo/ltp)
https://linux-test-project.readthedocs.io/
GNU General Public License v2.0
2.27k stars 999 forks source link

write regression test for "attr: block mode changes of symlinks" #1074

Open metan-ucw opened 10 months ago

metan-ucw commented 10 months ago
commit 5d1f903f75a80daa4dfb3d84e114ec8ecbf29956
Author: Christian Brauner <brauner@kernel.org>
Date:   Wed Jul 12 20:58:49 2023 +0200

    attr: block mode changes of symlinks

   Changing the mode of symlinks is meaningless as the vfs doesn't take the
    mode of a symlink into account during path lookup permission checking.

    However, the vfs doesn't block mode changes on symlinks. This however,
    has lead to an untenable mess roughly classifiable into the following
    two categories:

    (1) Filesystems that don't implement a i_op->setattr() for symlinks.

        Such filesystems may or may not know that without i_op->setattr()
        defined, notify_change() falls back to simple_setattr() causing the
        inode's mode in the inode cache to be changed.

        That's a generic issue as this will affect all non-size changing
        inode attributes including ownership changes.

        Example: afs

    (2) Filesystems that fail with EOPNOTSUPP but change the mode of the
        symlink nonetheless.

        Some filesystems will happily update the mode of a symlink but still
        return EOPNOTSUPP. This is the biggest source of confusion for
        userspace.

        The EOPNOTSUPP in this case comes from POSIX ACLs. Specifically it
        comes from filesystems that call posix_acl_chmod(), e.g., btrfs via

            if (!err && attr->ia_valid & ATTR_MODE)
                    err = posix_acl_chmod(idmap, dentry, inode->i_mode);

        Filesystems including btrfs don't implement i_op->set_acl() so
        posix_acl_chmod() will report EOPNOTSUPP.

        When posix_acl_chmod() is called, most filesystems will have
        finished updating the inode.

        Perversely, this has the consequences that this behavior may depend
        on two kconfig options and mount options:

        * CONFIG_POSIX_ACL={y,n}
        * CONFIG_${FSTYPE}_POSIX_ACL={y,n}
        * Opt_acl, Opt_noacl

        Example: btrfs, ext4, xfs
coolgw commented 1 month ago

checking

coolgw commented 1 month ago

https://patchwork.ozlabs.org/project/ltp/patch/20240510002331.31431-1-wegao@suse.com/

coolgw commented 1 month ago

https://patchwork.ozlabs.org/project/ltp/patch/20240510002331.31431-1-wegao@suse.com/

v2 need review https://patchwork.ozlabs.org/project/ltp/patch/20240524085617.32303-1-wegao@suse.com/