Received: by 10.192.165.148 with SMTP id m20csp4217731imm; Mon, 30 Apr 2018 14:04:59 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrSnXWG/qqWBYDempncWhYnYRtvUJIJwKnTzOb04baaP9JrFuFoNxPhQ1VazSJOAyMnVHZ7 X-Received: by 2002:a63:6a08:: with SMTP id f8-v6mr9267270pgc.363.1525122299398; Mon, 30 Apr 2018 14:04:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525122299; cv=none; d=google.com; s=arc-20160816; b=pT3/f3Ow9DT8U8p4r0NN+Yzotjz4JMspsQbkX3S8u085OcammluJhoPerV1JTb8sjN ozWH7ZHG0j4fIquMCIu69g6RI7RMirXckleA2wMiCpVpfPR39vb2YTZpwnCoL3DKaDYF wA2DpwHdqiuDaVAeln9g+iRIXygYGmVBEMlONgIDARSEyveYOz8aj+mWGmhzWVBMXR0I QdlG76m/xJmamLPiieJGVBeLDh+MKOayYq49UDEgMmcDSQJOm5dUbeQD1p8LGPDgmlnk yozttE+oTJoQn8ersZBEdweETfWQ83dYJEdd9samVGf+EJZ+HuMIUgeFufibSLwIynan jBzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:references :in-reply-to:mime-version:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=dfZ6CAZM4OjbtKFvtwOo5DVWc4WLcAXnkJM5/3/ftT4=; b=MsHK7JPrF5Sy3POGTSYla9LAbj2QjDzbxUh4BvcixDUU1h/bTePPIsg/PqlJGRVgX1 LKP8sqNd1iavn1g5l9BJRpA2S3HJLPBY3Jf52tUf2mUff4/xC6ItztmkNMQnDSEz8jde v5zcp4nX42lSliyNEvWyfAmciRxfbOVGVg9UDDzYVXJPEV9ILVLby+45u5hGUADpuHPE g6yQmdkGgsuOX1Yx2H8C79yQPaXByRVZqKcD6DQGDzY9VVa1Dk134YdNx7HpfB7K7t3L l8DSw05X3evTdEBUeRF6KTo+FSq+t+aNjAiDkD/5OiZssSmBHLalAvkjjWXrgdfJmJnN ERDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=MLMyC7qz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f5-v6si6623841pga.595.2018.04.30.14.04.45; Mon, 30 Apr 2018 14:04:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=MLMyC7qz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932094AbeD3VEN (ORCPT + 99 others); Mon, 30 Apr 2018 17:04:13 -0400 Received: from out2-smtp.messagingengine.com ([66.111.4.26]:47109 "EHLO out2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755162AbeD3VDF (ORCPT ); Mon, 30 Apr 2018 17:03:05 -0400 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id B1EA222AA5; Mon, 30 Apr 2018 17:03:04 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Mon, 30 Apr 2018 17:03:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:in-reply-to:message-id:mime-version :references:references:subject:to:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=dfZ6CAZM4OjbtKFvtwOo5DVWc4WLcAXnkJM5/3/ft T4=; b=MLMyC7qzUai0lUcgDatZmuwV8JLguw8y37mTKex/1pbDBbNtaQIdyx7iK h28YSVpD2brO8xSs5Ln4fnolknzPxSXmZoTWlDciUGpagrV5DT0VS7inaoNi4KQX rqit3ka4vcu7xaze8Zyj78UZHLl7nKdAjKT6CpkqutSZAFIV2E974ucklpKEooV0 1hfXftQcGCLAk4nhs5j/WSk9axPXwGLW+xWvVI6eRBsnTG/VPFOTYETbi8XimbwH Lv1kzejDYhGVMCIqGSG5MV84RFKIllLQWdRSDtLBE/44TWhguNP0Ci6tMKvPfY6j UCk8FIbdmYHX1kZHy8/AgVLTDNVRw== X-ME-Sender: Received: from localhost.localdomain (ip5b40bfaa.dynamic.kabel-deutschland.de [91.64.191.170]) by mail.messagingengine.com (Postfix) with ESMTPA id 41D16E4EAC; Mon, 30 Apr 2018 17:03:03 -0400 (EDT) From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= To: xen-devel@lists.xenproject.org Cc: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , stable@vger.kernel.org, Konrad Rzeszutek Wilk , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Boris Ostrovsky , Juergen Gross , Jens Axboe , linux-block@vger.kernel.org (open list:BLOCK LAYER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 5/6] xen-blkfront: make local copy of response before using it Date: Mon, 30 Apr 2018 23:01:49 +0200 Message-Id: <4af6663fbb4b4a97e5c89096033064627367982d.1525122026.git-series.marmarek@invisiblethingslab.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: References: MIME-Version: 1.0 In-Reply-To: References: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Data on the shared page can be changed at any time by the backend. Make a local copy, which is no longer controlled by the backend. And only then access it. This is complementary to XSA155. CC: stable@vger.kernel.org Signed-off-by: Marek Marczykowski-Górecki --- drivers/block/xen-blkfront.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index 2a8e781..3926811 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -1549,7 +1549,7 @@ static bool blkif_completion(unsigned long *id, static irqreturn_t blkif_interrupt(int irq, void *dev_id) { struct request *req; - struct blkif_response *bret; + struct blkif_response bret; RING_IDX i, rp; unsigned long flags; struct blkfront_ring_info *rinfo = (struct blkfront_ring_info *)dev_id; @@ -1566,8 +1566,8 @@ static irqreturn_t blkif_interrupt(int irq, void *dev_id) for (i = rinfo->ring.rsp_cons; i != rp; i++) { unsigned long id; - bret = RING_GET_RESPONSE(&rinfo->ring, i); - id = bret->id; + RING_COPY_RESPONSE(&rinfo->ring, i, &bret); + id = bret.id; /* * The backend has messed up and given us an id that we would * never have given to it (we stamp it up to BLK_RING_SIZE - @@ -1575,39 +1575,39 @@ static irqreturn_t blkif_interrupt(int irq, void *dev_id) */ if (id >= BLK_RING_SIZE(info)) { WARN(1, "%s: response to %s has incorrect id (%ld)\n", - info->gd->disk_name, op_name(bret->operation), id); + info->gd->disk_name, op_name(bret.operation), id); /* We can't safely get the 'struct request' as * the id is busted. */ continue; } req = rinfo->shadow[id].request; - if (bret->operation != BLKIF_OP_DISCARD) { + if (bret.operation != BLKIF_OP_DISCARD) { /* * We may need to wait for an extra response if the * I/O request is split in 2 */ - if (!blkif_completion(&id, rinfo, bret)) + if (!blkif_completion(&id, rinfo, &bret)) continue; } if (add_id_to_freelist(rinfo, id)) { WARN(1, "%s: response to %s (id %ld) couldn't be recycled!\n", - info->gd->disk_name, op_name(bret->operation), id); + info->gd->disk_name, op_name(bret.operation), id); continue; } - if (bret->status == BLKIF_RSP_OKAY) + if (bret.status == BLKIF_RSP_OKAY) blkif_req(req)->error = BLK_STS_OK; else blkif_req(req)->error = BLK_STS_IOERR; - switch (bret->operation) { + switch (bret.operation) { case BLKIF_OP_DISCARD: - if (unlikely(bret->status == BLKIF_RSP_EOPNOTSUPP)) { + if (unlikely(bret.status == BLKIF_RSP_EOPNOTSUPP)) { struct request_queue *rq = info->rq; printk(KERN_WARNING "blkfront: %s: %s op failed\n", - info->gd->disk_name, op_name(bret->operation)); + info->gd->disk_name, op_name(bret.operation)); blkif_req(req)->error = BLK_STS_NOTSUPP; info->feature_discard = 0; info->feature_secdiscard = 0; @@ -1617,15 +1617,15 @@ static irqreturn_t blkif_interrupt(int irq, void *dev_id) break; case BLKIF_OP_FLUSH_DISKCACHE: case BLKIF_OP_WRITE_BARRIER: - if (unlikely(bret->status == BLKIF_RSP_EOPNOTSUPP)) { + if (unlikely(bret.status == BLKIF_RSP_EOPNOTSUPP)) { printk(KERN_WARNING "blkfront: %s: %s op failed\n", - info->gd->disk_name, op_name(bret->operation)); + info->gd->disk_name, op_name(bret.operation)); blkif_req(req)->error = BLK_STS_NOTSUPP; } - if (unlikely(bret->status == BLKIF_RSP_ERROR && + if (unlikely(bret.status == BLKIF_RSP_ERROR && rinfo->shadow[id].req.u.rw.nr_segments == 0)) { printk(KERN_WARNING "blkfront: %s: empty %s op failed\n", - info->gd->disk_name, op_name(bret->operation)); + info->gd->disk_name, op_name(bret.operation)); blkif_req(req)->error = BLK_STS_NOTSUPP; } if (unlikely(blkif_req(req)->error)) { @@ -1638,9 +1638,9 @@ static irqreturn_t blkif_interrupt(int irq, void *dev_id) /* fall through */ case BLKIF_OP_READ: case BLKIF_OP_WRITE: - if (unlikely(bret->status != BLKIF_RSP_OKAY)) + if (unlikely(bret.status != BLKIF_RSP_OKAY)) dev_dbg(&info->xbdev->dev, "Bad return from blkdev data " - "request: %x\n", bret->status); + "request: %x\n", bret.status); break; default: -- git-series 0.9.1