* [PATCH] block: fix refcounting in BLKBSZSET
@ 2011-02-24 14:48 Miklos Szeredi
2011-02-24 14:54 ` Tejun Heo
2011-02-24 15:06 ` Mike Snitzer
0 siblings, 2 replies; 4+ messages in thread
From: Miklos Szeredi @ 2011-02-24 14:48 UTC (permalink / raw)
To: akpm, torvalds; +Cc: kovariadam, florian, rjw, tj, linux-kernel
[and lkml cc-d too]
This fixes bug 29202 in the 2.6.38 regression list.
Please apply.
Thanks,
Miklos
----
Subject: block: fix refcounting in BLKBSZSET
From: Miklos Szeredi <mszeredi@suse.cz>
Adam Kovari and others reported that disconnecting an USB drive with
an ntfs-3g filesystem would cause "kernel BUG at fs/inode.c:1421!" to
be triggered.
The BUG could be traced back to ioctl(BLKBSZSET), which would
erroneously decrement the refcount on the bdev. This is because
blkdev_get() expects the refcount to be already incremented and either
returns success or decrements the refcount and returns an error.
The bug was introduced by e525fd89 (block: make blkdev_get/put()
handle exclusive access), which didn't take into account this behavior
of blkdev_get().
Reported-by: Adam Kovari <kovariadam@gmail.com>
CC: Tejun Heo <tj@kernel.org>
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
---
block/ioctl.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
Index: linux.git/block/ioctl.c
===================================================================
--- linux.git.orig/block/ioctl.c 2011-01-18 09:02:44.000000000 +0100
+++ linux.git/block/ioctl.c 2011-02-24 14:23:56.000000000 +0100
@@ -294,9 +294,11 @@ int blkdev_ioctl(struct block_device *bd
return -EINVAL;
if (get_user(n, (int __user *) arg))
return -EFAULT;
- if (!(mode & FMODE_EXCL) &&
- blkdev_get(bdev, mode | FMODE_EXCL, &bdev) < 0)
- return -EBUSY;
+ if (!(mode & FMODE_EXCL)) {
+ bdgrab(bdev);
+ if (blkdev_get(bdev, mode | FMODE_EXCL, &bdev) < 0)
+ return -EBUSY;
+ }
ret = set_blocksize(bdev, n);
if (!(mode & FMODE_EXCL))
blkdev_put(bdev, mode | FMODE_EXCL);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] block: fix refcounting in BLKBSZSET
2011-02-24 14:48 [PATCH] block: fix refcounting in BLKBSZSET Miklos Szeredi
@ 2011-02-24 14:54 ` Tejun Heo
2011-02-24 15:06 ` Mike Snitzer
1 sibling, 0 replies; 4+ messages in thread
From: Tejun Heo @ 2011-02-24 14:54 UTC (permalink / raw)
To: Miklos Szeredi; +Cc: akpm, torvalds, kovariadam, florian, rjw, linux-kernel
On Thu, Feb 24, 2011 at 03:48:33PM +0100, Miklos Szeredi wrote:
> [and lkml cc-d too]
>
> This fixes bug 29202 in the 2.6.38 regression list.
>
> Please apply.
>
> Thanks,
> Miklos
>
> ----
> Subject: block: fix refcounting in BLKBSZSET
>
> From: Miklos Szeredi <mszeredi@suse.cz>
>
> Adam Kovari and others reported that disconnecting an USB drive with
> an ntfs-3g filesystem would cause "kernel BUG at fs/inode.c:1421!" to
> be triggered.
>
> The BUG could be traced back to ioctl(BLKBSZSET), which would
> erroneously decrement the refcount on the bdev. This is because
> blkdev_get() expects the refcount to be already incremented and either
> returns success or decrements the refcount and returns an error.
>
> The bug was introduced by e525fd89 (block: make blkdev_get/put()
> handle exclusive access), which didn't take into account this behavior
> of blkdev_get().
>
> Reported-by: Adam Kovari <kovariadam@gmail.com>
> CC: Tejun Heo <tj@kernel.org>
> Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Ah, it was me after all. Sorry about that.
Acked-by: Tejun Heo <tj@kernel.org>
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] block: fix refcounting in BLKBSZSET
2011-02-24 14:48 [PATCH] block: fix refcounting in BLKBSZSET Miklos Szeredi
2011-02-24 14:54 ` Tejun Heo
@ 2011-02-24 15:06 ` Mike Snitzer
2011-02-24 15:20 ` Florian Mickler
1 sibling, 1 reply; 4+ messages in thread
From: Mike Snitzer @ 2011-02-24 15:06 UTC (permalink / raw)
To: Miklos Szeredi
Cc: akpm, torvalds, kovariadam, florian, rjw, tj, linux-kernel,
Alasdair G Kergon, psusi
On Thu, Feb 24, 2011 at 9:48 AM, Miklos Szeredi <miklos@szeredi.hu> wrote:
> [and lkml cc-d too]
>
> This fixes bug 29202 in the 2.6.38 regression list.
It looks like this may fix bug 29792 too.
Mike
> Please apply.
>
> Thanks,
> Miklos
>
> ----
> Subject: block: fix refcounting in BLKBSZSET
>
> From: Miklos Szeredi <mszeredi@suse.cz>
>
> Adam Kovari and others reported that disconnecting an USB drive with
> an ntfs-3g filesystem would cause "kernel BUG at fs/inode.c:1421!" to
> be triggered.
>
> The BUG could be traced back to ioctl(BLKBSZSET), which would
> erroneously decrement the refcount on the bdev. This is because
> blkdev_get() expects the refcount to be already incremented and either
> returns success or decrements the refcount and returns an error.
>
> The bug was introduced by e525fd89 (block: make blkdev_get/put()
> handle exclusive access), which didn't take into account this behavior
> of blkdev_get().
>
> Reported-by: Adam Kovari <kovariadam@gmail.com>
> CC: Tejun Heo <tj@kernel.org>
> Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
> ---
> block/ioctl.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> Index: linux.git/block/ioctl.c
> ===================================================================
> --- linux.git.orig/block/ioctl.c 2011-01-18 09:02:44.000000000 +0100
> +++ linux.git/block/ioctl.c 2011-02-24 14:23:56.000000000 +0100
> @@ -294,9 +294,11 @@ int blkdev_ioctl(struct block_device *bd
> return -EINVAL;
> if (get_user(n, (int __user *) arg))
> return -EFAULT;
> - if (!(mode & FMODE_EXCL) &&
> - blkdev_get(bdev, mode | FMODE_EXCL, &bdev) < 0)
> - return -EBUSY;
> + if (!(mode & FMODE_EXCL)) {
> + bdgrab(bdev);
> + if (blkdev_get(bdev, mode | FMODE_EXCL, &bdev) < 0)
> + return -EBUSY;
> + }
> ret = set_blocksize(bdev, n);
> if (!(mode & FMODE_EXCL))
> blkdev_put(bdev, mode | FMODE_EXCL);
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] block: fix refcounting in BLKBSZSET
2011-02-24 15:06 ` Mike Snitzer
@ 2011-02-24 15:20 ` Florian Mickler
0 siblings, 0 replies; 4+ messages in thread
From: Florian Mickler @ 2011-02-24 15:20 UTC (permalink / raw)
To: Miklos Szeredi
Cc: Mike Snitzer, akpm, torvalds, kovariadam, rjw, tj, linux-kernel,
Alasdair G Kergon, psusi
Hi,
2011/2/24 Mike Snitzer <snitzer@redhat.com>:
> On Thu, Feb 24, 2011 at 9:48 AM, Miklos Szeredi <miklos@szeredi.hu> wrote:
>> [and lkml cc-d too]
>>
>> This fixes bug 29202 in the 2.6.38 regression list.
>
> It looks like this may fix bug 29792 too.
>
> Mike
>
>> Please apply.
>>
>> Thanks,
>> Miklos
>>
>> ----
>> Subject: block: fix refcounting in BLKBSZSET
>>
>> From: Miklos Szeredi <mszeredi@suse.cz>
>>
>> Adam Kovari and others reported that disconnecting an USB drive with
>> an ntfs-3g filesystem would cause "kernel BUG at fs/inode.c:1421!" to
>> be triggered.
>>
>> The BUG could be traced back to ioctl(BLKBSZSET), which would
>> erroneously decrement the refcount on the bdev. This is because
>> blkdev_get() expects the refcount to be already incremented and either
>> returns success or decrements the refcount and returns an error.
>>
>> The bug was introduced by e525fd89 (block: make blkdev_get/put()
>> handle exclusive access), which didn't take into account this behavior
>> of blkdev_get().
>>
putting a small reference to the bug reports in the changelog
(it is enough to have the bugnumber in there somewhere, grepping for 5
digit numbers doesn't turn up all too many false positives... )
helps with keeping track of the regressions and letting people know
that a fix / change was posted.
A line like "This fixes bug 29202." is sufficient.
Pasting a complete link( i.e.
https://bugzilla.kernel.org/show_bug.cgi?id=29202 ) would even allow
for an automated note in the bugzilla when it hits Linus tree.
Cheers,
Flo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-02-24 15:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-24 14:48 [PATCH] block: fix refcounting in BLKBSZSET Miklos Szeredi
2011-02-24 14:54 ` Tejun Heo
2011-02-24 15:06 ` Mike Snitzer
2011-02-24 15:20 ` Florian Mickler
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®