Linux EFI development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Christopher Obbard" <chris.obbard@oss.qualcomm.com>,
	"Ard Biesheuvel" <ardb@kernel.org>,
	"Ilias Apalodimas" <ilias.apalodimas@linaro.org>
Cc: "Bjorn Andersson" <andersson@kernel.org>,
	"Johan Hovold" <johan@kernel.org>,
	"Marc Zyngier" <maz@kernel.org>,
	linux-efi@vger.kernel.org
Subject: Re: [PATCH RFC] efi/libstub: arm64: Disable pointer authentication on the ThinkPad X13s
Date: Sat, 05 Dec 2026 19:08:49 +0000	[thread overview]
Message-ID: <sashiko-outbox-251850@kernel.org> (raw)
In-Reply-To: <20261205-wip-obbardc-qcom-x13s-nopauth-v1-1-913a21a18286@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [High] efi/libstub: empty cmdline clobbers FDT bootargs and
  CONFIG_CMDLINE
- [Medium] efi/libstub: efi_quirk_cmdline ignored under
  CONFIG_CMDLINE_FORCE
- [Medium] efi/libstub: efi_add_quirk_cmdline() can exceed
  COMMAND_LINE_SIZE
- [Low] efi/libstub: unmeasured SMBIOS quirk disables PAuth via
  arm64.nopauth
--

commit 996c453c39b0a2907966f4e7ee2f19941e71289e
Author: Christopher Obbard <chris.obbard@oss.qualcomm.com>

efi/libstub: arm64: Disable pointer authentication on the ThinkPad X13s

This commit adds an efi_quirk_cmdline hook so check_platform_features() can
prepend kernel command line options in the EFI stub, and uses it on arm64
to prepend arm64.nopauth on the Lenovo ThinkPad X13s based on SMBIOS type 1
strings.

Link: https://github.com/jhovold/linux/wiki/X13s#kernel-command-line
Link: https://git.launchpad.net/~ubuntu-concept/ubuntu/+source/ubuntu-x13s-settings/tree/grub.d/ubuntu-x13s-settings.cfg?h=main
Link: https://wiki.debian.org/InstallingDebianOn/Thinkpad/X13s#Boot_Debian_Installer

> diff --git a/drivers/firmware/efi/libstub/arm64.c b/drivers/firmware/efi/libstub/arm64.c
> index c190a3ac97001..838df75a46587 100644
> --- a/drivers/firmware/efi/libstub/arm64.c
> +++ b/drivers/firmware/efi/libstub/arm64.c
> @@ -55,6 +55,24 @@ static bool system_needs_vamap(void)
>  	return false;
>  }
>  
> +static bool system_is_thinkpad_x13s(void)
> +{
> +	const struct efi_smbios_type1_record *record;
> +	const u8 *str;
> +
> +	record = (struct efi_smbios_type1_record *)efi_get_smbios_record(1);
> +	if (!record || record->header.length <
> +		       offsetofend(struct efi_smbios_type1_record, family))
> +		return false;
> +
> +	str = efi_get_smbios_string(record, manufacturer);
> +	if (!str || strcmp(str, "LENOVO"))
> +		return false;
> +
> +	str = efi_get_smbios_string(record, family);
> +	return str && !strcmp(str, "ThinkPad X13s Gen 1");
> +}
> +
>  efi_status_t check_platform_features(void)
>  {
>  	u64 tg;
> @@ -67,6 +85,13 @@ efi_status_t check_platform_features(void)
>  	if (VA_BITS_MIN >= 48 && !system_needs_vamap())
>  		efi_novamap = true;
>  
> +	/*
> +	 * The Lenovo ThinkPad X13s firmware does not let the kernel use
> +	 * pointer authentication, and the kernel does not boot if it tries.
> +	 */
> +	if (IS_ENABLED(CONFIG_ARM64_PTR_AUTH) && system_is_thinkpad_x13s())
> +		efi_quirk_cmdline = "arm64.nopauth";

[Severity: Low]
Can an untrusted host VMM in a confidential arm64 guest spoof these SMBIOS
type 1 strings to disable pointer authentication without affecting the
measured command line?

efi_convert_cmdline() measures the raw LoadOptions into
EFISTUB_EVT_LOAD_OPTIONS before efi_stub_common() runs, and
system_is_thinkpad_x13s() checks only SMBIOS strings without a hardware
identity check (such as MIDR_EL1) or measurement of efi_quirk_cmdline.

In an Arm CCA Realm booting via UEFI, a spoofed SMBIOS table would force
all six pointer authentication ID register fields to zero while leaving the
load-options measurement unchanged.

> diff --git a/drivers/firmware/efi/libstub/efi-stub.c b/drivers/firmware/efi/libstub/efi-stub.c
> index a824b2ba3026b..7747da185399f 100644
> --- a/drivers/firmware/efi/libstub/efi-stub.c
> +++ b/drivers/firmware/efi/libstub/efi-stub.c

[ ... ]

> @@ -173,12 +179,34 @@ efi_status_t efi_handle_cmdline(efi_loaded_image_t *image, char **cmdline_ptr)
>  	return EFI_SUCCESS;
>  }
>  
> +/*
> + * Put efi_quirk_cmdline in front of the command line. It has to go first,
> + * because anything after "--" is passed to init.
> + */
> +static char *efi_add_quirk_cmdline(char *cmdline)
> +{
> +	size_t quirk_len = strlen(efi_quirk_cmdline);
> +	size_t len = strlen(cmdline);
> +	char *new;
> +
> +	if (efi_bs_call(allocate_pool, EFI_LOADER_DATA, quirk_len + len + 2,
> +			(void **)&new) != EFI_SUCCESS)
> +		return NULL;

[Severity: Medium]
Can prepending efi_quirk_cmdline push the command line past
COMMAND_LINE_SIZE?

efi_convert_cmdline() caps the converted command line at
COMMAND_LINE_SIZE - 1 bytes and truncates on a safe whitespace boundary
outside quotes.

Because efi_add_quirk_cmdline() adds quirk_len + 1 bytes without re-checking
that bound, early_init_dt_scan_chosen() will silently truncate the tail
mid-option or mid-quote, while idreg-override.c:get_bootargs_cmdline() still
parses the untruncated /chosen/bootargs property.

> +	memcpy(new, efi_quirk_cmdline, quirk_len);
> +	new[quirk_len] = ' ';
> +	memcpy(new + quirk_len + 1, cmdline, len + 1);
> +
> +	return new;
> +}

[Severity: High]
Does turning an empty UEFI command line into "arm64.nopauth " clobber
existing FDT /chosen/bootargs and disable the CONFIG_CMDLINE fallback?

When UEFI LoadOptions are empty, update_fdt() previously skipped writing
/chosen/bootargs, preserving DTB bootargs or allowing
early_init_dt_scan_chosen() and idreg-override.c:parse_cmdline() to fall
back to CONFIG_CMDLINE.

Because cmdline_ptr is now non-empty, update_fdt() overwrites
/chosen/bootargs, dropping all configured boot parameters (such as root= or
console=) on setups that boot with empty LoadOptions.  It also leaves a
trailing space when cmdline is empty.

[ ... ]

> @@ -186,6 +214,18 @@ efi_status_t efi_stub_common(efi_handle_t handle,
>  	if (status != EFI_SUCCESS)
>  		return status;
>  
> +	if (efi_quirk_cmdline) {
> +		quirk_cmdline = efi_add_quirk_cmdline(cmdline_ptr);
> +		if (quirk_cmdline) {
> +			efi_info("Adding \"%s\" to the command line\n",
> +				 efi_quirk_cmdline);
> +			cmdline_ptr = quirk_cmdline;
> +		} else {
> +			efi_warn("Failed to add \"%s\" to the command line\n",
> +				 efi_quirk_cmdline);
> +		}
> +	}

[Severity: Medium]
Should this skip adding efi_quirk_cmdline (or avoid claiming it was added)
when CONFIG_CMDLINE_FORCE is enabled?

Both early_init_dt_scan_chosen() and idreg-override.c:parse_cmdline()
ignore /chosen/bootargs under CONFIG_CMDLINE_FORCE, so arm64.nopauth has no
effect and pointer authentication remains enabled despite the info message.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261205-wip-obbardc-qcom-x13s-nopauth-v1-1-913a21a18286@oss.qualcomm.com?part=1

      reply	other threads:[~2026-12-05 19:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-05 18:50 [PATCH RFC] efi/libstub: arm64: Disable pointer authentication on the ThinkPad X13s Christopher Obbard
2026-12-05 19:08 ` sashiko-bot [this message]

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-251850@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=andersson@kernel.org \
    --cc=ardb@kernel.org \
    --cc=chris.obbard@oss.qualcomm.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=johan@kernel.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=maz@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