linux/drivers/md
Kiyoshi Ueda abdc568b05 dm: prevent access to md being deleted
This patch prevents access to mapped_device which is being deleted.

Currently, even after a mapped_device has been removed from the hash,
it could be accessed through idr_find() using minor number.
That could cause a race and NULL pointer reference below:
  CPU0                          CPU1
  ------------------------------------------------------------------
  dev_remove(param)
    down_write(_hash_lock)
    dm_lock_for_deletion(md)
      spin_lock(_minor_lock)
      set_bit(DMF_DELETING)
      spin_unlock(_minor_lock)
    __hash_remove(hc)
    up_write(_hash_lock)
                                dev_status(param)
                                  md = find_device(param)
                                         down_read(_hash_lock)
                                         __find_device_hash_cell(param)
                                           dm_get_md(param->dev)
                                             md = dm_find_md(dev)
                                                    spin_lock(_minor_lock)
                                                    md = idr_find(MINOR(dev))
                                                    spin_unlock(_minor_lock)
    dm_put(md)
      free_dev(md)
                                             dm_get(md)
                                         up_read(_hash_lock)
                                  __dev_status(md, param)
                                  dm_put(md)

This patch fixes such problems.

Signed-off-by: Kiyoshi Ueda <k-ueda@ct.jp.nec.com>
Signed-off-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
Cc: stable@kernel.org
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
2010-08-12 04:13:54 +01:00
..
.gitignore
bitmap.c
bitmap.h
dm-bio-record.h
dm-crypt.c
dm-delay.c
dm-exception-store.c dm snapshot: test chunk size against both origin and snapshot 2010-08-12 04:13:51 +01:00
dm-exception-store.h dm snapshot: test chunk size against both origin and snapshot 2010-08-12 04:13:51 +01:00
dm-io.c
dm-ioctl.c dm ioctl: return uevent flag after rename 2010-08-12 04:13:53 +01:00
dm-kcopyd.c
dm-linear.c
dm-log-userspace-base.c
dm-log-userspace-transfer.c
dm-log-userspace-transfer.h
dm-log.c
dm-mpath.c dm mpath: fix NULL pointer dereference when path parameters missing 2010-08-12 04:13:49 +01:00
dm-mpath.h
dm-path-selector.c
dm-path-selector.h
dm-queue-length.c
dm-raid1.c
dm-region-hash.c
dm-round-robin.c
dm-service-time.c
dm-snap-persistent.c
dm-snap-transient.c
dm-snap.c dm snapshot: test chunk size against both origin and snapshot 2010-08-12 04:13:51 +01:00
dm-stripe.c
dm-sysfs.c
dm-table.c
dm-target.c
dm-uevent.c
dm-uevent.h
dm-zero.c
dm.c dm: prevent access to md being deleted 2010-08-12 04:13:54 +01:00
dm.h
faulty.c
Kconfig Merge branch 'async' of macbook:git/btrfs-unstable 2010-08-09 10:36:44 +01:00
linear.c
linear.h
Makefile Merge branch 'async' of macbook:git/btrfs-unstable 2010-08-09 10:36:44 +01:00
md.c Merge branch 'for-linus' of git://neil.brown.name/md 2010-08-10 15:38:19 -07:00
md.h Merge branch 'for-linus' of git://neil.brown.name/md 2010-08-10 15:38:19 -07:00
multipath.c
multipath.h
raid0.c
raid0.h
raid1.c
raid1.h
raid5.c Merge branch 'for-linus' of git://neil.brown.name/md 2010-08-10 15:38:19 -07:00
raid5.h
raid10.c Merge branch 'for-linus' of git://neil.brown.name/md 2010-08-10 15:38:19 -07:00
raid10.h