From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Rodrigo Gobbi <rodrigo.gobbi.7@gmail.com>
Cc: andy@kernel.org, hansg@kernel.org, mchehab@kernel.org,
sakari.ailus@linux.intel.com, gregkh@linuxfoundation.org,
feng@innora.ai, ~lkcamp/patches@lists.sr.ht,
linux-kernel-mentees@lists.linux.dev,
linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
linux-staging@lists.linux.dev
Subject: Re: [PATCH v3 2/3] staging: media: atomisp: use kvmalloc_objs() for overflow-safe allocation
Date: Thu, 25 Jun 2026 10:14:04 +0300 [thread overview]
Message-ID: <ajzVPHie23a90TA3@ashevche-desk.local> (raw)
In-Reply-To: <20260623221028.40238-3-rodrigo.gobbi.7@gmail.com>
On Tue, Jun 23, 2026 at 07:09:27PM -0300, Rodrigo Gobbi wrote:
> Replace open-coded width * height * sizeof() multiplications with
> kvmalloc_objs() and array_size() to prevent integer overflow in buffer
> allocations.
>
> The atomisp driver computes DVS and statistics buffer sizes using
> unchecked arithmetic. When dimensions are large, the product can
> silently wrap, causing kvmalloc() to allocate an undersized buffer.
>
> kvmalloc_objs() uses size_mul() internally, which saturates to SIZE_MAX
> on overflow, so kvmalloc() returns NULL instead of succeeding with too
> few bytes. array_size() provides the same overflow protection for the
> two-factor dimension products.
>
> Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> Signed-off-by: Feng Ning <feng@innora.ai>
> [rodrigo: rebased; convert only the sites left open-coded after
> commit d178c7ca8fef]
Thanks, you can keep this on a single line
[rodrigo: rebased; convert only the sites left open-coded after commit d178c7ca8fef]
> Signed-off-by: Rodrigo Gobbi <rodrigo.gobbi.7@gmail.com>
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2026-06-25 7:14 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-23 22:09 [PATCH v3 0/3] staging: media: atomisp: use kvmalloc_objs() and drop redundant OOM messages Rodrigo Gobbi
2026-06-23 22:09 ` [PATCH v3 1/3] staging: media: atomisp: use kvmalloc_objs() in make_histogram() Rodrigo Gobbi
2026-06-23 22:09 ` [PATCH v3 2/3] staging: media: atomisp: use kvmalloc_objs() for overflow-safe allocation Rodrigo Gobbi
2026-06-25 7:14 ` Andy Shevchenko [this message]
2026-06-23 22:09 ` [PATCH v3 3/3] staging: media: atomisp: drop redundant out-of-memory messages Rodrigo Gobbi
2026-06-25 7:14 ` [PATCH v3 0/3] staging: media: atomisp: use kvmalloc_objs() and drop redundant OOM messages Andy Shevchenko
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=ajzVPHie23a90TA3@ashevche-desk.local \
--to=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=feng@innora.ai \
--cc=gregkh@linuxfoundation.org \
--cc=hansg@kernel.org \
--cc=linux-kernel-mentees@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=mchehab@kernel.org \
--cc=rodrigo.gobbi.7@gmail.com \
--cc=sakari.ailus@linux.intel.com \
--cc=~lkcamp/patches@lists.sr.ht \
/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