diff options
author | Guoqing Jiang <gqjiang@suse.com> | 2018-07-19 03:40:42 +0200 |
---|---|---|
committer | Jes Sorensen <jsorensen@fb.com> | 2018-07-19 19:19:35 +0200 |
commit | 531d7991476f8358a36fb7f320db93d38b0e4c8d (patch) | |
tree | a751a9ef383c15ca4604ee859b6868253020cba6 /mapfile.c | |
parent | tests, imsm: Calculate expected array_size in proper way (diff) | |
download | mdadm-531d7991476f8358a36fb7f320db93d38b0e4c8d.tar.xz mdadm-531d7991476f8358a36fb7f320db93d38b0e4c8d.zip |
mapfile: set *mapp to NULL after map_free
We can see "double free or corruption" with below steps
as reported by Mariusz:
export IMSM_NO_PLATFORM=1
export IMSM_DEVNAME_AS_SERIAL=1
mdadm --zero-super /dev/sd*
mdadm -C /dev/md/imsm -n2 -eimsm /dev/sdb /dev/sdc --run
mdadm -C /dev/md/r1 -n2 -z15G -eimsm /dev/sdb /dev/sdc -l1 --run --assume-clean
mdadm -f /dev/md126 /dev/sdb
mdadm -Ss
It is caused by Manage_stop calls map_remove and map_unlock,
but *mapp is not set to NULL after map_remove -> map_free,
so map_unlock will call map_free again.
Reported-by: Tkaczyk Mariusz <mariusz.tkaczyk@intel.com>
Tested-by: Tkaczyk Mariusz <mariusz.tkaczyk@intel.com>
Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Diffstat (limited to 'mapfile.c')
-rw-r--r-- | mapfile.c | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -268,6 +268,7 @@ void map_remove(struct map_ent **mapp, char *devnm) map_delete(mapp, devnm); map_write(*mapp); map_free(*mapp); + *mapp = NULL; } struct map_ent *map_by_uuid(struct map_ent **map, int uuid[4]) |