Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2217380/?format=api
{ "id": 2217380, "url": "http://patchwork.ozlabs.org/api/patches/2217380/?format=api", "web_url": "http://patchwork.ozlabs.org/project/kvm-riscv/patch/20260328092157.75058-1-yufan.chen@linux.dev/", "project": { "id": 70, "url": "http://patchwork.ozlabs.org/api/projects/70/?format=api", "name": "Linux KVM RISC-V", "link_name": "kvm-riscv", "list_id": "kvm-riscv.lists.infradead.org", "list_email": "kvm-riscv@lists.infradead.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "http://lists.infradead.org/pipermail/kvm-riscv/", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260328092157.75058-1-yufan.chen@linux.dev>", "list_archive_url": null, "date": "2026-03-28T09:21:57", "name": "riscv/kvm: fix guest vector leak on host alloc failure", "commit_ref": null, "pull_url": null, "state": "not-applicable", "archived": false, "hash": "76495f4893cb16a545147214410a56e888fd391c", "submitter": { "id": 92996, "url": "http://patchwork.ozlabs.org/api/people/92996/?format=api", "name": "Yufan Chen", "email": "yufan.chen@linux.dev" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/kvm-riscv/patch/20260328092157.75058-1-yufan.chen@linux.dev/mbox/", "series": [ { "id": 497859, "url": "http://patchwork.ozlabs.org/api/series/497859/?format=api", "web_url": "http://patchwork.ozlabs.org/project/kvm-riscv/list/?series=497859", "date": "2026-03-28T09:21:57", "name": "riscv/kvm: fix guest vector leak on host alloc failure", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/497859/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2217380/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2217380/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "\n <kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n secure) header.d=lists.infradead.org header.i=@lists.infradead.org\n header.a=rsa-sha256 header.s=bombadil.20210309 header.b=WWPuRzmB;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256\n header.s=key1 header.b=LQGQxLsP;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=none (no SPF record) smtp.mailfrom=lists.infradead.org\n (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org;\n envelope-from=kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org;\n receiver=patchwork.ozlabs.org)" ], "Received": [ "from bombadil.infradead.org (bombadil.infradead.org\n [IPv6:2607:7c80:54:3::133])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fjX9F0XzCz1xtJ\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 28 Mar 2026 20:22:36 +1100 (AEDT)", "from localhost ([::1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux))\n\tid 1w6PsF-00000008mNJ-2Xx9;\n\tSat, 28 Mar 2026 09:22:31 +0000", "from out-180.mta0.migadu.com ([2001:41d0:1004:224b::b4])\n\tby bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux))\n\tid 1w6PsC-00000008mM9-1Z6j\n\tfor kvm-riscv@lists.infradead.org;\n\tSat, 28 Mar 2026 09:22:29 +0000" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20210309; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc\n\t:To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:\n\tResent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:\n\tList-Owner; bh=unkSkgiP8LzvensinrA917o4GdXFu1HmDRlvs7GaNL4=; b=WWPuRzmBKmqsGi\n\tL0/2DSO1ckyZJPZUh9UafQygjInjPY29jWaMh4NPqp+OxZP19SzHTH4+TC3iEjw4dyRt29CeE3JEL\n\tFlDmD7An4VkqpyCqwXIpH+eaEkf4TVzBY4LS3jboQWwjo7EY3sC0SOSeVc4AOqqQ9G4cw+y7vjnwX\n\ttiEsYwIqZAuBMCywdSVDW1lQpCEM5K91t3EN30FbgYORAXlecCnkxOsn7u5t89PfuG/qCUer4qNFh\n\tYOIHozqjItcSqM70fddIUj32aS5CUdFxSF8HIu0hVb+gkwOzlPKTdCrxGBEDkpTE/zDz/1o0BJMER\n\tU5HxLtfUtp5rgEMr1b9w==;", "v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1;\n\tt=1774689729;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\t to:to:cc:cc:mime-version:mime-version:\n\t content-transfer-encoding:content-transfer-encoding;\n\tbh=32F5mTJaAj0N/FgsyqUyjOrOpTIx3iyjz27Gm160YI0=;\n\tb=LQGQxLsPWUUKNiS9izD994OcRD4Qe8YmBJ2/6ybuHVLl7MGGBjWOElR2BGUgGHwfKmhtoT\n\tR48X4U/8G/SXxkly0CEAYbRZp/Aq9ovHcrfpLetqhPUx4ueSZOW3aZ6snWawrqEkigCePS\n\tlZf3p0VeRPJJHlDhgHnoU/ejGS4ypwU=" ], "X-Report-Abuse": "Please report any abuse attempt to abuse@migadu.com and\n include these headers.", "From": "Yufan Chen <yufan.chen@linux.dev>", "To": "Anup Patel <anup@brainfault.org>,\n\tAtish Patra <atish.patra@linux.dev>,\n\tPaul Walmsley <pjw@kernel.org>,\n\tPalmer Dabbelt <palmer@dabbelt.com>,\n\tAlbert Ou <aou@eecs.berkeley.edu>,\n\tAlexandre Ghiti <alex@ghiti.fr>,\n\tkvm@vger.kernel.org,\n\tkvm-riscv@lists.infradead.org,\n\tlinux-riscv@lists.infradead.org,\n\tlinux-kernel@vger.kernel.org", "Cc": "yufan.chen@linux.dev,\n\tYufan Chen <ericterminal@gmail.com>", "Subject": "[PATCH] riscv/kvm: fix guest vector leak on host alloc failure", "Date": "Sat, 28 Mar 2026 17:21:57 +0800", "Message-ID": "<20260328092157.75058-1-yufan.chen@linux.dev>", "MIME-Version": "1.0", "X-Developer-Signature": "v=1; a=openpgp-sha256; l=1515;\n i=ericterminal@gmail.com; h=from:subject;\n bh=NyfQPU3Jx0krdL2ohrnV2JS3MQSaKsafKvtyKGDOgko=;\n b=owGbwMvMwCXWM/dCzeS3H+sZT6slMWQen8OyTu1PtO8cubJjyjckVnkk+E65Zah1/P09Th+OB\n U7rTWz1OiayMIhxMViKKbLc/b9vbq7XrTnXuQ/nwsxhZQIZIi3SwAAELAx8uYl5pUY6Rnqm2oZ6\n hkY6BjrGDFycAjDVU2MZGd4zLJKIWpTyzoVD/cjFfqWSN2ZpJjwVPv6+73b6bcgL9waqOHGO1yO\n s/cU5sdtR5p/XBW9Mjp9gr+62/dNR/4aaC0ksAA==", "X-Developer-Key": "i=ericterminal@gmail.com; a=openpgp;\n fpr=DDFFBE9D6D4ADA9CD70BC36D8C9DD07C93EDF17F", "X-Migadu-Flow": "FLOW_OUT", "X-CRM114-Version": "20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ", "X-CRM114-CacheID": "sfid-20260328_022228_576339_E4BE1D87 ", "X-CRM114-Status": "UNSURE ( 7.73 )", "X-CRM114-Notice": "Please train this message.", "X-Spam-Score": "-2.1 (--)", "X-Spam-Report": "Spam detection software,\n running on the system \"bombadil.infradead.org\",\n has NOT identified this incoming email as spam. The original\n message has been attached to this so you can view it or label\n similar future email. If you have any questions, see\n the administrator of that system for details.\n Content preview: From: Yufan Chen <ericterminal@gmail.com> When allocating\n vector context for a vCPU, guest_context.vector.datap is allocated before\n host_context.vector.datap. If the second allocation fails,\n the function returns\n -ENOMEM directly and leaks the [...]\n Content analysis details: (-2.1 points, 5.0 required)\n pts rule name description\n ---- ----------------------\n --------------------------------------------------\n -0.0 SPF_PASS SPF: sender matches SPF record\n -0.0 SPF_HELO_PASS SPF: HELO matches SPF record\n 0.1 DKIM_SIGNED Message has a DKIM or DK signature,\n not necessarily valid\n -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from\n author's\n domain\n -0.1 DKIM_VALID Message has at least one valid DKIM or DK\n signature\n -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from\n envelope-from domain\n -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1%\n [score: 0.0000]", "X-BeenThere": "kvm-riscv@lists.infradead.org", "X-Mailman-Version": "2.1.34", "Precedence": "list", "List-Id": "<kvm-riscv.lists.infradead.org>", "List-Unsubscribe": "<http://lists.infradead.org/mailman/options/kvm-riscv>,\n <mailto:kvm-riscv-request@lists.infradead.org?subject=unsubscribe>", "List-Archive": "<http://lists.infradead.org/pipermail/kvm-riscv/>", "List-Post": "<mailto:kvm-riscv@lists.infradead.org>", "List-Help": "<mailto:kvm-riscv-request@lists.infradead.org?subject=help>", "List-Subscribe": "<http://lists.infradead.org/mailman/listinfo/kvm-riscv>,\n <mailto:kvm-riscv-request@lists.infradead.org?subject=subscribe>", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Sender": "\"kvm-riscv\" <kvm-riscv-bounces@lists.infradead.org>", "Errors-To": "kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org" }, "content": "From: Yufan Chen <ericterminal@gmail.com>\n\nWhen allocating vector context for a vCPU, guest_context.vector.datap is allocated before host_context.vector.datap. If the second allocation fails, the function returns -ENOMEM directly and leaks the guest buffer.\n\nSwitch the failure path to centralized cleanup. On host allocation failure, free guest_context.vector.datap, clear the pointer, and return -ENOMEM through a shared exit label.\n\nSigned-off-by: Yufan Chen <ericterminal@gmail.com>\n---\n arch/riscv/kvm/vcpu_vector.c | 12 ++++++++++--\n 1 file changed, 10 insertions(+), 2 deletions(-)", "diff": "diff --git a/arch/riscv/kvm/vcpu_vector.c b/arch/riscv/kvm/vcpu_vector.c\nindex 05f3cc2d8..4c2f92dce 100644\n--- a/arch/riscv/kvm/vcpu_vector.c\n+++ b/arch/riscv/kvm/vcpu_vector.c\n@@ -75,15 +75,23 @@ void kvm_riscv_vcpu_host_vector_restore(struct kvm_cpu_context *cntx)\n \n int kvm_riscv_vcpu_alloc_vector_context(struct kvm_vcpu *vcpu)\n {\n+\tint rc = -ENOMEM;\n+\n \tvcpu->arch.guest_context.vector.datap = kzalloc(riscv_v_vsize, GFP_KERNEL);\n \tif (!vcpu->arch.guest_context.vector.datap)\n-\t\treturn -ENOMEM;\n+\t\tgoto out;\n \n \tvcpu->arch.host_context.vector.datap = kzalloc(riscv_v_vsize, GFP_KERNEL);\n \tif (!vcpu->arch.host_context.vector.datap)\n-\t\treturn -ENOMEM;\n+\t\tgoto free_guest_vector_datap;\n \n \treturn 0;\n+\n+free_guest_vector_datap:\n+\tkfree(vcpu->arch.guest_context.vector.datap);\n+\tvcpu->arch.guest_context.vector.datap = NULL;\n+out:\n+\treturn rc;\n }\n \n void kvm_riscv_vcpu_free_vector_context(struct kvm_vcpu *vcpu)\n", "prefixes": [] }