Re: FW: Areca controller problem with Linux XFS over DM-CRYPT

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

 



nickcheng wrote:
> Sir,
> This is from Areca researching and developing SAS/SATA RAID adapter,
> http://www.areca.com.tw/.
> Currently, our customers report an issue which happened on the xfs
> filesystem with dm-crypt.
> We have verified it and found it does exist.
> We found, 
> 1. XFS with Areca works fine,
> 2. EXT3 with Areca works fine,
> 3. dm-crypt with EXT3 over Areca works fine.
> But once the configuration is xfs filesystem plus dm-crypt, the scsi
> commands aborted happened.
> We find that even though the driver claims the maximum SG entry number,
> ARCMSR_MAX_SG_ENTRIES, to the upper layer.
> But we still got the scsi commands with sg number over our limit.
> That is why arcmsr, which is Areca RAID driver, would issue "abort scsi
> command" messages constantly. 

Hello,

thanks for reporting this, the same issue is tracked here
http://bugzilla.kernel.org/show_bug.cgi?id=7763

In attachment is patch I just sent to bugzilla which should fix it.
Patch still need review and testing but when ready it will go through
DM devel tree to stable kernel.

Thanks,
Milan
--
mbroz@xxxxxxxxxx

From: Milan Broz <mbroz@xxxxxxxxxx>

Fix possible max_phys_segments violation in cloned dm-crypt bio.

In write operation dm-crypt needs to allocate new bio request
and run crypto operation on this clone. Cloned request has always
the same size, but number of physical segments can be increased
and violate max_phys_segments restriction.

This can lead to data corruption and serious hardware malfunction.
This was observed when using XFS over dm-crypt and at least
two HBA controller drivers (arcmsr, cciss) recently.

Fix it by using bio_add_page() call (which performs all restrictions
validation) instead of constructing own biovec.

(All versions of dm-crypt are affected by this bug.)

Signed-off-by: Milan Broz <mbroz@xxxxxxxxxx>
---
 drivers/md/dm-crypt.c |   23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

Index: linux-2.6.24/drivers/md/dm-crypt.c
===================================================================
--- linux-2.6.24.orig/drivers/md/dm-crypt.c	2007-11-17 06:16:36.000000000 +0100
+++ linux-2.6.24/drivers/md/dm-crypt.c	2007-12-01 15:41:51.000000000 +0100
@@ -399,6 +399,8 @@ static struct bio *crypt_alloc_buffer(st
 	unsigned int nr_iovecs = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
 	gfp_t gfp_mask = GFP_NOIO | __GFP_HIGHMEM;
 	unsigned int i;
+	struct page *page;
+	unsigned long len;
 
 	clone = bio_alloc_bioset(GFP_NOIO, nr_iovecs, cc->bs);
 	if (!clone)
@@ -407,10 +409,8 @@ static struct bio *crypt_alloc_buffer(st
 	clone_init(io, clone);
 
 	for (i = 0; i < nr_iovecs; i++) {
-		struct bio_vec *bv = bio_iovec_idx(clone, i);
-
-		bv->bv_page = mempool_alloc(cc->page_pool, gfp_mask);
-		if (!bv->bv_page)
+		page = mempool_alloc(cc->page_pool, gfp_mask);
+		if (!page)
 			break;
 
 		/*
@@ -421,15 +421,14 @@ static struct bio *crypt_alloc_buffer(st
 		if (i == (MIN_BIO_PAGES - 1))
 			gfp_mask = (gfp_mask | __GFP_NOWARN) & ~__GFP_WAIT;
 
-		bv->bv_offset = 0;
-		if (size > PAGE_SIZE)
-			bv->bv_len = PAGE_SIZE;
-		else
-			bv->bv_len = size;
+		len = (size > PAGE_SIZE) ? PAGE_SIZE : size;
+
+		if (!bio_add_page(clone, page, len, 0)) {
+			mempool_free(page, cc->page_pool);
+			break;
+		}
 
-		clone->bi_size += bv->bv_len;
-		clone->bi_vcnt++;
-		size -= bv->bv_len;
+		size -= len;
 	}
 
 	if (!clone->bi_size) {

---------------------------------------------------------------------
dm-crypt mailing list - http://www.saout.de/misc/dm-crypt/
To unsubscribe, e-mail: dm-crypt-unsubscribe@xxxxxxxx
For additional commands, e-mail: dm-crypt-help@xxxxxxxx

[Index of Archives]     [Device Mapper Devel]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux