mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Easwar Hariharan <easwar.hariharan@linux.microsoft.com>
To: Jeremy Linton <jeremy.linton@arm.com>
Cc: linux-acpi@vger.kernel.org, easwar.hariharan@linux.microsoft.com,
	jarredwhite@linux.microsoft.com, lenb@kernel.org,
	rafael@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ACPI: CPPC: Suppress UBSAN warning caused by field misuse
Date: Fri, 5 Jun 2026 09:33:41 -0700	[thread overview]
Message-ID: <ff856534-28b0-4867-abc6-84698b8a5d81@linux.microsoft.com> (raw)
In-Reply-To: <20260601235808.1113137-1-jeremy.linton@arm.com>

On 6/1/2026 16:58, Jeremy Linton wrote:
> The definition of reg->access_width changes depending on the
> reg->space_id type.  Type ACPI_ADR_SPACE_PLATFORM_COMM uses
> access_width to indicate the PCC region, which can result in a UBSAN
> if the value is greater than 4.
> 
> For example:
> 
>  UBSAN: shift-out-of-bounds in drivers/acpi/cppc_acpi.c:1090:9
>  shift exponent 32 is too large for 32-bit type 'int'
>  CPU: 61 UID: 0 PID: 1220 Comm: (udev-worker) Not tainted 7.0.10-201.fc44.aarch64 #1 PREEMPT(lazy)
>  Hardware name: To be filled by O.E.M.
>  Call trace:
>   ...(trimming)
>   ubsan_epilogue+0x10/0x48
>   __ubsan_handle_shift_out_of_bounds+0xdc/0x1e0
>   cpc_write+0x4d0/0x670
>   cppc_set_perf+0x18c/0x490
>   cppc_cpufreq_cpu_init+0x1c8/0x380 [cppc_cpufreq]
>   ... (trimming)
> 
> Lets fix this by validating the region type, as well as whether
> access_width has a value. Then since we are returning bit_width
> directly for ACPI_ADR_SPACE_PLATFORM_COMM, drop the code correcting
> the size.
> 
> Fixes: 2f4a4d63a193 ("ACPI: CPPC: Use access_width over bit_width for system memory accesses")
> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
> ---
>  drivers/acpi/cppc_acpi.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
Reviewed-by: Easwar Hariharan <easwar.hariharan@linux.microsoft.com>

  parent reply	other threads:[~2026-06-05 16:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-01 23:58 Jeremy Linton
2026-06-02 18:32 ` Jarred White
2026-06-05 16:33 ` Easwar Hariharan [this message]
2026-06-08 12:25   ` Rafael J. Wysocki

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=ff856534-28b0-4867-abc6-84698b8a5d81@linux.microsoft.com \
    --to=easwar.hariharan@linux.microsoft.com \
    --cc=jarredwhite@linux.microsoft.com \
    --cc=jeremy.linton@arm.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    /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

Powered by JetHome