All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] debugfs: fix debugfs_rename parameter checking
@ 2019-01-23 10:27 Greg Kroah-Hartman
  2019-01-23 10:28 ` [PATCH 2/2] debugfs: return error values, not NULL Greg Kroah-Hartman
  0 siblings, 1 reply; 18+ messages in thread
From: Greg Kroah-Hartman @ 2019-01-23 10:27 UTC (permalink / raw)
  To: linux-kernel

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>
---
 fs/debugfs/inode.c | 7 +++++++
 1 file changed, 7 insertions(+)

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,
 	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 (d_really_is_negative(old_dir) || d_really_is_negative(new_dir))
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2019-01-28 16:04 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-23 10:27 [PATCH 1/2] debugfs: fix debugfs_rename parameter checking Greg Kroah-Hartman
2019-01-23 10:28 ` [PATCH 2/2] debugfs: return error values, not NULL Greg Kroah-Hartman
2019-01-23 10:29   ` Greg Kroah-Hartman
2019-01-23 10:31     ` Greg Kroah-Hartman
2019-01-23 11:06   ` Michal Hocko
2019-01-23 11:55     ` Greg Kroah-Hartman
2019-01-23 12:13       ` Michal Hocko
2019-01-23 12:26         ` Greg Kroah-Hartman
2019-01-23 12:40           ` Michal Hocko
2019-01-23 13:00             ` Greg Kroah-Hartman
2019-01-23 13:09               ` Michal Hocko
2019-01-23 13:40                 ` Greg Kroah-Hartman
2019-01-23 13:49                   ` Greg Kroah-Hartman
2019-01-23 13:54                   ` Michal Hocko
2019-01-23 21:32   ` Sebastian Andrzej Siewior
2019-01-24  2:26   ` Masami Hiramatsu
2019-01-28 13:55     ` Masami Hiramatsu
2019-01-28 16:04       ` Greg Kroah-Hartman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.