mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Joshua Crofts <crofts@kernel.org>
Cc: "Raffaele Tranfaglia via B4 Relay"
	<devnull+raffaele.tranfaglia.gmail.com@kernel.org>,
	raffaele.tranfaglia@gmail.com,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Dmitry Osipenko" <digetx@gmail.com>,
	"David Heidelberg" <david@ixit.cz>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: light: al3010: fix out-of-bounds read of the scale table
Date: Wed, 4 Nov 2026 01:48:09 +0000	[thread overview]
Message-ID: <20261104014809.75e92a17@jic23-hlaptop> (raw)
In-Reply-To: <20261103140055.00000efd@kernel.org>

On Tue, 3 Nov 2026 14:00:55 +0100
Joshua Crofts <crofts@kernel.org> wrote:

> On Tue, 03 Nov 2026 08:42:48 +0000
> Raffaele Tranfaglia via B4 Relay <devnull+raffaele.tranfaglia.gmail.com@kernel.org> wrote:
> 
> > From: Raffaele Tranfaglia <raffaele.tranfaglia@gmail.com>
> > 
> > The gain field read from the CONFIG register is three bits wide, so it
> > can hold values from 0 to 7, but al3010_scales[] only has four entries.
> > If the register holds a gain value of 4 or more, reading the scale
> > attribute indexes past the end of the table and returns garbage.
> > 
> > Reject such values with -EINVAL instead of indexing past the end of
> > the table.
> > 
> > Fixes: c36b5195ab70 ("iio: light: add Dyna-Image AL3010 driver")
Dropped the fixes tag.  This is hardening against buggy hardware
rather than fixing an issue anyone should encounter with a correctly
functioning device.

I don't mind such hardening (when simple and maintainable which 
your example here is) but I don't want to mark them as fixes
as that tends to trigger backporting which may not be appropriate.

Applied to the testing branch of iio.git with that tag dropped.

Jonathan

> > Signed-off-by: Raffaele Tranfaglia <raffaele.tranfaglia@gmail.com>
> > ---
> > Found with LLM-assisted static analysis of drivers/iio, looking for
> > table lookups indexed by unchecked register fields; the fix was drafted
> > with the same assistant and reviewed and tested by me.
> > 
> > Tested on arm64 QEMU with i2c-stub and CONFIG_UBSAN_BOUNDS=y. After
> > writing a gain value of 4 to CONFIG (0x10), reading
> > in_illuminance_scale:
> > - before: two array-index-out-of-bounds reports (al3010.c:137 and
> >   :138), and the attribute reads 0.000000
> > - after: the read fails with -EINVAL and no report is printed
> > ---  
> 
> Reviewed-by: Joshua Crofts <crofts@kernel.org>
> 


      reply	other threads:[~2026-11-04  1:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-03  8:42 Raffaele Tranfaglia via B4 Relay
2026-11-03 13:00 ` Joshua Crofts
2026-11-04  1:48   ` Jonathan Cameron [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=20261104014809.75e92a17@jic23-hlaptop \
    --to=jic23@kernel.org \
    --cc=andy@kernel.org \
    --cc=crofts@kernel.org \
    --cc=david@ixit.cz \
    --cc=devnull+raffaele.tranfaglia.gmail.com@kernel.org \
    --cc=digetx@gmail.com \
    --cc=dlechner@baylibre.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=raffaele.tranfaglia@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®