[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1468282504-2272-1-git-send-email-david.chen@osnexus.com>
Date: Mon, 11 Jul 2016 17:15:04 -0700
From: Chunwei Chen <david.chen@...exus.com>
To: linux-kernel@...r.kernel.org
Cc: Chunwei Chen <david.chen@...exus.com>,
Alexander Viro <viro@...iv.linux.org.uk>,
linux-fsdevel@...r.kernel.org, stable@...r.kernel.org
Subject: [PATCH] vfs: check i_count under lock in evict_inodes
We need to check i_count again with i_lock held, because iput might re-add
i_count when lazytime is on. Without this check, we could end up with
double-free or use-after-free.
Cc: Alexander Viro <viro@...iv.linux.org.uk>
Cc: linux-fsdevel@...r.kernel.org
Cc: linux-kernel@...r.kernel.org
Cc: stable@...r.kernel.org
Signed-off-by: Chunwei Chen <david.chen@...exus.com>
---
fs/inode.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/fs/inode.c b/fs/inode.c
index 4ccbc21..10bb020 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -607,7 +607,12 @@ again:
continue;
spin_lock(&inode->i_lock);
- if (inode->i_state & (I_NEW | I_FREEING | I_WILL_FREE)) {
+ /*
+ * check i_count again with lock, because iput might re-add
+ * it when lazytime is on.
+ */
+ if (atomic_read(&inode->i_count) ||
+ (inode->i_state & (I_NEW | I_FREEING | I_WILL_FREE))) {
spin_unlock(&inode->i_lock);
continue;
}
--
2.7.4
Powered by blists - more mailing lists