Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: "Onur Özkan" <work@onurozkan.dev>
To: Gary Guo <gary@garyguo.net>
Cc: Yuan Tan <ytan089@ucr.edu>,
	ojeda@kernel.org, boqun@kernel.org,
	rust-for-linux@vger.kernel.org, zhiyunq@cs.ucr.edu,
	ardalan@uci.edu, pgovind2@uci.edu, dzueck@uci.edu,
	stable@vger.kernel.org
Subject: Re: [PATCH] rust: firmware: return empty slice for zero-size firmware
Date: Fri,  5 Jun 2026 12:16:31 +0300	[thread overview]
Message-ID: <20260605091632.313084-1-work@onurozkan.dev> (raw)
In-Reply-To: <DJ0YRJ6MHAU7.WVR4P2MQ4HIX@garyguo.net>

On Fri, 05 Jun 2026 09:13:55 +0100
Gary Guo <gary@garyguo.net> wrote:

> On Fri Jun 5, 2026 at 8:10 AM BST, Onur Özkan wrote:
> > On Thu, 04 Jun 2026 21:11:34 -0700
> > Yuan Tan <ytan089@ucr.edu> wrote:
> >
> >> Firmware::data() builds a Rust slice with core::slice::from_raw_parts().
> >> Unlike many C APIs, from_raw_parts() requires its pointer argument to be
> >> non-NULL even when the length is zero.
> >> 
> >> The firmware loader can represent an empty firmware image with size == 0
> >
> >
> > I haven't checked in detail yet but "empty firmware image with size == 0"
> > sounds like an invalid image. Can such an image actually make it all the way
> > to Firmware::data()? I would be surprised if the loader accepted it.
> 
> `kernel_read_file` will return EINVAL if file is of zero size. But I think the
> decompression path might produce this? The zstd code just does a
> 
>     out_buf = vzalloc(out_size);
> 
> which will trigger a WARN but still return NULL.

On NULL, it immediately fails with ENOMEM:

	out_buf = vzalloc(out_size);
	if (!out_buf)
		return -ENOMEM;

Thanks,
Onur

> 
> That said, I doubt any valid firmware will be just a compressed empty file.
> 
> Best,
> Gary

  reply	other threads:[~2026-06-05  9:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-05  4:11 [PATCH] rust: firmware: return empty slice for zero-size firmware Yuan Tan
2026-06-05  7:10 ` Onur Özkan
2026-06-05  8:13   ` Gary Guo
2026-06-05  9:16     ` Onur Özkan [this message]
2026-06-05  9:28       ` Gary Guo
2026-06-05 11:15         ` Miguel Ojeda
2026-06-05 13:11           ` Onur Özkan

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=20260605091632.313084-1-work@onurozkan.dev \
    --to=work@onurozkan.dev \
    --cc=ardalan@uci.edu \
    --cc=boqun@kernel.org \
    --cc=dzueck@uci.edu \
    --cc=gary@garyguo.net \
    --cc=ojeda@kernel.org \
    --cc=pgovind2@uci.edu \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=ytan089@ucr.edu \
    --cc=zhiyunq@cs.ucr.edu \
    /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