From: Greg KH <gregkh@linuxfoundation.org>
To: Feng Ning <feng@innora.ai>
Cc: linux-media@vger.kernel.org, hansg@kernel.org,
mchehab@kernel.org, sakari.ailus@linux.intel.com
Subject: Re: [PATCH] staging: media: atomisp: use array3_size() for overflow-safe allocation
Date: Thu, 2 Apr 2026 06:01:50 +0200 [thread overview]
Message-ID: <2026040258-cold-umbilical-005c@gregkh> (raw)
In-Reply-To: <ac3R8_qf4qivmGc2@ans-MacBook-Pro.local>
On Thu, Apr 02, 2026 at 02:18:32AM +0000, Feng Ning wrote:
> Replace bare width * height * sizeof() multiplications with
> array3_size() to prevent integer overflow in buffer allocations.
>
> The atomisp driver computes DVS and shading buffer sizes using
> unchecked u32 multiplication. When dimensions are large, the
> product wraps and kvmalloc allocates an undersized buffer.
>
> Use array3_size() which returns SIZE_MAX on overflow, causing
> kvmalloc to fail safely instead of allocating too little memory.
>
> Affected locations (11 instances across 3 files):
> - sh_css_params.c: ia_css_dvs_6axis_config_allocate (lines 4482-4498)
> - sh_css_params.c: ia_css_morph_table_allocate (lines 1384-1387)
> - sh_css_params.c: ia_css_dvs_stat_allocate (lines 4209-4214)
> - sh_css_param_dvs.c: ia_css_dvs_6axis_config_allocate (lines 52-79)
> - sh_css_param_shading.c: ia_css_shading_table_alloc (line 342)
>
> Example fix for one location:
>
> - dvs_config->xcoords_y = kvmalloc(width_y * height_y * sizeof(uint32_t),
> + dvs_config->xcoords_y = kvmalloc(array3_size(width_y, height_y, sizeof(uint32_t)),
> GFP_KERNEL);
>
> The full patch covering all 11 locations is larger than suitable for
> email. I can send git format-patch output if preferred, or submit via
> a merge request on the kernel gitlab.
Email is how we accept patches. Please do so that way, this is not
going to be a "huge" change at all. Worst case, break it up and make it
a patch series.
thanks,
greg k-h
prev parent reply other threads:[~2026-04-02 4:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-02 2:18 [PATCH] staging: media: atomisp: use array3_size() for overflow-safe allocation Feng Ning
2026-04-02 4:01 ` Greg KH [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=2026040258-cold-umbilical-005c@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=feng@innora.ai \
--cc=hansg@kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=sakari.ailus@linux.intel.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