]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - fs/inode.c
ext4: zero out the unused memory region in the extent tree block
[mirror_ubuntu-bionic-kernel.git] / fs / inode.c
index 03102d6ef044d484ee9d7d1c9731437a4418d2c9..7de7df08fe48422c726a39d761cbc399ad35d4eb 100644 (file)
@@ -177,6 +177,7 @@ int inode_init_always(struct super_block *sb, struct inode *inode)
        mapping->a_ops = &empty_aops;
        mapping->host = inode;
        mapping->flags = 0;
+       mapping->wb_err = 0;
        atomic_set(&mapping->i_mmap_writable, 0);
        mapping_set_gfp_mask(mapping, GFP_HIGHUSER_MOVABLE);
        mapping->private_data = NULL;
@@ -1655,7 +1656,7 @@ EXPORT_SYMBOL(generic_update_time);
  * This does the actual work of updating an inodes time or version.  Must have
  * had called mnt_want_write() before calling this.
  */
-static int update_time(struct inode *inode, struct timespec *time, int flags)
+int update_time(struct inode *inode, struct timespec *time, int flags)
 {
        int (*update_time)(struct inode *, struct timespec *, int);
 
@@ -1664,6 +1665,7 @@ static int update_time(struct inode *inode, struct timespec *time, int flags)
 
        return update_time(inode, time, flags);
 }
+EXPORT_SYMBOL_GPL(update_time);
 
 /**
  *     touch_atime     -       update the access time
@@ -1749,7 +1751,8 @@ EXPORT_SYMBOL(touch_atime);
  */
 int should_remove_suid(struct dentry *dentry)
 {
-       umode_t mode = d_inode(dentry)->i_mode;
+       struct inode *inode = d_inode(dentry);
+       umode_t mode = inode->i_mode;
        int kill = 0;
 
        /* suid always must be killed */
@@ -1763,7 +1766,8 @@ int should_remove_suid(struct dentry *dentry)
        if (unlikely((mode & S_ISGID) && (mode & S_IXGRP)))
                kill |= ATTR_KILL_SGID;
 
-       if (unlikely(kill && !capable(CAP_FSETID) && S_ISREG(mode)))
+       if (unlikely(kill && !capable_wrt_inode_uidgid(inode, CAP_FSETID) &&
+                    S_ISREG(mode)))
                return kill;
 
        return 0;
@@ -2005,8 +2009,14 @@ void inode_init_owner(struct inode *inode, const struct inode *dir,
        inode->i_uid = current_fsuid();
        if (dir && dir->i_mode & S_ISGID) {
                inode->i_gid = dir->i_gid;
+
+               /* Directories are special, and always inherit S_ISGID */
                if (S_ISDIR(mode))
                        mode |= S_ISGID;
+               else if ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP) &&
+                        !in_group_p(inode->i_gid) &&
+                        !capable_wrt_inode_uidgid(dir, CAP_FSETID))
+                       mode &= ~S_ISGID;
        } else
                inode->i_gid = current_fsgid();
        inode->i_mode = mode;