All of lore.kernel.org
 help / color / mirror / Atom feed
* Patch "ext4: use dget_parent() in ext4_file_open()" has been added to the 4.5-stable tree
@ 2016-04-17 11:50 gregkh
  0 siblings, 0 replies; only message in thread
From: gregkh @ 2016-04-17 11:50 UTC (permalink / raw)
  To: mszeredi, gregkh, tytso; +Cc: stable, stable-commits


This is a note to let you know that I've just added the patch titled

    ext4: use dget_parent() in ext4_file_open()

to the 4.5-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     ext4-use-dget_parent-in-ext4_file_open.patch
and it can be found in the queue-4.5 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.


>From 9dd78d8c9a7bd4bc341f5864db32d4331b8eae4c Mon Sep 17 00:00:00 2001
From: Miklos Szeredi <mszeredi@redhat.com>
Date: Sat, 26 Mar 2016 16:14:41 -0400
Subject: ext4: use dget_parent() in ext4_file_open()

From: Miklos Szeredi <mszeredi@redhat.com>

commit 9dd78d8c9a7bd4bc341f5864db32d4331b8eae4c upstream.

In f_op->open() lock on parent is not held, so there's no guarantee that
parent dentry won't go away at any time.

Even after this patch there's no guarantee that 'dir' will stay the parent
of 'inode', but at least it won't be freed while being used.

Fixes: ff978b09f973 ("ext4 crypto: move context consistency check to ext4_file_open()")
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 fs/ext4/file.c |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -335,7 +335,7 @@ static int ext4_file_open(struct inode *
 	struct super_block *sb = inode->i_sb;
 	struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
 	struct vfsmount *mnt = filp->f_path.mnt;
-	struct inode *dir = filp->f_path.dentry->d_parent->d_inode;
+	struct dentry *dir;
 	struct path path;
 	char buf[64], *cp;
 	int ret;
@@ -379,14 +379,18 @@ static int ext4_file_open(struct inode *
 		if (ext4_encryption_info(inode) == NULL)
 			return -ENOKEY;
 	}
-	if (ext4_encrypted_inode(dir) &&
-	    !ext4_is_child_context_consistent_with_parent(dir, inode)) {
+
+	dir = dget_parent(filp->f_path.dentry);
+	if (ext4_encrypted_inode(d_inode(dir)) &&
+	    !ext4_is_child_context_consistent_with_parent(d_inode(dir), inode)) {
 		ext4_warning(inode->i_sb,
 			     "Inconsistent encryption contexts: %lu/%lu\n",
-			     (unsigned long) dir->i_ino,
+			     (unsigned long) d_inode(dir)->i_ino,
 			     (unsigned long) inode->i_ino);
+		dput(dir);
 		return -EPERM;
 	}
+	dput(dir);
 	/*
 	 * Set up the jbd2_inode if we are opening the inode for
 	 * writing and the journal is present


Patches currently in stable-queue which might be from mszeredi@redhat.com are

queue-4.5/ext4-use-dget_parent-in-ext4_file_open.patch
queue-4.5/ext4-use-file_dentry.patch
queue-4.5/nfs-use-file_dentry.patch
queue-4.5/fs-add-file_dentry.patch

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-04-17 11:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-17 11:50 Patch "ext4: use dget_parent() in ext4_file_open()" has been added to the 4.5-stable tree gregkh

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.