Merge commit 'v3.15' into next
[sfrench/cifs-2.6.git] / security / security.c
index 919cad93ac82fa2fa7c017b5c85353ca8ac6818e..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);
 }
@@ -1407,7 +1425,7 @@ void security_key_free(struct key *key)
 }
 
 int security_key_permission(key_ref_t key_ref,
-                           const struct cred *cred, key_perm_t perm)
+                           const struct cred *cred, unsigned perm)
 {
        return security_ops->key_permission(key_ref, cred, perm);
 }