lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id:  <1070731021739.25411@suse.de>
Date:	Tue, 31 Jul 2007 12:17:39 +1000
From:	NeilBrown <neilb@...e.de>
To:	linux-kernel@...r.kernel.org
Subject: [PATCH 021 of 35] Teach umem.c about bi_offset and to limit to bi_size.



Signed-off-by: Neil Brown <neilb@...e.de>

### Diffstat output
 ./drivers/block/umem.c |   16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff .prev/drivers/block/umem.c ./drivers/block/umem.c
--- .prev/drivers/block/umem.c	2007-07-31 11:21:03.000000000 +1000
+++ ./drivers/block/umem.c	2007-07-31 11:21:11.000000000 +1000
@@ -115,6 +115,7 @@ struct cardinfo {
 	struct bio	*bio, *currentbio, **biotail;
 	int		current_idx;
 	sector_t	current_sector;
+	int		current_size;
 
 	struct request_queue *queue;
 
@@ -387,12 +388,14 @@ static int add_bio(struct cardinfo *card
 	int idx;
 	int rw;
 	int len;
+	int bvoffset = 0;
 
 	bio = card->currentbio;
 	if (!bio && card->bio) {
 		card->currentbio = card->bio;
 		card->current_idx = 0;
 		card->current_sector = card->bio->bi_sector;
+		card->current_size = bio->bi_size;
 		card->bio = card->bio->bi_next;
 		if (card->bio == NULL)
 			card->biotail = &card->bio;
@@ -408,10 +411,14 @@ static int add_bio(struct cardinfo *card
 		return 0;
 
 	vec = bio_iovec_idx(bio, idx);
-	len = vec->bv_len;
+	if (idx == 0)
+		bvoffset = bio->bi_offset;
+	len = vec->bv_len - bvoffset;
+	if (len > card->current_size)
+		len = card->current_size;
 	dma_handle = pci_map_page(card->dev,
 				  vec->bv_page,
-				  vec->bv_offset,
+				  vec->bv_offset + bvoffset,
 				  len,
 				  (rw==READ) ?
 				  PCI_DMA_FROMDEVICE : PCI_DMA_TODEVICE);
@@ -446,11 +453,14 @@ static int add_bio(struct cardinfo *card
 		desc->control_bits |= cpu_to_le32(DMASCR_TRANSFER_READ);
 	desc->sem_control_bits = desc->control_bits;
 
+	card->current_size -= len;
 	card->current_sector += (len >> 9);
 	idx++;
 	card->current_idx = idx;
-	if (idx >= bio->bi_vcnt)
+	if (idx >= bio->bi_vcnt) {
+		BUG_ON(card->current_size);
 		card->currentbio = NULL;
+	}
 
 	return 1;
 }
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ