Merge commit 'v3.15' into next
[sfrench/cifs-2.6.git] / security / security.c
index d91fec458e905053872cd9737b819ea142de9989..31614e9e96e556883aa947fc1360e9e03127883d 100644 (file)
@@ -433,11 +433,20 @@ int security_path_link(struct dentry *old_dentry, struct path *new_dir,
 }
 
 int security_path_rename(struct path *old_dir, struct dentry *old_dentry,
-                        struct path *new_dir, struct dentry *new_dentry)
+                        struct path *new_dir, struct dentry *new_dentry,
+                        unsigned int flags)
 {
        if (unlikely(IS_PRIVATE(old_dentry->d_inode) ||
                     (new_dentry->d_inode && IS_PRIVATE(new_dentry->d_inode))))
                return 0;
+
+       if (flags & RENAME_EXCHANGE) {
+               int err = security_ops->path_rename(new_dir, new_dentry,
+                                                   old_dir, old_dentry);
+               if (err)
+                       return err;
+       }
+
        return security_ops->path_rename(old_dir, old_dentry, new_dir,
                                         new_dentry);
 }
@@ -524,11 +533,20 @@ int security_inode_mknod(struct inode *dir, struct dentry *dentry, umode_t mode,
 }
 
 int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry,
-                          struct inode *new_dir, struct dentry *new_dentry)
+                          struct inode *new_dir, struct dentry *new_dentry,
+                          unsigned int flags)
 {
         if (unlikely(IS_PRIVATE(old_dentry->d_inode) ||
             (new_dentry->d_inode && IS_PRIVATE(new_dentry->d_inode))))
                return 0;
+
+       if (flags & RENAME_EXCHANGE) {
+               int err = security_ops->inode_rename(new_dir, new_dentry,
+                                                    old_dir, old_dentry);
+               if (err)
+                       return err;
+       }
+
        return security_ops->inode_rename(old_dir, old_dentry,
                                           new_dir, new_dentry);
 }