dmraid -r -E bus error

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


Hi all,

The command "dmraid -r -E <raid dev>" SEGVs if there is a single device
in in the on disk meta data configuration.

If the on disk meta data configuration contains one raid device only
(one block only) then the isw module determines there are no extended
attributes and extra space isn't allocated during the meta data read. 

However, the meta data write function fails to check whether the extra
space is present before copying the meta data and SEGVs when trying to
write it to the non existent memory.

I consulted with Heinz Mauelshagen and we ended up with this patch.
Comments welcome.

Ian

---
diff -up 1.0.0.rc14/lib/format/ataraid/isw.c.solitary-meta-block 1.0.0.rc14/lib/format/ataraid/isw.c
--- 1.0.0.rc14/lib/format/ataraid/isw.c.solitary-meta-block	2006-09-23 02:11:37.000000000 +0800
+++ 1.0.0.rc14/lib/format/ataraid/isw.c	2007-10-22 15:10:49.000000000 +0800
@@ -364,21 +364,26 @@ static int isw_write(struct lib_context 
 {
 	int ret;
 	struct isw *isw = META(rd, isw);
+	int large = div_up(isw->mpb_size, ISW_DISK_BLOCK_SIZE) > 1;
 
 	to_disk(isw, FULL);
 
-	/*
-	 * Copy 1st metadata sector to after the extended ones
-	 * and increment metadata area pointer by one block, so
-	 * that the metadata is filed in the proper sequence.
-	 */
-	memcpy((void*) isw + rd->meta_areas->size, isw, ISW_DISK_BLOCK_SIZE);
-	rd->meta_areas->area += ISW_DISK_BLOCK_SIZE;
+	if (large) {
+		/*
+		 * Copy 1st metadata sector to after the extended ones
+		 * and increment metadata area pointer by one block, so
+		 * that the metadata is filed in the proper sequence.
+		 */
+		memcpy((void*) isw + rd->meta_areas->size, isw,
+		       ISW_DISK_BLOCK_SIZE);
+		rd->meta_areas->area += ISW_DISK_BLOCK_SIZE;
+	}
 
 	ret = write_metadata(lc, handler, rd, -1, erase);
 
 	/* Correct metadata area pointer. */
-	rd->meta_areas->area -= ISW_DISK_BLOCK_SIZE;
+	if (large)
+		rd->meta_areas->area -= ISW_DISK_BLOCK_SIZE;
 
 	to_cpu(isw, FULL);
 


_______________________________________________
Ataraid-list mailing list
Ataraid-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/ataraid-list

[Linux RAID]     [Linux IDE]     [Linux SCSI]     [Kernel]     [Linux Books]     [Linux Admin]     [GFS]     [RPM]     [Photos]     [Yosemite Photos]     [Yosemite News]     [AMD 64]
  Powered by Linux