linux/drivers/md
Joe Thornber 8cbb486d92 dm btree: fix serious bug in btree_split_beneath()
commit bc68d0a435 upstream.

When inserting a new key/value pair into a btree we walk down the spine of
btree nodes performing the following 2 operations:

  i) space for a new entry
  ii) adjusting the first key entry if the new key is lower than any in the node.

If the _root_ node is full, the function btree_split_beneath() allocates 2 new
nodes, and redistibutes the root nodes entries between them.  The root node is
left with 2 entries corresponding to the 2 new nodes.

btree_split_beneath() then adjusts the spine to point to one of the two new
children.  This means the first key is never adjusted if the new key was lower,
ie. operation (ii) gets missed out.  This can result in the new key being
'lost' for a period; until another low valued key is inserted that will uncover
it.

This is a serious bug, and quite hard to make trigger in normal use.  A
reproducing test case ("thin create devices-in-reverse-order") is
available as part of the thin-provision-tools project:
  https://github.com/jthornber/thin-provisioning-tools/blob/master/functional-tests/device-mapper/dm-tests.scm#L593

Fix the issue by changing btree_split_beneath() so it no longer adjusts
the spine.  Instead it unlocks both the new nodes, and lets the main
loop in btree_insert_raw() relock the appropriate one and make any
neccessary adjustments.

Reported-by: Monty Pavel <monty_pavel@sina.com>
Signed-off-by: Joe Thornber <thornber@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
History 2018-03-03 15:52:25 +00:00
..
bcache bcache: recover data from backing when data is clean 2018-03-03 15:51:33 +00:00
persistent-data dm btree: fix serious bug in btree_split_beneath() 2018-03-03 15:52:25 +00:00
bitmap.c md/bitmap: disable bitmap_resize for file-backed bitmaps. 2017-11-26 13:50:29 +00:00
bitmap.h kernfs: s/sysfs_dirent/kernfs_node/ and rename its friends accordingly 2013-12-11 15:28:36 -08:00
dm-bio-prison.c dm bio prison: implement per bucket locking in the dm_bio_prison hash table 2014-06-11 16:48:54 -04:00
dm-bio-prison.h dm thin: return ENOSPC instead of EIO when error_if_no_space enabled 2014-06-03 13:44:08 -04:00
dm-bio-record.h dm: Refactor for new bio cloning/splitting 2013-11-23 22:33:55 -08:00
dm-bufio.c dm bufio: fix integer overflow when limiting maximum cache size 2018-02-13 18:42:23 +00:00
dm-bufio.h dm snapshot: use dm-bufio prefetch 2014-01-14 23:23:03 -05:00
dm-builtin.c dm sysfs: fix a module unload race 2014-01-14 23:23:04 -05:00
dm-cache-block-types.h dm cache: remove remainder of distinct discard block size 2014-03-27 16:56:23 -04:00
dm-cache-metadata.c dm cache: fix missing ERR_PTR returns and handling 2015-02-04 10:58:25 +00:00
dm-cache-metadata.h dm cache: fix a lock-inversion 2014-04-04 14:53:05 -04:00
dm-cache-policy-cleaner.c dm cache: fix NULL pointer when switching from cleaner policy 2015-10-30 13:59:29 +00:00
dm-cache-policy-internal.h dm cache: add remove_cblock method to policy interface 2013-11-11 11:37:50 -05:00
dm-cache-policy-mq.c dm cache mq: fix memory allocation failure for large cache devices 2014-02-28 12:18:29 -05:00
dm-cache-policy.c dm cache: add policy name to status output 2014-01-16 13:44:11 -05:00
dm-cache-policy.h dm cache: add policy name to status output 2014-01-16 13:44:11 -05:00
dm-cache-target.c dm: fix various targets to dm_register_target after module __init resources created 2018-03-03 15:51:44 +00:00
dm-crypt.c dm crypt: mark key as invalid until properly loaded 2017-03-16 02:26:24 +00:00
dm-delay.c Merge branch 'for-3.14/core' of git://git.kernel.dk/linux-block 2014-01-30 11:19:05 -08:00
dm-era-target.c dm era: save spacemap metadata root after the pre-commit 2017-08-26 02:14:38 +01:00
dm-exception-store.c dm: replace simple_strtoul 2012-07-27 15:07:59 +01:00
dm-exception-store.h dm snapshot: fix hung bios when copy error occurs 2016-02-02 19:09:21 +00:00
dm-flakey.c dm flakey: error READ bios during the down_interval 2016-11-20 01:17:03 +00:00
dm-io.c dm io: deal with wandering queue limits when handling REQ_DISCARD and REQ_WRITE_SAME 2015-03-30 11:10:44 +01:00
dm-ioctl.c dm ioctl: prevent stack leak in dm ioctl call 2017-08-26 02:14:40 +01:00
dm-kcopyd.c dm: stop using WQ_NON_REENTRANT 2013-08-23 09:02:13 -04:00
dm-linear.c block: Abstract out bvec iterator 2013-11-23 22:33:47 -08:00
dm-log-userspace-base.c dm log userspace: allow mark requests to piggyback on flush requests 2014-01-21 23:46:27 -05:00
dm-log-userspace-transfer.c dm log userspace: fix memory leak in dm_ulog_tfr_init failure path 2014-11-17 14:11:44 +00:00
dm-log-userspace-transfer.h dm log: userspace add luid to distinguish between concurrent log instances 2009-09-04 20:40:34 +01:00
dm-log.c dm: use memweight() 2012-07-30 17:25:16 -07:00
dm-mpath.c dm: fix various targets to dm_register_target after module __init resources created 2018-03-03 15:51:44 +00:00
dm-mpath.h dm mpath: remove is_active from struct dm_path 2008-10-10 13:36:58 +01:00
dm-path-selector.c md: Add module.h to all files using it implicitly 2011-10-31 19:31:18 -04:00
dm-path-selector.h dm mpath: add start_io and nr_bytes to path selectors 2009-06-22 10:12:27 +01:00
dm-queue-length.c dm: reject trailing characters in sccanf input 2012-03-28 18:41:26 +01:00
dm-raid.c dm raid: fix round up of default region size 2015-10-30 13:59:28 +00:00
dm-raid1.c dm mirror: do not degrade the mirror on discard error 2015-03-02 15:04:24 +00:00
dm-region-hash.c block: Abstract out bvec iterator 2013-11-23 22:33:47 -08:00
dm-round-robin.c dm: reject trailing characters in sccanf input 2012-03-28 18:41:26 +01:00
dm-service-time.c dm: reject trailing characters in sccanf input 2012-03-28 18:41:26 +01:00
dm-snap-persistent.c dm snapshot: fix hung bios when copy error occurs 2016-02-02 19:09:21 +00:00
dm-snap-transient.c dm snapshot: fix hung bios when copy error occurs 2016-02-02 19:09:21 +00:00
dm-snap.c dm: fix various targets to dm_register_target after module __init resources created 2018-03-03 15:51:44 +00:00
dm-stats.c dm stats: fix divide by zero if 'number_of_areas' arg is zero 2015-07-15 10:00:41 +01:00
dm-stats.h dm: add statistics support 2013-09-05 20:46:06 -04:00
dm-stripe.c block: Abstract out bvec iterator 2013-11-23 22:33:47 -08:00
dm-switch.c block: Abstract out bvec iterator 2013-11-23 22:33:47 -08:00
dm-sysfs.c dm sysfs: fix a module unload race 2014-01-14 23:23:04 -05:00
dm-table.c dm: discard support requires all targets in a table support discards 2018-02-13 18:42:23 +00:00
dm-target.c dm: allow error target to replace bio-based and request-based targets 2013-09-05 20:46:05 -04:00
dm-thin-metadata.c dm thin metadata: THIN_MAX_CONCURRENT_LOCKS should be 6 2018-03-03 15:52:24 +00:00
dm-thin-metadata.h dm thin: ensure user takes action to validate data and metadata consistency 2014-03-05 15:25:35 -05:00
dm-thin.c dm: fix various targets to dm_register_target after module __init resources created 2018-03-03 15:51:44 +00:00
dm-uevent.c md: Add in export.h for files using EXPORT_SYMBOL 2011-10-31 19:31:19 -04:00
dm-uevent.h dm: uevent generate events 2007-10-20 02:01:26 +01:00
dm-verity.c dm verity: fix biovecs hash calculation regression 2014-04-15 12:19:24 -04:00
dm-zero.c dm crypt, dm zero: update author name following legal name change 2014-07-10 16:44:14 -04:00
dm.c dm: fix race between dm_get_from_kobject() and __dm_destroy() 2018-02-13 18:42:20 +00:00
dm.h dm table: add dm_table_run_md_queue_async 2014-03-27 16:56:24 -04:00
faulty.c block: Abstract out bvec iterator 2013-11-23 22:33:47 -08:00
Kconfig scsi_dh: fix randconfig build error 2015-09-30 13:20:52 +01:00
linear.c md linear: fix a race between linear_add() and linear_congested() 2017-06-05 21:17:07 +01:00
linear.h md linear: fix a race between linear_add() and linear_congested() 2017-06-05 21:17:07 +01:00
Makefile dm: add era target 2014-03-27 16:56:23 -04:00
md.c md: ensure md devices are freed before module is unloaded. 2017-06-05 21:17:08 +01:00
md.h md/bitmap: don't abuse i_writecount for bitmap files. 2014-04-09 12:26:59 +10:00
multipath.c md: multipath: don't hardcopy bio in .make_request path 2016-05-01 00:06:00 +02:00
multipath.h md/multipath: typedef removal: multipath_conf_t -> struct mpconf 2011-10-11 16:48:57 +11:00
raid0.c md/raid0: apply base queue limits *before* disk_stack_limits 2015-12-13 17:49:47 +00:00
raid0.h md: add proper merge_bvec handling to RAID0 and Linear. 2012-03-19 12:46:39 +11:00
raid1.c md: don't use flush_signals in userspace processes 2017-10-12 15:27:48 +01:00
raid1.h raid1: Rewrite the implementation of iobarrier. 2013-11-19 15:19:18 +11:00
raid5.c md/raid5: add thread_group worker async_tx_issue_pending_all 2017-11-11 13:33:07 +00:00
raid5.h raid5: add an option to avoid copy data from bio to stripe cache 2014-05-29 16:59:47 +10:00
raid10.c md/raid1/10: fix potential deadlock 2017-07-18 18:40:10 +01:00
raid10.h MD RAID10: Improve redundancy for 'far' and 'offset' algorithms (part 1) 2013-02-26 11:55:30 +11:00