Merge tag 'v6.6-vfs.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
[linux-2.6-microblaze.git] / fs / attr.c
index 599f6d1..a8ae5f6 100644 (file)
--- a/fs/attr.c
+++ b/fs/attr.c
@@ -394,9 +394,25 @@ int notify_change(struct mnt_idmap *idmap, struct dentry *dentry,
                return error;
 
        if ((ia_valid & ATTR_MODE)) {
-               umode_t amode = attr->ia_mode;
+               /*
+                * Don't allow changing the mode of symlinks:
+                *
+                * (1) The vfs doesn't take the mode of symlinks into account
+                *     during permission checking.
+                * (2) This has never worked correctly. Most major filesystems
+                *     did return EOPNOTSUPP due to interactions with POSIX ACLs
+                *     but did still updated the mode of the symlink.
+                *     This inconsistency led system call wrapper providers such
+                *     as libc to block changing the mode of symlinks with
+                *     EOPNOTSUPP already.
+                * (3) To even do this in the first place one would have to use
+                *     specific file descriptors and quite some effort.
+                */
+               if (S_ISLNK(inode->i_mode))
+                       return -EOPNOTSUPP;
+
                /* Flag setting protected by i_mutex */
-               if (is_sxid(amode))
+               if (is_sxid(attr->ia_mode))
                        inode->i_flags &= ~S_NOSEC;
        }