[PATCH] mapfile: set *mapp to NULL after map_free

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
Tested-by: Tkaczyk Mariusz <mariusz.tkaczyk@xxxxxxxxx>
Signed-off-by: Guoqing Jiang <gqjiang@xxxxxxxx>
---
 mapfile.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/mapfile.c b/mapfile.c
index a50255632d28..8d7acb3cc389 100644
--- a/mapfile.c
+++ b/mapfile.c
@@ -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])
-- 
2.13.6

--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux