linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fs: Fix mod_timer crash when removing USB sticks
@ 2012-01-12 21:57 Paul Taysom
  2012-03-16 17:36 ` Greg KH
  0 siblings, 1 reply; 25+ messages in thread
From: Paul Taysom @ 2012-01-12 21:57 UTC (permalink / raw)
  Cc: Paul Taysom, Mandeep Baines, Greg KH, Jens Axboe, Theodore Tso,
	Andrew Morton, linux-usb, linux-kernel, Alexander Viro,
	linux-fsdevel, stable

A USB stick with a ext file system on it, would occasionally crash
when the stick was pulled.

The problem was a timer was being set on the Backing Device Interface,
bdi, after the USB device had been removed and the bdi had been
unregistered. The bdi would then be later reinitialized by zeroing
the timer without removing from the timer from the timer queue.
This would eventually result in a kernel crash (NULL ptr dereference).

When the bdi is unregistered, the dev field is set to NULL. This
indication is used by bdi_unregister to only unregister the device
once.

Fix: When the backing device is invalidated, the mapping backing_dev_info
should be redirected to the default_backing_dev_info.

Created 3 USB sticks with ext2, ext4 and one with both apple and DOS
file systems on it. Inserted and removed USB sticks many times in random
order. With out the bug fix, the kernel would soon crash. With the fix,
it did not. Ran on both stumpy and amd64-generic.

Signed-off-by: Paul Taysom <taysom@chromium.org>
Cc: Mandeep Baines <msb@chromium.org>
Cc: Greg KH <greg@kroah.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Theodore Tso <tytso@google.com>
Cc: Andrew Morton <akpm@google.com>
Cc: <linux-usb@vger.kernel.org>
Cc: <linux-kernel@vger.kernel.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: <linux-fsdevel@vger.kernel.org>
Cc: <stable@kernel.org>
---
 fs/block_dev.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/fs/block_dev.c b/fs/block_dev.c
index afe74dd..322cd05 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -110,6 +110,7 @@ void invalidate_bdev(struct block_device *bdev)
 	 * But, for the strange corners, lets be cautious
 	 */
 	cleancache_flush_inode(mapping);
+	mapping->backing_dev_info = &default_backing_dev_info;
 }
 EXPORT_SYMBOL(invalidate_bdev);
 
-- 
1.7.7.3


^ permalink raw reply related	[flat|nested] 25+ messages in thread
* [PATCH] fs: Fix mod_timer crash when removing USB sticks
@ 2012-01-12 21:15 Paul Taysom
  2012-01-12 21:38 ` Greg KH
  2012-01-13  5:42 ` Josh Boyer
  0 siblings, 2 replies; 25+ messages in thread
From: Paul Taysom @ 2012-01-12 21:15 UTC (permalink / raw)
  Cc: Paul Taysom, Paul Taysom, Mandeep Baines, Olof Johansson,
	Greg KH, Jens Axboe, Theodore Tso, Andrew Morton, linux-usb,
	linux-kernel, Alexander Viro, linux-fsdevel

From: Paul Taysom <taysom@google.com>

A USB stick with a ext file system on it, would occasionally crash
when the stick was pulled.

The problem was a timer was being set on the Backing Device Interface,
bdi, after the USB device had been removed and the bdi had been
unregistered. The bdi would then be later reinitialized by zeroing
the timer without removing from the timer from the timer queue.
This would eventually result in a kernel crash (NULL ptr dereference).

When the bdi is unregistered, the dev field is set to NULL. This
indication is used by bdi_unregister to only unregister the device
once.

Fix: When the backing device is invalidated, the mapping backing_dev_info
should be redirected to the default_backing_dev_info.

Created 3 USB sticks with ext2, ext4 and one with both apple and DOS
file systems on it. Inserted and removed USB sticks many times in random
order. With out the bug fix, the kernel would soon crash. With the fix,
it did not. Ran on both stumpy and amd64-generic.

Change-Id: Icdd06cf3ced555dcd9994cfcc9478a9071a802f1
Signed-off-by: Paul Taysom <taysom@chromium.org>
Downstream-bug-report: http://crosbug.com/24165
Cc: Mandeep Baines <msb@chromium.org>
Cc: Olof Johansson <olofj@chromium.org>
Cc: Greg KH <greg@kroah.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Theodore Tso <tytso@google.com>
Cc: Andrew Morton <akpm@google.com>
Cc: <linux-usb@vger.kernel.org>
Cc: <linux-kernel@vger.kernel.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: <linux-fsdevel@vger.kernel.org>
---
 fs/block_dev.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/fs/block_dev.c b/fs/block_dev.c
index afe74dd..322cd05 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -110,6 +110,7 @@ void invalidate_bdev(struct block_device *bdev)
 	 * But, for the strange corners, lets be cautious
 	 */
 	cleancache_flush_inode(mapping);
+	mapping->backing_dev_info = &default_backing_dev_info;
 }
 EXPORT_SYMBOL(invalidate_bdev);
 
-- 
1.7.7.3


^ permalink raw reply related	[flat|nested] 25+ messages in thread
* [PATCH] fs: Fix mod_timer crash when removing USB sticks
@ 2012-01-12 19:57 Paul Taysom
  2012-01-12 20:15 ` Greg KH
  2012-01-13 11:28 ` Sergei Shtylyov
  0 siblings, 2 replies; 25+ messages in thread
From: Paul Taysom @ 2012-01-12 19:57 UTC (permalink / raw)
  Cc: Paul Taysom, Paul Taysom, Mandeep Baines, Greg KH, Jens Axboe,
	Theodore Tso, Andrew Morton, linux-usb, linux-kernel,
	Alexander Viro, linux-fsdevel

From: Paul Taysom <taysom@google.com>

A USB stick with a ext file system on it, would occasionally crash
when the stick was pulled.

The problem was a timer was being set on the Backing Device Interface,
bdi, after the USB device had been removed and the bdi had been
unregistered. The bdi would then be later reinitialized by zeroing
the timer without removing from the timer from the timer queue.
This would eventually result in a kernel crash (NULL ptr dereference).

When the bdi is unregistered, the dev field is set to NULL. This
indication is used by bdi_unregister to only unregister the device
once.

Fix: When the backing device is invalidated, the mapping backing_dev_info
should be redirected to the default_backing_dev_info.

Created 3 USB sticks with ext2, ext4 and one with both apple and DOS
file systems on it. Inserted and removed USB sticks many times in random
order. With out the bug fix, the kernel would soon crash. With the fix,
it did not. Ran on both stumpy and amd64-generic.

Signed-off-by: Paul Taysom <taysom@chromium.org>
Downstream-bug-report: http://crosbug.com/24165
Cc: Mandeep Baines <msb@chromium.org>
Cc: Greg KH <greg@kroah.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Theodore Tso <tytso@google.com>
Cc: Andrew Morton <akpm@google.com>
Cc: <linux-usb@vger.kernel.org>
Cc: <linux-kernel@vger.kernel.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: <linux-fsdevel@vger.kernel.org>
---
 fs/block_dev.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/fs/block_dev.c b/fs/block_dev.c
index afe74dd..9f9b617 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1,4 +1,4 @@
-/*
+nvalid/*
  *  linux/fs/block_dev.c
  *
  *  Copyright (C) 1991, 1992  Linus Torvalds
@@ -110,6 +110,7 @@ void invalidate_bdev(struct block_device *bdev)
 	 * But, for the strange corners, lets be cautious
 	 */
 	cleancache_flush_inode(mapping);
+	mapping->backing_dev_info = &default_backing_dev_info;
 }
 EXPORT_SYMBOL(invalidate_bdev);
 
-- 
1.7.7.3


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

end of thread, other threads:[~2012-03-22 16:15 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-12 21:57 [PATCH] fs: Fix mod_timer crash when removing USB sticks Paul Taysom
2012-03-16 17:36 ` Greg KH
2012-03-16 19:29   ` Paul Taysom
2012-03-16 19:43     ` Greg KH
2012-03-16 21:10       ` Theodore Tso
2012-03-17  0:06         ` Greg KH
2012-03-17 14:21         ` Alan Stern
2012-03-18  3:44           ` Ted Ts'o
2012-03-18 20:23             ` Alan Stern
2012-03-18 22:25               ` Mandeep Singh Baines
2012-03-20  0:24                 ` Paul Taysom
2012-03-20  2:02                   ` Alan Stern
2012-03-22 16:15                     ` Paul Taysom
  -- strict thread matches above, loose matches on Subject: below --
2012-01-12 21:15 Paul Taysom
2012-01-12 21:38 ` Greg KH
2012-01-12 21:53   ` Mandeep Singh Baines
2012-01-12 22:02     ` Greg KH
2012-01-12 22:11     ` Theodore Tso
     [not found]     ` <CAGagf4dk4KsZSkaWTO9Yegi=_wRJsYBPgfyks1z=wMZJV8gX0w@mail.gmail.com>
2012-01-12 22:35       ` Mandeep Singh Baines
2012-01-12 23:23         ` Andrew Morton
2012-01-13  5:42 ` Josh Boyer
2012-01-13 15:39   ` Paul Taysom
2012-01-12 19:57 Paul Taysom
2012-01-12 20:15 ` Greg KH
2012-01-13 11:28 ` Sergei Shtylyov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).