From patchwork Mon Dec 5 17:50:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Gardner X-Patchwork-Id: 1712432 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=bTxdkSZ0; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NQrhf5Hlbz23yl for ; Tue, 6 Dec 2022 04:51:46 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1p2Fcx-0006Im-Bk; Mon, 05 Dec 2022 17:51:39 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1p2Fcv-0006IM-5K for kernel-team@lists.ubuntu.com; Mon, 05 Dec 2022 17:51:37 +0000 Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id DAC393F13F for ; Mon, 5 Dec 2022 17:51:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1670262696; bh=sBmqXgz4frvpain9DwC7Mz543/TT9JcnFaMq2IQorZU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bTxdkSZ0cNhkKn+SM4nZjh9gzTd4HA57XACuKRWSZjKAoNHrfvGsgUPjnk3b7/DoW SBXOfnokeng+R3v81D2EAmsoRv7x+PRXSJFuM/F77bSvAV7Xvfy86GUSj5+CEhsCTn v7IdMnRBi7NL6sGB2eHxc+4m6B8n6jOd0eLsYPuQFRCr8b2IgA4S9azbzeb1/l+yJ0 tm4WRqm6+u73TJqqizRh5t9QOUoMDxResFzjQa5XUY3ZZW2y0Uks/2NzEMN/6Eup9g 3ZA+a5G9yrWpWfXTOVvi/pWgArRHsyq+fXUhcCBGtwX8Utj2RY+rrt2UuZWyTgK6G2 CijFY7TygSnfQ== Received: by mail-pl1-f200.google.com with SMTP id y6-20020a17090322c600b00189892baa53so14041859plg.6 for ; Mon, 05 Dec 2022 09:51:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sBmqXgz4frvpain9DwC7Mz543/TT9JcnFaMq2IQorZU=; b=7pdxQUwjCO2MSDyn+faEvSvs02SfkARwdcg94gp0etA6Y1A3mGC3xqw0foUVlWVYep BxIWpLpa/kj8h9cS1dNwLvO8LmyJpHup7Xw01OEIxgU7k7sMl/MwMN/3mXAqXNV791n0 si57PvVXP4ZNtNi91fomrFuHHaZ9sb4lsKVQgcVLc5Lt2r129qwYe2/qFJmjZjVVhY8V A3xWnUpWhzQ42DSLzPDuTwm2bmkxfxu3vmss8OfwRMlAwDMISS1MZH1+PDRM8krPSUlT k28as1aWvoWkIAQobXV+VgMgrJcjo378FvEeiNZ6FpuSLvoP7f3N6Nx6CF/I5yMZ6tS6 6yEA== X-Gm-Message-State: ANoB5pmZgrp0x3hLqlZuB5McKaz9+3QiHQNVQYkUmNO8WTdZB9iMdaxK 4TZFTISge2//9QJBbrAkLPwtWJ9eBK+gU3GtEEWwJvbFXERRUJLYv3D/sj4Y8UpLtM6jYzltmgk zh6UNTgXJdsaqnmDWy689N0Z/nIH6PSfgYSOGQxEdAA== X-Received: by 2002:a63:ec50:0:b0:476:df9e:e792 with SMTP id r16-20020a63ec50000000b00476df9ee792mr60735519pgj.210.1670262694910; Mon, 05 Dec 2022 09:51:34 -0800 (PST) X-Google-Smtp-Source: AA0mqf6B70D9S8+W2S3WG2NqgFtMvQtB0jMF6eS7ljIUDamWDLvnN7j6npVIC97MUffG/7N/B/jQ3w== X-Received: by 2002:a63:ec50:0:b0:476:df9e:e792 with SMTP id r16-20020a63ec50000000b00476df9ee792mr60735508pgj.210.1670262694695; Mon, 05 Dec 2022 09:51:34 -0800 (PST) Received: from localhost.localdomain ([69.163.84.166]) by smtp.gmail.com with ESMTPSA id p2-20020a622902000000b00575acb243besm10122251pfp.1.2022.12.05.09.51.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Dec 2022 09:51:34 -0800 (PST) From: Tim Gardner To: kernel-team@lists.ubuntu.com Subject: [PATCH] UBUNTU: SAUCE: scsi: storvsc: Fix swiotlb bounce buffer leak in confidential VM Date: Mon, 5 Dec 2022 10:50:56 -0700 Message-Id: <20221205175056.20806-2-tim.gardner@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221205175056.20806-1-tim.gardner@canonical.com> References: <20221205175056.20806-1-tim.gardner@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Michael Kelley https://lore.kernel.org/lkml/1670183564-76254-1-git-send-email-mikelley@microsoft.com/ storvsc_queuecommand() maps the scatter/gather list using scsi_dma_map(), which in a confidential VM allocates swiotlb bounce buffers. If the I/O submission fails in storvsc_do_io(), the I/O is typically retried by higher level code, but the bounce buffer memory is never freed. The mostly like cause of I/O submission failure is a full VMBus channel ring buffer, which is not uncommon under high I/O loads. Eventually enough bounce buffer memory leaks that the confidential VM can't do any I/O. The same problem can arise in a non-confidential VM with kernel boot parameter swiotlb=force. Fix this by doing scsi_dma_unmap() in the case of an I/O submission error, which frees the bounce buffer memory. Fixes: 743b237c3a7b ("scsi: storvsc: Add Isolation VM support for storvsc driver") Signed-off-by: Michael Kelley Acked-by: Thadeu Lima de Souza Cascardo --- drivers/scsi/storvsc_drv.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c index 302a29a8fd90..e817af18846e 100644 --- a/drivers/scsi/storvsc_drv.c +++ b/drivers/scsi/storvsc_drv.c @@ -1887,6 +1887,9 @@ static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd) ret = storvsc_do_io(dev, cmd_request, get_cpu()); put_cpu(); + if (ret) + scsi_dma_unmap(scmnd); + if (ret == -EAGAIN) { /* no more space */ ret = SCSI_MLQUEUE_DEVICE_BUSY;