Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Esben Haabendal" <esben@geanix.com>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH v4 6/7] iio: light: ltr501: Add ltr329 driver support
Date: Mon, 10 Aug 2026 07:24:54 +0000	[thread overview]
Message-ID: <20260810072455.426591F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260810-liteon-ltr329-v4-6-8bd3dfd15280@geanix.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Uninitialized kernel stack memory leak and functional corruption on big-endian systems due to regmap_bulk_read/write type mismatch.
--

--- Patch [6]: [PATCH v4 6/7] iio: light: ltr501: Add ltr329 driver support ---
commit 1db9cef73562002d6e7e4eeeed1f2b197809ecbf
Author: Esben Haabendal <esben@geanix.com>

iio: light: ltr501: Add ltr329 driver support

This adds support for the LTR-329ALS-01 chip, which is similar to the
LTR-303ALS-01, except it does not have interrupt support.

> diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c
> index b36bd10a02624..cd5ff00ef5e26 100644
> --- a/drivers/iio/light/ltr501.c
> +++ b/drivers/iio/light/ltr501.c

[ ... ]

> @@ -1257,6 +1271,18 @@ static const struct ltr501_chip_info ltr501_chip_info_tbl[] = {
>  		.channels = ltr301_channels,
>  		.no_channels = ARRAY_SIZE(ltr301_channels),
>  	},
> +	[ltr329] = {
> +		.partid = 0x0A,
> +		.als_gain = ltr559_als_gain_tbl,
> +		.als_gain_tbl_size = ARRAY_SIZE(ltr559_als_gain_tbl),
> +		.als_mode_active = BIT(0),
> +		.als_gain_mask = BIT(2) | BIT(3) | BIT(4),
> +		.als_gain_shift = 2,
> +		.no_irq_support = true,
> +		.info_no_irq = &ltr301_info_no_irq,
> +		.channels = ltr301_channels,
> +		.no_channels = ARRAY_SIZE(ltr301_channels),
> +	},
>  };

[Severity: High]
This is a pre-existing issue, but will this new ltr329 chip also be affected
by the big-endian stack leak in the driver's bulk read and write operations?

Looking at ltr501_trigger_handler() (and similarly in ltr501_read_thresh()
and ltr501_write_thresh()), the code uses regmap_bulk_read and 
regmap_bulk_write to read or write 2 bytes into a 4-byte integer variable:

drivers/iio/light/ltr501.c:ltr501_trigger_handler() {
    ...
    int psdata;
    ...
    ret = regmap_bulk_read(data->regmap, LTR501_PS_DATA, &psdata, 2);
    ...
    scan.channels[j++] = psdata & LTR501_PS_DATA_MASK;
    ...
}

On big-endian systems, wouldn't reading 2 bytes into the address of psdata
only populate the upper half of the 32-bit integer, leaving the lower half
uninitialized? 

Since the lower half contains uninitialized kernel stack memory,
doesn't masking and storing this in the IIO scan buffer leak stack memory to
userspace?

Similarly, wouldn't ltr501_write_thresh() corrupt the threshold configuration
by writing 2 bytes from the lowest address of val (which are 0x00 on
big-endian)?

Could we fix this driver-wide issue by using 16-bit variables (like __le16)
for these 2-byte regmap_bulk_read and regmap_bulk_write operations?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260810-liteon-ltr329-v4-0-8bd3dfd15280@geanix.com?part=6

  reply	other threads:[~2026-08-10  7:24 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-10  7:11 [PATCH v4 0/7] iio: light: ltr501: Add ltr329 support Esben Haabendal
2026-08-10  7:11 ` [PATCH v4 1/7] dt-bindings: iio: light: ltr501: Sort compatible enum array Esben Haabendal
2026-08-10  7:11 ` [PATCH v4 2/7] dt-bindings: iio: light: ltr501: Add missing ltr303 compatible Esben Haabendal
2026-08-10  7:11 ` [PATCH v4 3/7] dt-bindings: iio: light: ltr501: Add ltr329 compatible Esben Haabendal
2026-08-10  7:19   ` sashiko-bot
2026-08-10 15:50   ` Rob Herring
2026-08-10  7:11 ` [PATCH v4 4/7] iio: light: ltr501: Power down chip if request irq fails Esben Haabendal
2026-08-10  7:23   ` sashiko-bot
2026-08-10  7:11 ` [PATCH v4 5/7] iio: light: ltr501: Fix duplicated error message Esben Haabendal
2026-08-10  7:11 ` [PATCH v4 6/7] iio: light: ltr501: Add ltr329 driver support Esben Haabendal
2026-08-10  7:24   ` sashiko-bot [this message]
2026-08-10 19:57   ` Andy Shevchenko
2026-08-10  7:11 ` [PATCH v4 7/7] iio: light: ltr501: Fix sorting order of device arrays Esben Haabendal
2026-08-10 19:59 ` [PATCH v4 0/7] iio: light: ltr501: Add ltr329 support Andy Shevchenko

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=20260810072455.426591F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=esben@geanix.com \
    --cc=robh@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