Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jiri Pirko" <jiri@resnulli.us>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH RFC 18/20] tdx-guest: Expose the native attestation service API
Date: Thu, 15 Oct 2026 15:40:05 +0000	[thread overview]
Message-ID: <sashiko-outbox-173083@kernel.org> (raw)
In-Reply-To: <20261015145053.3664509-19-jiri@resnulli.us>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] tdx: client attach failure aborts core driver initialization
- [Low] tdx: memory bloat per TSM report due to missing right-sizing
- [Low] Unreachable return statements after scoped_cond_guard
--

commit b1dd6a27af0398a52344b35c7786c4b3fbbf85c3
Author: Jiri Pirko <jiri@resnulli.us>

tdx-guest: Expose the native attestation service API

This patch shares TDREPORT, Quote and measurement-register operations with one
in-kernel client while preserving the existing misc, TSM report and TSM
MR interfaces. It ties clients to service initialization and removal.

> diff --git a/drivers/virt/coco/tdx-guest/tdx-guest.c b/drivers/virt/coco/tdx-guest/tdx-guest.c
> index d0303e31e8161..0d53170602463 100644
> --- a/drivers/virt/coco/tdx-guest/tdx-guest.c
> +++ b/drivers/virt/coco/tdx-guest/tdx-guest.c

[ ... ]

> +static int tdx_do_report(sockptr_t data, sockptr_t tdreport)
> +{
> +	scoped_cond_guard(mutex_intr, return -EINTR, &mr_lock)
> +		return __tdx_do_report(data, tdreport);
>  	return 0;
>  }

[Severity: Low]
Is the trailing return 0 unreachable? When scoped_cond_guard is used with a
single return statement as its body, both the success and failure branches
return immediately. The loop's internal break is never reached, preventing
execution from falling through to the statements following the macro.

[ ... ]

> +static int tdx_guest_quote_get(struct device *dev, const u8 *reportdata,
> +			       size_t length, void *out, size_t capacity,
> +			       size_t *out_length)
> +{
> +	if (!tdx_guest_device_valid(dev))
> +		return -ENODEV;
> +	scoped_cond_guard(mutex_intr, return -EINTR, &quote_lock)
> +		return __tdx_guest_quote_get(reportdata, length, out,
> +					     capacity, out_length);
> +	return 0;
> +}

[Severity: Low]
Is this trailing return 0 also unreachable for the same reason as in
tdx_do_report()?

[ ... ]

> +static int tdx_report_new_locked(struct tsm_report *report, void *data)
> +{
> +	struct tsm_report_desc *desc = &report->desc;
> +	size_t length;
> +	void *buf;
> +	int ret;
> +
> +	buf = kvmalloc(TDX_QUOTE_MAX_LEN, GFP_KERNEL);
> +	if (!buf)
> +		return -ENOMEM;
> +	ret = __tdx_guest_quote_get(desc->inblob, desc->inblob_len,
> +				    buf, TDX_QUOTE_MAX_LEN, &length);
> +	if (ret) {
> +		kvfree(buf);
> +		return ret;
> +	}
> +	report->outblob = buf;
> +	report->outblob_len = length;
> +	return 0;
> +}

[Severity: Low]
Does this code introduce persistent memory bloat for each TSM report?

The buffer is allocated at the maximum possible size of 128KB but is never
shrunk to the actual quote length returned in the length variable.

The previous implementation used kvmemdup() to size the buffer exactly to
the output length, which is typically much smaller than the 128KB maximum.
By leaving it at 128KB, could this increase the memory footprint for
concurrent reports?

[ ... ]

>  static int __init tdx_guest_init(void)
>  {
>  	int ret;

[ ... ]

>  	ret = tsm_report_register(&tdx_tsm_ops, NULL);
>  	if (ret)
>  		goto free_quote;
> +	scoped_guard(mutex, &client_lock) {
> +		tdx_service_ready = true;
> +		ret = tdx_guest_client_attach();
> +		if (ret)
> +			tdx_service_ready = false;
> +	}
> +	if (ret)
> +		goto unregister_tsm;
>  
>  	return 0;
>  
> +unregister_tsm:
> +	tsm_report_unregister(&tdx_tsm_ops);

[Severity: High]
Does a failure to attach a client here abort the entire core driver
initialization?

If a built-in client registers before tdx_guest_init() runs, a failure in
the client's add() callback will cause tdx_guest_client_attach() to fail.
This error is returned, causing a jump to unregister_tsm, which aborts the
initialization of the TDX guest driver and breaks other frontends like the
misc ioctl and configfs.

If the client is loaded after the driver, its failure does not affect the
core driver. Should the core provider ignore an optional downstream client's
failure and continue its initialization?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261015145053.3664509-1-jiri@resnulli.us?part=18

  reply	other threads:[~2026-10-15 15:40 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-15 14:50 [PATCH RFC 00/20] attestation: Add a common subsystem and TDX support Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 01/20] ctlv: Add the schema language and generator Jiri Pirko
2026-10-15 14:58   ` sashiko-bot
2026-10-15 14:50 ` [PATCH RFC 02/20] ctlv: Add the UAPI wire format and family API Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 03/20] ctlv: Add the root family specification and generated files Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 04/20] Documentation: ctlv: Add userspace ABI Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 05/20] ctlv: Prepare message input handling Jiri Pirko
2026-10-15 15:06   ` sashiko-bot
2026-10-15 14:50 ` [PATCH RFC 06/20] ctlv: Prepare blob descriptor validation Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 07/20] ctlv: Prepare schema validation Jiri Pirko
2026-10-15 15:14   ` sashiko-bot
2026-10-15 14:50 ` [PATCH RFC 08/20] ctlv: Prepare message output handling Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 09/20] ctlv: Prepare VA blob handling Jiri Pirko
2026-10-15 15:14   ` sashiko-bot
2026-10-15 14:50 ` [PATCH RFC 10/20] ctlv: Prepare event queue support Jiri Pirko
2026-10-15 15:22   ` sashiko-bot
2026-10-15 14:50 ` [PATCH RFC 11/20] ctlv: Prepare runtime introspection Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 12/20] ctlv: Add device and operation dispatch Jiri Pirko
2026-10-15 15:28   ` sashiko-bot
2026-10-15 14:50 ` [PATCH RFC 13/20] Documentation: ctlv: Describe how to write a family Jiri Pirko
2026-10-15 15:20   ` sashiko-bot
2026-10-15 14:50 ` [PATCH RFC 14/20] attestation: Add the base family specification and generated files Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 15/20] attestation: Prepare provider and instance core Jiri Pirko
2026-10-15 15:30   ` sashiko-bot
2026-10-15 14:50 ` [PATCH RFC 16/20] attestation: Prepare measurement register journal Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 17/20] attestation: Add CTLV operation handling Jiri Pirko
2026-10-15 15:33   ` sashiko-bot
2026-10-15 14:50 ` [PATCH RFC 18/20] tdx-guest: Expose the native attestation service API Jiri Pirko
2026-10-15 15:40   ` sashiko-bot [this message]
2026-10-15 14:50 ` [PATCH RFC 19/20] attestation: Add the TDX family specification and generated files Jiri Pirko
2026-10-15 14:50 ` [PATCH RFC 20/20] attestation: Add the TDX family implementation Jiri Pirko
2026-10-15 15:40   ` sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-173083@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=jiri@resnulli.us \
    --cc=kvm@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox