block fixes for 2.6.32-rc
Subsystems (2)
Hi Linus,
Two important one-liners, both fixing a regression. Please pull.
git://git.kernel.dk/linux-2.6-block.git for-linus
Mark McLoughlin (1):
block: silently error unsupported empty barriers too
Neil Brown (1):
block: use after free bug in __blkdev_get
block/blk-core.c | 2 +- fs/block_dev.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
block/blk-core.c +1 -1
@@ -1161,7 +1161,7 @@ static int __make_request(struct request_queue *q, struct bio *bio)const unsigned int ff = bio->bi_rw &REQ_FAILFAST_MASK ;int rw_flags; -if (bio_rw_flagged (bio,BIO_RW_BARRIER ) &&bio_has_data (bio) && +if (bio_rw_flagged (bio,BIO_RW_BARRIER ) && (q->next_ordered ==QUEUE_ORDERED_NONE )) {bio_endio (bio, -EOPNOTSUPP );return 0 ;
fs/block_dev.c +1 -1
@@ -1248,8 +1248,8 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)bd_set_size (bdev, (loff_t )bdev->bd_part->nr_sects <<9 ); } }else { -put_disk (disk);module_put (disk->fops->owner); +put_disk (disk); disk =NULL ;if (bdev->bd_contains == bdev) {if (bdev->bd_disk->fops->open) {
Signature · 1 line
Jens Axboe
Quoted 9 lines · Jens Axboe
Neil Brown (1):
block: use after free bug in__blkdev_getfs/block_dev.c +0
-0
fs/block_dev.c static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) · line 1255
Quoted 9 lines
fs/block_dev.c +1
-1@@ -1248,8 +1248,8 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)bd_set_size (bdev, (loff_t )bdev->bd_part->nr_sects <<9 ); } }else { -put_disk (disk);module_put (disk->fops->owner); +put_disk (disk); disk =NULL ;if (bdev->bd_contains == bdev) {if (bdev->bd_disk->fops->open) {
Is this really right? You do the module-put while the disk is still available..
I get the feeling that it might have been better to do
struct module *mod = disk->fops->owner; put_disk(disk); module_put(mod);
instead, which tries to make sure that the module is put only after we've gotten rid of the disk entirely.
But I dunno. Maybe there is some reason why it's safe either way. You're sure the kobject_put() in put_disk will never call to the module?
Linus
Quoted 31 lines · Linus Torvalds
Quoted 9 lines · Jens Axboe
Neil Brown (1):
block: use after free bug in__blkdev_getfs/block_dev.c +0
-0fs/block_dev.c static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) · line 1255
Quoted 9 lines
fs/block_dev.c +1
-1@@ -1248,8 +1248,8 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)bd_set_size (bdev, (loff_t )bdev->bd_part->nr_sects <<9 ); } }else { -put_disk (disk);module_put (disk->fops->owner); +put_disk (disk); disk =NULL ;if (bdev->bd_contains == bdev) {if (bdev->bd_disk->fops->open) {Is this really right? You do the module-put while the disk is still available..
I get the feeling that it might have been better to do
struct module *mod = disk->fops->owner; put_disk(disk); module_put(mod);
Quoted 5 lines
instead, which tries to make sure that the module is put only after we've gotten rid of the disk entirely.
But I dunno. Maybe there is some reason why it's safe either way. You're sure the
kobject_put()input_diskwill never call to the module?
Hmm good point. The general use case in block_dev.c is indeed to put the module after the disk, which does seem a bit backwards (at least logically). I'd say pull the patch since it fixes Neil's problem and follows the general pattern, then I'll investigate whether that use pattern is indeed safe. It wont make things worse and the current usage being fixed is definitely wrong.
Signature · 1 line
Jens Axboe
Quoted 38 lines · Jens Axboe
Quoted 31 lines · Linus Torvalds
Quoted 9 lines · Jens Axboe
Neil Brown (1):
block: use after free bug in__blkdev_getfs/block_dev.c +0
-0fs/block_dev.c static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) · line 1255
Quoted 9 lines
fs/block_dev.c +1
-1@@ -1248,8 +1248,8 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)bd_set_size (bdev, (loff_t )bdev->bd_part->nr_sects <<9 ); } }else { -put_disk (disk);module_put (disk->fops->owner); +put_disk (disk); disk =NULL ;if (bdev->bd_contains == bdev) {if (bdev->bd_disk->fops->open) {Is this really right? You do the module-put while the disk is still available..
I get the feeling that it might have been better to do
struct module *mod = disk->fops->owner; put_disk(disk); module_put(mod);Quoted 5 lines
instead, which tries to make sure that the module is put only after we've gotten rid of the disk entirely.
But I dunno. Maybe there is some reason why it's safe either way. You're sure the
kobject_put()input_diskwill never call to the module?
Quoted 6 lines
Hmm good point. The general use case in
block_dev.cis indeed to put the module after the disk, which does seem a bit backwards (at least logically). I'd say pull the patch since it fixes Neil's problem and follows the general pattern, then I'll investigate whether that use pattern is indeed safe. It wont make things worse and the current usage being fixed is definitely wrong.
So if I'm following the convoluted mazes of the kobjects correctly, the release is disk_release() and it only does a free+release of the disk, partition, and related partition table. So doing the module_put() before the put_disk() is safe, even if it does look odd.
Signature · 1 line
Jens Axboe