From: Greg Kroah-Hartman Date: Wed, 23 Jan 2019 10:27:02 +0000 (+0100) Subject: debugfs: fix debugfs_rename parameter checking X-Git-Tag: v3.18.135~30 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=64870211efd5d69d115c7798ae089d11919355a9;p=thirdparty%2Fkernel%2Fstable.git debugfs: fix debugfs_rename parameter checking commit d88c93f090f708c18195553b352b9f205e65418f upstream. 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 Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c index 1488e13d6221d..1278abacad056 100644 --- a/fs/debugfs/inode.c +++ b/fs/debugfs/inode.c @@ -622,6 +622,13 @@ struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry, struct dentry *dentry = NULL, *trap; struct name_snapshot old_name; + if (IS_ERR(old_dir)) + return old_dir; + if (IS_ERR(new_dir)) + return new_dir; + if (IS_ERR_OR_NULL(old_dentry)) + return old_dentry; + trap = lock_rename(new_dir, old_dir); /* Source or destination directories don't exist? */ if (!old_dir->d_inode || !new_dir->d_inode)