]>
Commit | Line | Data |
---|---|---|
c0531539 GKH |
1 | From d88c93f090f708c18195553b352b9f205e65418f Mon Sep 17 00:00:00 2001 |
2 | From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
3 | Date: Wed, 23 Jan 2019 11:27:02 +0100 | |
4 | Subject: debugfs: fix debugfs_rename parameter checking | |
5 | ||
6 | From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
7 | ||
8 | commit d88c93f090f708c18195553b352b9f205e65418f upstream. | |
9 | ||
10 | debugfs_rename() needs to check that the dentries passed into it really | |
11 | are valid, as sometimes they are not (i.e. if the return value of | |
12 | another debugfs call is passed into this one.) So fix this up by | |
13 | properly checking if the two parent directories are errors (they are | |
14 | allowed to be NULL), and if the dentry to rename is not NULL or an | |
15 | error. | |
16 | ||
17 | Cc: stable <stable@vger.kernel.org> | |
18 | Signed-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)) |