]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.19.22/debugfs-fix-debugfs_rename-parameter-checking.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.19.22 / debugfs-fix-debugfs_rename-parameter-checking.patch
CommitLineData
c0531539
GKH
1From d88c93f090f708c18195553b352b9f205e65418f Mon Sep 17 00:00:00 2001
2From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3Date: Wed, 23 Jan 2019 11:27:02 +0100
4Subject: debugfs: fix debugfs_rename parameter checking
5
6From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
7
8commit d88c93f090f708c18195553b352b9f205e65418f upstream.
9
10debugfs_rename() needs to check that the dentries passed into it really
11are valid, as sometimes they are not (i.e. if the return value of
12another debugfs call is passed into this one.) So fix this up by
13properly checking if the two parent directories are errors (they are
14allowed to be NULL), and if the dentry to rename is not NULL or an
15error.
16
17Cc: stable <stable@vger.kernel.org>
18Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
19
20---
21 fs/debugfs/inode.c | 7 +++++++
22 1 file changed, 7 insertions(+)
23
24--- a/fs/debugfs/inode.c
25+++ b/fs/debugfs/inode.c
26@@ -787,6 +787,13 @@ struct dentry *debugfs_rename(struct den
27 struct dentry *dentry = NULL, *trap;
28 struct name_snapshot old_name;
29
30+ if (IS_ERR(old_dir))
31+ return old_dir;
32+ if (IS_ERR(new_dir))
33+ return new_dir;
34+ if (IS_ERR_OR_NULL(old_dentry))
35+ return old_dentry;
36+
37 trap = lock_rename(new_dir, old_dir);
38 /* Source or destination directories don't exist? */
39 if (d_really_is_negative(old_dir) || d_really_is_negative(new_dir))