From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796409374; b=aDI1dH6RqqcmwMiquoE4vrtvATRIbldy1doOkcavYeC1hqbmms2ULwiwiYgoxf4W19wh KzfrTx4jnNo92KrzJMjc9XYJUPg3Olzp4rMqeB3BFrLjfpKl1ix2/2jhapOZsFBZDjTe/ DWOVxUd/KkFSAl+eV92+bjtZ+A0ByQiwTzyKoCXG9zauzxE5/ICIwDTKLVr4UdroNSQee uvoBN1jvzq05IQTJrsRmqj8tC+o8a0G7nxXNVdDHTMSr2VB6dVXTlFVtDDjFFxrb7UNt0 PyttpGAX1rwQtoAEDg61jAwSowP1HkV6U2NPVoNUoHRq4RSAnBFgZQYm5MXHZ/Dbh7Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796409374; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=Nf7d2PdozoTvDVTZ6yqYhLs6uqNF5Ubpyk6AvauH+A0=; b=tDrFDVdl5GrDeQWysl1feT7Jn7pQGsvQIkIIR/IA1oZOTO7p2/n3rH3vlOnFSmv8wIu/ hIaPpedkiQ3GPB7deV4xVr06ZecTTSL0yCeFnxF5cO+iU2E0SOZ6mATAoBuUBkM8WPo5L X789GAzSYh66xU3TaAU29CHxiGtdd3jbU91boOcaBhpaPGG/70DO8hjWh319yAPeYOuWd CFeGs57AqCurRxXrKMC/69r8cRTCjxCZu7jO4Mbbc5pcUfLzs67CheOnCD9Wf2R59ANIv 57sKFEE0K03jzXMKrN5lbtlV5NYIpdvNFX2EFlW5d7Zv+QI+x5f1RelbcBathbUSZFA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="NGPXtp/8"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4ADE2606A322 for ; Fri, 4 Dec 2026 18:36:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=NGPXtp/8 Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE9961F00936; Fri, 4 Dec 2026 18:36:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796409374; bh=Nf7d2PdozoTvDVTZ6yqYhLs6uqNF5Ubpyk6AvauH+A0=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=NGPXtp/8N+HPpckY0bYzbcIzGq6GgZ0plyCkF7pA5hVWeUMyJLKvhyHbKp3h2FISx CX4ss+3Fu7frt+F+2aSBe+sRSh/ZEeEtdJlJKPCSvwkONw2OIz6PNIgcEdCHE/1nXF AmLpLcnR2Pir0fxmY0pPYfF0XQTJsu80EpndLjWOYfPsr7lvc3t/ecR5vH4gtCz96d v/dYG4yup97IY0sFRe+A8hpDEJdDHL2DEWIXrfOZGZj/Rz7VdFvASDd7cOQQ5Yq54B +aADpgyRpsGOS7EAM793cawbMgNz7VF99xhLJmt6KrkEb+k43QF3mVmrzxsHUtKJjI fhCOSYtlVorPQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v3 1/8] x86/virt/tdx: Add interface to generate a Quote Reply-To: sashiko-reviews@lists.linux.dev To: "Peter Fang" Cc: kvm@vger.kernel.org In-Reply-To: <20261204182022.324230-2-peter.fang@intel.com> References: <20261204182022.324230-1-peter.fang@intel.com> <20261204182022.324230-2-peter.fang@intel.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 18:36:13 +0000 X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] x86/virt/tdx: uninit HPA list nodes and tail read in tdx_quote_generate() - [Medium] x86/virt/tdx: missing cond_resched() in tdx_quote_get() retry loop -- commit 822505db95798a7ae7ce913170aae5958aefcee1 Author: Peter Fang x86/virt/tdx: Add interface to generate a Quote This commit adds tdx_quote_generate() and a TDH.QUOTE.GET SEAMCALL wrapper = so KVM can request a signed TDX Quote using caller-provided host pages. > diff --git a/arch/x86/virt/vmx/tdx/tdx.c b/arch/x86/virt/vmx/tdx/tdx.c > index dbe17a136dced..39f280190b73d 100644 > --- a/arch/x86/virt/vmx/tdx/tdx.c > +++ b/arch/x86/virt/vmx/tdx/tdx.c > @@ -2529,6 +2529,102 @@ void tdx_free_control_page(struct page *page) > } > EXPORT_SYMBOL_FOR_KVM(tdx_free_control_page); > =20 > +static u64 tdx_quote_get(struct tdx_td *td, u16 session_id, > + struct page *report_page, u64 report_size, > + u64 *quote_hpa_list, u64 quote_buf_size, > + u64 *quote_size) > +{ [ ... ] > + do { > + r =3D seamcall_ret(TDH_QUOTE_GET, &args); > + } while (r =3D=3D TDX_INTERRUPTED_RESUMABLE); [Severity: Medium] Should this retry loop call cond_resched()? seamcall_ret() only calls preempt_enable(), which does not reschedule on CONFIG_PREEMPT_NONE or CONFIG_PREEMPT_VOLUNTARY kernels. In sleepable runtime context, spinning across TDX_INTERRUPTED_RESUMABLE retries can star= ve other tasks and delay RCU quiescent states, unlike init_tdmr(). [ ... ] > +int tdx_quote_generate(struct tdx_td *td, u16 session_id, > + struct page *report_page, u64 report_size, > + struct page **quote_pages, u64 quote_buf_size, > + u64 *quote_size, u64 *seamcall_err) > +{ > + int num_quote_pages, num_nodes, ret =3D 0; > + u64 *node_head, *node_entry; > + u64 r; > + > + /* > + * Pass the quote buffer to the TDX module as an HPA linked list. Each > + * node holds 4KB page HPAs and the last entry points to the next node. > + */ > + node_head =3D kmalloc(PAGE_SIZE, GFP_KERNEL); > + if (!node_head) > + return -ENOMEM; > + > + node_entry =3D node_head; > + num_quote_pages =3D PFN_UP(quote_buf_size); > + num_nodes =3D 1; > + > + /* Populate the linked list. Allocate new nodes as needed. */ > + for (int i =3D 0, pages =3D 0; pages < num_quote_pages; > + i =3D (i + 1) % HPAS_PER_NODE) { > + if (i =3D=3D HPAS_PER_NODE - 1) { > + u64 *new_node =3D kmalloc(PAGE_SIZE, GFP_KERNEL); > + > + if (!new_node) { > + ret =3D -ENOMEM; > + goto out_free_nodes; > + } > + > + /* Write the 'next' pointer. */ > + node_entry[i] =3D __pa(new_node); > + node_entry =3D new_node; > + num_nodes++; > + continue; > + } > + > + node_entry[i] =3D page_to_phys(quote_pages[pages]); > + pages++; > + } > + > + r =3D tdx_quote_get(td, session_id, report_page, report_size, node_head, > + quote_buf_size, quote_size); > + > + *seamcall_err =3D r; > + > + if (r !=3D TDX_SUCCESS) > + ret =3D -EIO; > + > +out_free_nodes: > + for (int i =3D 0; i < num_nodes; i++) { > + node_entry =3D node_head; > + node_head =3D __va(node_head[HPAS_PER_NODE - 1]); > + kfree(node_entry); > + } [Severity: Medium] Can node_head and new_node pass uninitialized slab memory to TDH_QUOTE_GET and read an uninitialized next pointer in out_free_nodes? Both allocations use kmalloc() instead of kzalloc(), and the loop only sets entries for pages < num_quote_pages and the next pointer when chaining a new node. Unused trailing HPA slots and the final node's next pointer remain uninitialized, which can cause TDH_QUOTE_GET to fail or walk bad addresses. The final iteration of out_free_nodes also unconditionally reads node_head[HPAS_PER_NODE - 1] on every call, including -ENOMEM, triggering an uninitialized heap read. Allocating nodes with kzalloc() and skipping the next-pointer read on the last node avoids both issues. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204182022.3242= 30-1-peter.fang@intel.com?part=3D1