aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-01-23 05:27:02 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-01-25 06:56:32 -0500
commitd88c93f090f708c18195553b352b9f205e65418f (patch)
tree76d7cecb24578d4a38e2aca3f827c52501508afe
parent3a34c986324c07dde32903f7bb262e6138e77c2a (diff)
debugfs: fix debugfs_rename parameter checking
debugfs_rename() needs to check that the dentries passed into it really are valid, as sometimes they are not (i.e. if the return value of another debugfs call is passed into this one.) So fix this up by properly checking if the two parent directories are errors (they are allowed to be NULL), and if the dentry to rename is not NULL or an error. Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--fs/debugfs/inode.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index 13b01351dd1c..41ef452c1fcf 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -787,6 +787,13 @@ struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
787 struct dentry *dentry = NULL, *trap; 787 struct dentry *dentry = NULL, *trap;
788 struct name_snapshot old_name; 788 struct name_snapshot old_name;
789 789
790 if (IS_ERR(old_dir))
791 return old_dir;
792 if (IS_ERR(new_dir))
793 return new_dir;
794 if (IS_ERR_OR_NULL(old_dentry))
795 return old_dentry;
796
790 trap = lock_rename(new_dir, old_dir); 797 trap = lock_rename(new_dir, old_dir);
791 /* Source or destination directories don't exist? */ 798 /* Source or destination directories don't exist? */
792 if (d_really_is_negative(old_dir) || d_really_is_negative(new_dir)) 799 if (d_really_is_negative(old_dir) || d_really_is_negative(new_dir))