Patch "xen/blkfront: don't take local copy of a request from the ring page" has been added to the 4.4-stable tree

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

 



This is a note to let you know that I've just added the patch titled

    xen/blkfront: don't take local copy of a request from the ring page

to the 4.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     xen-blkfront-don-t-take-local-copy-of-a-request-from-the-ring-page.patch
and it can be found in the queue-4.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.


>From foo@baz Mon Nov 29 07:12:46 PM CET 2021
From: Juergen Gross <jgross@xxxxxxxx>
Date: Mon, 29 Nov 2021 14:00:21 +0100
Subject: xen/blkfront: don't take local copy of a request from the ring page

From: Juergen Gross <jgross@xxxxxxxx>

commit 8f5a695d99000fc3aa73934d7ced33cfc64dcdab upstream.

In order to avoid a malicious backend being able to influence the local
copy of a request build the request locally first and then copy it to
the ring page instead of doing it the other way round as today.

Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
Acked-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
Link: https://lore.kernel.org/r/20210730103854.12681-3-jgross@xxxxxxxx
Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 drivers/block/xen-blkfront.c |   38 ++++++++++++++++++++++++++------------
 1 file changed, 26 insertions(+), 12 deletions(-)

--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -456,16 +456,31 @@ static int blkif_ioctl(struct block_devi
 	return 0;
 }
 
+static unsigned long blkif_ring_get_request(struct blkfront_info *info,
+					    struct request *req,
+					    struct blkif_request **ring_req)
+{
+	unsigned long id;
+
+	*ring_req = RING_GET_REQUEST(&info->ring, info->ring.req_prod_pvt);
+	info->ring.req_prod_pvt++;
+
+	id = get_id_from_freelist(info);
+	info->shadow[id].request = req;
+	info->shadow[id].req.u.rw.id = id;
+
+	return id;
+}
+
 static int blkif_queue_discard_req(struct request *req)
 {
 	struct blkfront_info *info = req->rq_disk->private_data;
-	struct blkif_request *ring_req;
+	struct blkif_request *ring_req, *final_ring_req;
 	unsigned long id;
 
 	/* Fill out a communications ring structure. */
-	ring_req = RING_GET_REQUEST(&info->ring, info->ring.req_prod_pvt);
-	id = get_id_from_freelist(info);
-	info->shadow[id].request = req;
+	id = blkif_ring_get_request(info, req, &final_ring_req);
+	ring_req = &info->shadow[id].req;
 
 	ring_req->operation = BLKIF_OP_DISCARD;
 	ring_req->u.discard.nr_sectors = blk_rq_sectors(req);
@@ -478,8 +493,8 @@ static int blkif_queue_discard_req(struc
 
 	info->ring.req_prod_pvt++;
 
-	/* Keep a private copy so we can reissue requests when recovering. */
-	info->shadow[id].req = *ring_req;
+	/* Copy the request to the ring page. */
+	*final_ring_req = *ring_req;
 
 	return 0;
 }
@@ -569,7 +584,7 @@ static void blkif_setup_rw_req_grant(uns
 static int blkif_queue_rw_req(struct request *req)
 {
 	struct blkfront_info *info = req->rq_disk->private_data;
-	struct blkif_request *ring_req;
+	struct blkif_request *ring_req, *final_ring_req;
 	unsigned long id;
 	int i;
 	struct setup_rw_req setup = {
@@ -613,9 +628,8 @@ static int blkif_queue_rw_req(struct req
 		new_persistent_gnts = 0;
 
 	/* Fill out a communications ring structure. */
-	ring_req = RING_GET_REQUEST(&info->ring, info->ring.req_prod_pvt);
-	id = get_id_from_freelist(info);
-	info->shadow[id].request = req;
+	id = blkif_ring_get_request(info, req, &final_ring_req);
+	ring_req = &info->shadow[id].req;
 
 	BUG_ON(info->max_indirect_segments == 0 &&
 	       GREFS(req->nr_phys_segments) > BLKIF_MAX_SEGMENTS_PER_REQUEST);
@@ -696,8 +710,8 @@ static int blkif_queue_rw_req(struct req
 
 	info->ring.req_prod_pvt++;
 
-	/* Keep a private copy so we can reissue requests when recovering. */
-	info->shadow[id].req = *ring_req;
+	/* Copy request(s) to the ring page. */
+	*final_ring_req = *ring_req;
 
 	if (new_persistent_gnts)
 		gnttab_free_grant_references(setup.gref_head);


Patches currently in stable-queue which might be from jgross@xxxxxxxx are

queue-4.4/xen-blkfront-read-response-from-backend-only-once.patch
queue-4.4/tty-hvc-replace-bug_on-with-negative-return-value.patch
queue-4.4/xen-blkfront-don-t-trust-the-backend-response-data-blindly.patch
queue-4.4/xen-sync-include-xen-interface-io-ring.h-with-xen-s-newest-version.patch
queue-4.4/xen-blkfront-don-t-take-local-copy-of-a-request-from-the-ring-page.patch
queue-4.4/xen-detect-uninitialized-xenbus-in-xenbus_init.patch
queue-4.4/xen-netfront-don-t-read-data-from-request-on-the-ring-page.patch
queue-4.4/xen-netfront-disentangle-tx_skb_freelist.patch
queue-4.4/xen-netfront-read-response-from-backend-only-once.patch
queue-4.4/xen-netfront-don-t-trust-the-backend-response-data-blindly.patch



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux