All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Esben Haabendal" <esben@geanix.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v2 3/4] iio: light: ltr501: Add ltr329 driver support
Date: Wed, 15 Jul 2026 12:48:55 +0000	[thread overview]
Message-ID: <20260715124855.9A8841F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260715-liteon-ltr329-v2-3-d18af55edab5@geanix.com>

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

Pre-existing issues:
- [High] Use-After-Free of IIO event interface due to mixing devm_request_threaded_irq with manual iio_device_unregister
- [High] Kernel stack memory leak and logic failure on big-endian systems due to reading 2 bytes into an uninitialized 4-byte integer
--

--- Patch [3]: [PATCH v2 3/4] iio: light: ltr501: Add ltr329 driver support ---
commit 8ae95bcf91bc6043da3fe9505d6fab5f356128f7
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
LTR-303ALS-01, except for interrupt, which LTR-329ALS-01 chip does not
have.

> diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c
> index 7d045be78c6df..379e57ac5f5b2 100644
> --- a/drivers/iio/light/ltr501.c
> +++ b/drivers/iio/light/ltr501.c

[ ... ]

> @@ -1531,6 +1556,12 @@ static int ltr501_probe(struct i2c_client *client)
>  		return ret;
>  
>  	if (client->irq > 0) {
> +		if (!ltr501_has_irq_support(data->chip_info)) {
> +			dev_err(&client->dev, "chip does not support irq\n");
> +			ret = -EINVAL;
> +			goto powerdown_on_error;
> +		}
> +
>  		ret = devm_request_threaded_irq(&client->dev, client->irq,

[Severity: High]
This is a pre-existing issue, but does using devres for the IRQ while
manually unregistering the IIO device cause a use-after-free?

In ltr501_remove(), iio_device_unregister() is called manually, which
frees the event interface. However, because the IRQ is allocated with
devm_request_threaded_irq(), it remains active until after
ltr501_remove() returns.

If an interrupt fires during this window, ltr501_interrupt_handler()
could call iio_push_event(), which accesses the freed event interface.


[Severity: High]
This is also a pre-existing issue, but is there a risk of leaking kernel
stack memory on big-endian systems in ltr501_trigger_handler()?

In ltr501_trigger_handler(), regmap_bulk_read() reads 2 bytes into an
uninitialized 4-byte integer:

ltr501_trigger_handler() {
    ...
    int psdata;
    ...
    ret = regmap_bulk_read(data->regmap, LTR501_PS_DATA, &psdata, 2);
    ...
}

On big-endian architectures, these 2 bytes overwrite the most
significant bytes of psdata, leaving the least significant bytes
uninitialized.

The driver then applies a mask:

    scan.channels[j++] = psdata & LTR501_PS_DATA_MASK;

Could this extract uninitialized kernel stack data and push it to the
IIO ring buffer, exposing it to userspace?

>  						NULL, ltr501_interrupt_handler,
>  						IRQF_TRIGGER_FALLING |

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260715-liteon-ltr329-v2-0-d18af55edab5@geanix.com?part=3

  reply	other threads:[~2026-07-15 12:48 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-15 12:27 [PATCH v2 0/4] iio: light: ltr501: Add ltr329 support Esben Haabendal
2026-07-15 12:27 ` [PATCH v2 1/4] dt-bindings: iio: light: ltr501: Add missing ltr303 compatible Esben Haabendal
2026-07-15 12:37   ` sashiko-bot
2026-07-15 12:27 ` [PATCH v2 2/4] dt-bindings: iio: light: ltr501: Add ltr329 compatible Esben Haabendal
2026-07-15 12:27 ` [PATCH v2 3/4] iio: light: ltr501: Add ltr329 driver support Esben Haabendal
2026-07-15 12:48   ` sashiko-bot [this message]
2026-07-15 12:53   ` Joshua Crofts
2026-07-15 13:55     ` Esben Haabendal
2026-07-15 13:58       ` Joshua Crofts
2026-07-15 13:16   ` Nuno Sá
2026-07-15 13:43     ` Esben Haabendal
2026-07-15 14:25       ` Nuno Sá
2026-07-15 12:27 ` [PATCH v2 4/4] iio: light: ltr501: Power down chip if request irq fails Esben Haabendal
2026-07-15 12:59   ` Joshua Crofts
2026-07-15 13:32     ` Esben Haabendal
2026-07-15 13:01   ` Nuno Sá
2026-07-15 13:31     ` Esben Haabendal
2026-07-15 13:53     ` Esben Haabendal
2026-07-15 12:55 ` [PATCH v2 0/4] iio: light: ltr501: Add ltr329 support Joshua Crofts
2026-07-15 13:17   ` Nuno Sá
2026-07-15 13:34     ` Esben Haabendal

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=20260715124855.9A8841F000E9@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.