mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: <Marius.Cristea@microchip.com>
To: <tristmd@gmail.com>, <jic23@kernel.org>
Cc: <tristan@talencesecurity.com>, <nuno.sa@analog.com>,
	<dlechner@baylibre.com>, <linux-iio@vger.kernel.org>,
	<andy@kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v5] iio: adc: pac1934: validate ACPI _DSM return type and bounds
Date: Fri, 30 Oct 2026 16:32:51 +0000	[thread overview]
Message-ID: <6eb7177ec4730be9307a3f4d29a53a952a7f7bbd.camel@microchip.com> (raw)
In-Reply-To: <20261030123528.606107-1-tristmd@gmail.com>

On Fri, 2026-10-30 at 12:35 +0000, Tristan Madani wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you
> know the content is safe
> 
> From: Tristan Madani <tristan@talencesecurity.com>
> 
> pac1934_acpi_parse_channel_config() calls acpi_evaluate_dsm() four
> times to read channel configuration but does not validate the
> returned
> object type or array bounds:
> 
>   1. No check that the returned object is ACPI_TYPE_PACKAGE.  If
>      firmware returns a different type, accessing rez->package.count
>      and rez->package.elements on a non-package object produces
>      unpredictable values.
> 
>   2. The loop bounds use rez->package.count directly without capping
>      to PAC1934_MAX_NUM_CHANNELS (4).  A package with more elements
>      than expected causes writes past the fixed-size labels[],
>      shunts[], and active_channels[] arrays.
> 
>   3. The bipolar and sample rate DSM calls access elements[0] without
>      verifying package.count >= 1.
> 
> Use acpi_evaluate_dsm_typed() with ACPI_TYPE_PACKAGE to validate the
> return type at evaluation time.  Cap loop iterations to
> PAC1934_MAX_NUM_CHANNELS, and verify package count >= 1 before
> accessing elements[0].
> 
> Signed-off-by: Tristan Madani <tristan@talencesecurity.com>
> ---
> Changes in v5:
> - Keep existing declaration order, only add new 'count' variable, per
>   Andy Shevchenko
> - Replace (count & ~1u) with min_t() cap and i + 1 < count loop bound
>   to avoid unsigned literal question, per Andy Shevchenko
> 
> Changes in v4:
> - Reorder variable declarations to reverse xmas tree, per Andy
> Shevchenko
> - Drop casts from min() parameters, per Andy Shevchenko
> 
> Changes in v3:
> - Use acpi_evaluate_dsm_typed() instead of manual type checks, per
>   Andy Shevchenko
> - Use (count & ~1u) for the name+mohm loop bound to ensure pairs
>   are complete, per Andy Shevchenko
> - Drop Fixes: and Cc: stable tags since this is hardening rather
>   than a fix for a specific regression, per Jonathan Cameron
>  drivers/iio/adc/pac1934.c | 33 +++++++++++++++++++++++++++------
>  1 file changed, 27 insertions(+), 6 deletions(-)
> 


Reviewed-by: Marius Cristea <marius.cristea@microchip.com>

      reply	other threads:[~2026-10-30 16:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-30 12:35 Tristan Madani
2026-10-30 16:32 ` Marius.Cristea [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=6eb7177ec4730be9307a3f4d29a53a952a7f7bbd.camel@microchip.com \
    --to=marius.cristea@microchip.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=tristan@talencesecurity.com \
    --cc=tristmd@gmail.com \
    /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

all inboxes | Powered by JetHome®