diff mbox

sunvdc: limit each sg segment to a page

Message ID 1411134173-26665-1-git-send-email-dwight.engen@oracle.com
State Accepted
Delegated to: David Miller
Headers show

Commit Message

Dwight Engen Sept. 19, 2014, 1:42 p.m. UTC
ldc_map_sg() could fail its check that the number of pages referred to
by the sg scatterlist was <= the number of cookies.

This fixes the issue by doing a similar thing to the xen-blkfront driver,
ensuring that the scatterlist will only ever contain a segment count <=
port->ring_cookies, and each segment will be page aligned, and <= page
size. This ensures that the scatterlist is always mappable.

Orabug: 19347817
OraBZ: 15945

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
---
 drivers/block/sunvdc.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

Comments

David Miller Sept. 30, 2014, 9:38 p.m. UTC | #1
From: Dwight Engen <dwight.engen@oracle.com>
Date: Fri, 19 Sep 2014 09:42:53 -0400

> ldc_map_sg() could fail its check that the number of pages referred to
> by the sg scatterlist was <= the number of cookies.
> 
> This fixes the issue by doing a similar thing to the xen-blkfront driver,
> ensuring that the scatterlist will only ever contain a segment count <=
> port->ring_cookies, and each segment will be page aligned, and <= page
> size. This ensures that the scatterlist is always mappable.
> 
> Orabug: 19347817
> OraBZ: 15945
> 
> Signed-off-by: Dwight Engen <dwight.engen@oracle.com>

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

Patch

diff --git a/drivers/block/sunvdc.c b/drivers/block/sunvdc.c
index 1616ad0..1a9360d 100644
--- a/drivers/block/sunvdc.c
+++ b/drivers/block/sunvdc.c
@@ -747,6 +747,10 @@  static int probe_disk(struct vdc_port *port)
 
 	port->disk = g;
 
+	/* Each segment in a request is up to an aligned page in size. */
+	blk_queue_segment_boundary(q, PAGE_SIZE - 1);
+	blk_queue_max_segment_size(q, PAGE_SIZE);
+
 	blk_queue_max_segments(q, port->ring_cookies);
 	blk_queue_max_hw_sectors(q, port->max_xfer_size);
 	g->major = vdc_major;