From: Dan Carpenter <error27@gmail.com>
To: Muhammad Bilal <meatuni001@gmail.com>
Cc: ardb@kernel.org, ivan.hu@canonical.com,
ilias.apalodimas@linaro.org, mingo@kernel.org,
matt@codeblueprint.co.uk, linux-efi@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] efi/efi_test: bound capsule_count to what the int loop index can hold
Date: Mon, 21 Sep 2026 16:33:22 +0300 [thread overview]
Message-ID: <arEyIsRJKRa7seUh@stanley.mountain> (raw)
In-Reply-To: <20260919192410.272516-1-meatuni001@gmail.com>
On Sun, Sep 20, 2026 at 12:24:10AM +0500, Muhammad Bilal wrote:
> efi_runtime_query_capsulecaps() only rejects capsule_count == ULONG_MAX
> (to stop "capsule_count + 1" wrapping the kzalloc_objs() count to
> zero), but then walks the array with
> "for (i = 0; i < qcaps.capsule_count; i++)"
> using a plain int i against an unsigned long bound. A capsule_count
> between INT_MAX and ULONG_MAX - 1 lets i wrap through INT_MIN instead
> of ever reaching the loop bound, and capsules[i] with a negative i
> indexes before the allocation.
>
> kzalloc_objs() would have to succeed at that size for the loop to be
> reached at all, which bounds this in practice, but the check should
> not rely on the allocator failing first. Reject any capsule_count
> that would not fit in the int index up front.
No, the it's fine to rely on kzalloc failure. Don't bother trying
to silence this false positive. Fix your checker instead.
>
> Fixes: 092e72c9edab ("efi/efi_test: Prevent an Oops in efi_runtime_query_capsulecaps()")
Certainly, don't add a Fixes tag.
> Signed-off-by: Muhammad Bilal <meatuni001@gmail.com>
> ---
Regards,
dan carpenter
prev parent reply other threads:[~2026-09-21 13:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-19 19:24 Muhammad Bilal
2026-09-21 13:33 ` Dan Carpenter [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=arEyIsRJKRa7seUh@stanley.mountain \
--to=error27@gmail.com \
--cc=ardb@kernel.org \
--cc=ilias.apalodimas@linaro.org \
--cc=ivan.hu@canonical.com \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matt@codeblueprint.co.uk \
--cc=meatuni001@gmail.com \
--cc=mingo@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
all inboxes | Powered by JetHome®