The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Laxman Acharya Padhya <acharyalaxman8848@gmail.com>
Cc: "Jonathan Cameron" <jic23@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Joshua Crofts" <joshua.crofts1@gmail.com>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH v3] iio: proximity: hx9023s: validate firmware size
Date: Mon, 13 Jul 2026 14:34:32 +0300	[thread overview]
Message-ID: <alTNSJODSTsPWyAF@ashevche-desk.local> (raw)
In-Reply-To: <CAMyXUJnsV1GD0VmK_n25hqr_=A5Z=u_gCXV=oACgKuP3dSgwnQ@mail.gmail.com>

On Mon, Jul 13, 2026 at 10:31:30AM +0545, Laxman Acharya Padhya wrote:
> hx9023s_send_cfg() copies the firmware into a counted flexible array and
> then reads fixed offsets from the copied data before walking register/value
> pairs starting at FW_DATA_OFFSET. A truncated firmware image can therefore
> make the driver read past the copied buffer during probe-time configuration
> loading.
> 
> Reject firmware images that cannot contain the fixed header, reject images
> too large for the u16 fw_size field, and validate that the advertised
> register count fits in the remaining payload.

> Fixes: e9ed97be4fcc ("iio: proximity: hx9023s: Added firmware file
> parsing functionality")

This has to be a single line.

> Cc: stable@vger.kernel.org
> Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>
> Signed-off-by: Laxman Acharya Padhya <acharyalaxman8848@gmail.com>

...

> v3:
> - Resend once in plain-text format after the duplicate v2 messages.
> - Keep each commit trailer on one complete line.

None of these is being addressed.

...

>  static int hx9023s_send_cfg(const struct firmware *fw, struct
> hx9023s_data *data)
>  {
> + /* fw_size is u16 in struct hx9023s_bin, so reject truncation. */
> + if (fw->size < FW_DATA_OFFSET || fw->size > U16_MAX)
> + return -EINVAL;

The patch is mangled. Please, conduct an investigation before sending any new
versions or other patches to the kernel mailing lists.

>   struct hx9023s_bin *bin __free(kfree) =
>    kzalloc(fw->size + sizeof(*bin), GFP_KERNEL);
>   if (!bin)

Compare the above to

	struct hx9023s_bin *bin __free(kfree) =
		kzalloc(fw->size + sizeof(*bin), GFP_KERNEL);
	if (!bin)
		return -ENOMEM;

	bin->fw_size = fw->size;
	memcpy(bin->data, fw->data, bin->fw_size);

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2026-07-13 11:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-13  4:46 [PATCH v3] iio: proximity: hx9023s: validate firmware size Laxman Acharya Padhya
2026-07-13 11:34 ` Andy Shevchenko [this message]
2026-07-13 11:41   ` Joshua Crofts

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=alTNSJODSTsPWyAF@ashevche-desk.local \
    --to=andriy.shevchenko@intel.com \
    --cc=acharyalaxman8848@gmail.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=joshua.crofts1@gmail.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=stable@vger.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