mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jerry Hoemann <jerry.hoemann@hp.com>
To: akpm@linux-foundation.org, jeffrey.t.kirsher@intel.com,
	kenhelias@firemail.de
Cc: linux-kernel@vger.kernel.org, tmak@hp.com,
	Jerry Hoemann <jerry.hoemann@hp.com>
Subject: [RFC 1/1] fsnotify: next_i is freed during fsnotify_unmount_inodes.
Date: Wed,  8 Oct 2014 16:47:14 -0600	[thread overview]
Message-ID: <1412808434-36030-2-git-send-email-jerry.hoemann@hp.com> (raw)
In-Reply-To: <1412808434-36030-1-git-send-email-jerry.hoemann@hp.com>

During list_for_each_entry_safe, next_i is becoming free causing
the loop to never terminate.  Advance next_i in those cases where
__iget is not done.

Signed-off-by: Jerry Hoemann <jerry.hoemann@hp.com>
---
 fs/notify/inode_mark.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/fs/notify/inode_mark.c b/fs/notify/inode_mark.c
index 9ce0622..e849714 100644
--- a/fs/notify/inode_mark.c
+++ b/fs/notify/inode_mark.c
@@ -288,20 +288,25 @@ void fsnotify_unmount_inodes(struct list_head *list)
 		spin_unlock(&inode->i_lock);
 
 		/* In case the dropping of a reference would nuke next_i. */
-		if ((&next_i->i_sb_list != list) &&
-		    atomic_read(&next_i->i_count)) {
+		while (&next_i->i_sb_list != list) {
 			spin_lock(&next_i->i_lock);
-			if (!(next_i->i_state & (I_FREEING | I_WILL_FREE))) {
+			if (!(next_i->i_state & (I_FREEING | I_WILL_FREE)) &&
+						atomic_read(&next_i->i_count)) {
 				__iget(next_i);
 				need_iput = next_i;
+				spin_unlock(&next_i->i_lock);
+				break;
 			}
 			spin_unlock(&next_i->i_lock);
+			next_i = list_entry(next_i->i_sb_list.next,
+						struct inode, i_sb_list);
 		}
 
 		/*
-		 * We can safely drop inode_sb_list_lock here because we hold
-		 * references on both inode and next_i.  Also no new inodes
-		 * will be added since the umount has begun.
+		 * We can safely drop inode_sb_list_lock here because either
+		 * we actually hold references on both inode and next_i or
+		 * end of list.  Also no new inodes will be added since the
+		 * umount has begun.
 		 */
 		spin_unlock(&inode_sb_list_lock);
 
-- 
1.7.11.3


      reply	other threads:[~2014-10-08 22:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-08 22:47 [RFC 0/1] " Jerry Hoemann
2014-10-08 22:47 ` Jerry Hoemann [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1412808434-36030-2-git-send-email-jerry.hoemann@hp.com \
    --to=jerry.hoemann@hp.com \
    --cc=akpm@linux-foundation.org \
    --cc=jeffrey.t.kirsher@intel.com \
    --cc=kenhelias@firemail.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tmak@hp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®