Hou Tao
b9a41d21dc
dm: fix race between dm_get_from_kobject() and __dm_destroy()
...
The following BUG_ON was hit when testing repeat creation and removal of
DM devices:
kernel BUG at drivers/md/dm.c:2919!
CPU: 7 PID: 750 Comm: systemd-udevd Not tainted 4.1.44
Call Trace:
[<ffffffff81649e8b>] dm_get_from_kobject+0x34/0x3a
[<ffffffff81650ef1>] dm_attr_show+0x2b/0x5e
[<ffffffff817b46d1>] ? mutex_lock+0x26/0x44
[<ffffffff811df7f5>] sysfs_kf_seq_show+0x83/0xcf
[<ffffffff811de257>] kernfs_seq_show+0x23/0x25
[<ffffffff81199118>] seq_read+0x16f/0x325
[<ffffffff811de994>] kernfs_fop_read+0x3a/0x13f
[<ffffffff8117b625>] __vfs_read+0x26/0x9d
[<ffffffff8130eb59>] ? security_file_permission+0x3c/0x44
[<ffffffff8117bdb8>] ? rw_verify_area+0x83/0xd9
[<ffffffff8117be9d>] vfs_read+0x8f/0xcf
[<ffffffff81193e34>] ? __fdget_pos+0x12/0x41
[<ffffffff8117c686>] SyS_read+0x4b/0x76
[<ffffffff817b606e>] system_call_fastpath+0x12/0x71
The bug can be easily triggered, if an extra delay (e.g. 10ms) is added
between the test of DMF_FREEING & DMF_DELETING and dm_get() in
dm_get_from_kobject().
To fix it, we need to ensure the test of DMF_FREEING & DMF_DELETING and
dm_get() are done in an atomic way, so _minor_lock is used.
The other callers of dm_get() have also been checked to be OK: some
callers invoke dm_get() under _minor_lock, some callers invoke it under
_hash_lock, and dm_start_request() invoke it after increasing
md->open_count.
Cc: stable@vger.kernel.org
Signed-off-by: Hou Tao <houtao1@huawei.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2017-11-10 15:44:56 -05:00
..
bcache
bcache: use llist_for_each_entry_safe() in __closure_wake_up()
2017-09-27 14:54:49 -06:00
persistent-data
dm space map metadata: use ARRAY_SIZE
2017-11-10 15:44:52 -05:00
bitmap.c
md/bitmap: disable bitmap_resize for file-backed bitmaps.
2017-08-31 22:57:03 -07:00
bitmap.h
dm-bio-prison-v1.c
dm-bio-prison-v1.h
dm-bio-prison-v2.c
dm-bio-prison-v2.h
dm-bio-record.h
block: replace bi_bdev with a gendisk pointer and partitions index
2017-08-23 12:49:55 -06:00
dm-bufio.c
- Some request-based DM core and DM multipath fixes and cleanups
2017-09-14 13:43:16 -07:00
dm-bufio.h
dm integrity: optimize writing dm-bufio buffers that are partially changed
2017-08-28 11:47:17 -04:00
dm-builtin.c
dm-cache-background-tracker.c
dm-cache-background-tracker.h
dm-cache-block-types.h
dm-cache-metadata.c
dm cache: convert dm_cache_metadata.ref_count from atomic_t to refcount_t
2017-10-24 15:09:51 -04:00
dm-cache-metadata.h
dm-cache-policy-internal.h
dm-cache-policy-smq.c
dm-cache-policy.c
dm-cache-policy.h
dm-cache-target.c
dm cache: simplify get_per_bio_data() by removing data_size argument
2017-11-10 15:44:49 -05:00
dm-core.h
dm: allocate struct mapped_device with kvzalloc
2017-11-10 15:44:55 -05:00
dm-crypt.c
dm crypt: reject sector_size feature if device length is not aligned to it
2017-10-04 10:49:58 -04:00
dm-delay.c
block: replace bi_bdev with a gendisk pointer and partitions index
2017-08-23 12:49:55 -06:00
dm-era-target.c
block: replace bi_bdev with a gendisk pointer and partitions index
2017-08-23 12:49:55 -06:00
dm-exception-store.c
dm-exception-store.h
dm-flakey.c
- Some request-based DM core and DM multipath fixes and cleanups
2017-09-14 13:43:16 -07:00
dm-integrity.c
- Some request-based DM core and DM multipath fixes and cleanups
2017-09-14 13:43:16 -07:00
dm-io.c
block: replace bi_bdev with a gendisk pointer and partitions index
2017-08-23 12:49:55 -06:00
dm-ioctl.c
dm ioctl: fix alignment of event number in the device list
2017-09-25 11:18:29 -04:00
dm-kcopyd.c
dm kcopyd: add sequential write feature
2017-06-19 11:03:51 -04:00
dm-linear.c
- Some request-based DM core and DM multipath fixes and cleanups
2017-09-14 13:43:16 -07:00
dm-log-userspace-base.c
dm-log-userspace-transfer.c
dm-log-userspace-transfer.h
dm-log-writes.c
dm log writes: add support for DAX
2017-11-10 15:44:51 -05:00
dm-log.c
dm-mpath.c
- Some request-based DM core and DM multipath fixes and cleanups
2017-09-14 13:43:16 -07:00
dm-mpath.h
dm-path-selector.c
dm-path-selector.h
dm-queue-length.c
dm-raid.c
- A stable fix for the alignment of the event number reported at the
2017-10-05 15:17:40 -07:00
dm-raid1.c
block: replace bi_bdev with a gendisk pointer and partitions index
2017-08-23 12:49:55 -06:00
dm-region-hash.c
dm-round-robin.c
dm-rq.c
dm rq: do not update rq partially in each ending bio
2017-08-28 10:23:28 -04:00
dm-rq.h
dm rq: do not update rq partially in each ending bio
2017-08-28 10:23:28 -04:00
dm-service-time.c
dm-snap-persistent.c
dm-snap-transient.c
dm-snap.c
block: replace bi_bdev with a gendisk pointer and partitions index
2017-08-23 12:49:55 -06:00
dm-stats.c
dm-stats.h
dm-stripe.c
- Some request-based DM core and DM multipath fixes and cleanups
2017-09-14 13:43:16 -07:00
dm-switch.c
- Some request-based DM core and DM multipath fixes and cleanups
2017-09-14 13:43:16 -07:00
dm-sysfs.c
dm-table.c
dm: convert dm_dev_internal.count from atomic_t to refcount_t
2017-10-24 15:09:51 -04:00
dm-target.c
dm-thin-metadata.c
dm-thin-metadata.h
dm-thin.c
- Some request-based DM core and DM multipath fixes and cleanups
2017-09-14 13:43:16 -07:00
dm-uevent.c
dm-uevent.h
dm-verity-fec.c
dm verity fec: fix GFP flags used with mempool_alloc()
2017-07-26 15:55:44 -04:00
dm-verity-fec.h
dm-verity-target.c
- Some request-based DM core and DM multipath fixes and cleanups
2017-09-14 13:43:16 -07:00
dm-verity.h
dm-zero.c
dm-zoned-metadata.c
block: replace bi_bdev with a gendisk pointer and partitions index
2017-08-23 12:49:55 -06:00
dm-zoned-reclaim.c
dm zoned: use GFP_NOIO in I/O path
2017-07-26 15:55:43 -04:00
dm-zoned-target.c
dm zoned: ignore last smaller runt zone
2017-11-10 15:44:53 -05:00
dm-zoned.h
dm zoned: drive-managed zoned block device target
2017-06-19 11:05:20 -04:00
dm.c
dm: fix race between dm_get_from_kobject() and __dm_destroy()
2017-11-10 15:44:56 -05:00
dm.h
dm: convert dm_dev_internal.count from atomic_t to refcount_t
2017-10-24 15:09:51 -04:00
faulty.c
block: replace bi_bdev with a gendisk pointer and partitions index
2017-08-23 12:49:55 -06:00
Kconfig
dm zoned: drive-managed zoned block device target
2017-06-19 11:05:20 -04:00
linear.c
block: replace bi_bdev with a gendisk pointer and partitions index
2017-08-23 12:49:55 -06:00
linear.h
Makefile
dm zoned: drive-managed zoned block device target
2017-06-19 11:05:20 -04:00
md-cluster.c
md-cluster.h
md.c
md: fix a race condition for flush request handling
2017-09-27 20:08:18 -07:00
md.h
md: separate request handling
2017-09-27 20:07:40 -07:00
multipath.c
block: replace bi_bdev with a gendisk pointer and partitions index
2017-08-23 12:49:55 -06:00
multipath.h
raid0.c
Merge tag 'md/4.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shli/md
2017-09-07 12:41:48 -07:00
raid0.h
raid1-10.c
md: raid1-10: move raid1/raid10 common code into raid1-10.c
2017-07-21 12:47:20 -07:00
raid1.c
Merge tag 'md/4.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shli/md
2017-09-07 12:41:48 -07:00
raid1.h
raid5-cache.c
Merge tag 'md/4.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shli/md
2017-09-07 12:41:48 -07:00
raid5-log.h
raid5-ppl.c
Merge tag 'md/4.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shli/md
2017-09-07 12:41:48 -07:00
raid5.c
md/raid5: cap worker count
2017-09-27 20:08:44 -07:00
raid5.h
raid10.c
Merge tag 'md/4.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shli/md
2017-09-07 12:41:48 -07:00
raid10.h