All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] CIFS: Fix kernel crash on simultaneous mount/umount calls
@ 2011-06-09 12:29 Pavel Shilovsky
       [not found] ` <1307622570-7141-1-git-send-email-piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 17+ messages in thread
From: Pavel Shilovsky @ 2011-06-09 12:29 UTC (permalink / raw)
  To: linux-cifs-u79uwXL29TY76Z2rM5mHXA

Recently merged shared-sb capability causes kernel to crash when
we try to do mounts and umounts simultaneously on the same machine.
The patch fixes umount codepath by doing kill_anon_super at first
(it calls generic_shutdown_super that tries to take sb_lock and
removes a superblock from fs_supers list) and then processing
cifs_umount (that frees cifs related fields).

In this case when we call sget and it calls cifs_match_super under
sb_lock for every entry from fs_supers list, we can be sure that
all cifs related fields are not freed by simultaneous umount.

Signed-off-by: Pavel Shilovsky <piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 fs/cifs/cifsfs.c |   19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 989442d..3537e7d 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -180,16 +180,30 @@ out_mount_failed:
 static void
 cifs_put_super(struct super_block *sb)
 {
+	struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
+	if (cifs_sb == NULL) {
+		cFYI(1, "Empty cifs superblock info passed to put_super");
+		return;
+	}
+
+	bdi_destroy(&cifs_sb->bdi);
+}
+
+static void
+cifs_kill_super(struct super_block *sb)
+{
 	int rc = 0;
 	struct cifs_sb_info *cifs_sb;
 
 	cFYI(1, "In cifs_put_super");
 	cifs_sb = CIFS_SB(sb);
 	if (cifs_sb == NULL) {
-		cFYI(1, "Empty cifs superblock info passed to unmount");
+		cFYI(1, "Empty cifs superblock info passed to kill_super");
 		return;
 	}
 
+	kill_anon_super(sb);
+
 	rc = cifs_umount(sb, cifs_sb);
 	if (rc)
 		cERROR(1, "cifs_umount failed with return code %d", rc);
@@ -199,7 +213,6 @@ cifs_put_super(struct super_block *sb)
 	}
 
 	unload_nls(cifs_sb->local_nls);
-	bdi_destroy(&cifs_sb->bdi);
 	kfree(cifs_sb);
 }
 
@@ -807,7 +820,7 @@ struct file_system_type cifs_fs_type = {
 	.owner = THIS_MODULE,
 	.name = "cifs",
 	.mount = cifs_do_mount,
-	.kill_sb = kill_anon_super,
+	.kill_sb = cifs_kill_super,
 	/*  .fs_flags */
 };
 const struct inode_operations cifs_dir_inode_ops = {
-- 
1.7.1

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

end of thread, other threads:[~2011-06-24 23:03 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-09 12:29 [PATCH] CIFS: Fix kernel crash on simultaneous mount/umount calls Pavel Shilovsky
     [not found] ` <1307622570-7141-1-git-send-email-piastryyy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-06-09 12:40   ` Christoph Hellwig
     [not found]     ` <20110609124043.GA9621-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2011-06-09 16:30       ` Pavel Shilovsky
     [not found]         ` <BANLkTikmfKtDxG_6qg+6JiCT2FzF1FFfQg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-06-10  6:00           ` Pavel Shilovsky
2011-06-11  9:43           ` Christoph Hellwig
     [not found]             ` <20110611094314.GA6217-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2011-06-11 11:12               ` Al Viro
     [not found]                 ` <20110611111253.GD11521-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org>
2011-06-11 14:00                   ` Pavel Shilovsky
     [not found]                     ` <BANLkTim==J7=-bEz1pahhKuxFdMFe2BnWg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-06-17  3:54                       ` Al Viro
     [not found]                         ` <20110617035421.GO11521-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org>
2011-06-17 14:08                           ` Al Viro
     [not found]                             ` <20110617140833.GA9563-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org>
2011-06-20 12:54                               ` Pavel Shilovsky
     [not found]                                 ` <BANLkTi=mH-9F9N4Gz8JJqL==Hm5p8Y1_tQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-06-20 12:59                                   ` Jeff Layton
     [not found]                                     ` <20110620085943.6371af1b-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org>
2011-06-20 16:13                                       ` Steve French
     [not found]                                         ` <BANLkTinfETnDdcBFkQNq8pLZPQOGsVRuGA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-06-20 16:15                                           ` Al Viro
     [not found]                                             ` <20110620161516.GU11521-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org>
2011-06-24  8:47                                               ` Pavel Shilovsky
     [not found]                                                 ` <BANLkTi=nYfiy0qnHPXs2fckCPNJXwbpi7Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-06-24 10:48                                                   ` Jeff Layton
     [not found]                                                     ` <20110624064810.495dec99-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org>
2011-06-24 22:54                                                       ` [git pull] ->mount() regression fixes for cifs Al Viro
     [not found]                                                         ` <20110624225414.GA11013-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org>
2011-06-24 23:03                                                           ` Steve French

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.