From: soufianeda@tutanota.com
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Linux Media <linux-media@vger.kernel.org>,
Linux Staging <linux-staging@lists.linux.dev>,
Gregkh <gregkh@linuxfoundation.org>,
Johannes Goede <johannes.goede@oss.qualcomm.com>,
Andy <andy@kernel.org>,
Sakari Ailus <sakari.ailus@linux.intel.com>
Subject: Re: [PATCH] staging: atomisp: fix heap buffer overflow in framebuffer conversion
Date: Wed, 11 Feb 2026 14:37:53 +0100 (CET) [thread overview]
Message-ID: <OlBv1uI--R-9@tutanota.com> (raw)
In-Reply-To: <aYwVNjC7Zbhr_4vo@stanley.mountain>
Hi Dan,
The issue is that res->data_bytes and arg->fmt.sizeimage are computed
from independent sources with no validation linking them.
ia_css_frame_allocate() computes data_bytes internally based on
width, height, format, and padded_width through frame_init_planes():
frame_allocate_with_data()
-> frame_create(width, height, ...)
-> ia_css_frame_init_planes()
-> frame_init_single_plane() / frame_init_nv_planes() / ...
-> frame->data_bytes = stride * height (varies by format)
-> frame_allocate_buffer_data()
-> hmm_alloc(frame->data_bytes)
But arg->fmt.sizeimage is a separate user-controlled field in
struct v4l2_framebuffer. Nothing enforces that sizeimage matches
the data_bytes computed from width/height/format. A user can pass:
width=100, height=100 -> small data_bytes allocation
sizeimage=1048576 -> 1MB copy via hmm_store()
The hmm_store() then does memcpy() with the sizeimage length into
the data_bytes-sized buffer.
I found this by code review, then confirmed with a userspace harness
compiled with AFL++/ASAN that simulates the allocation and copy. The
ASAN output shows heap-buffer-overflow immediately with mismatched
values.
The ioctl path is:
ioctl(fd, ATOMISP_IOC_S_ISP_FPN_TABLE, &fb)
-> atomisp_fixed_pattern_table()
-> atomisp_v4l2_framebuffer_to_css_frame()
Regarding your suggestion about bounds checking in hmm_store() -
that would also work, but hmm_store() is a generic function used
elsewhere. Validating at the call site before we even vmalloc the
oversized tmp_buf seems cleaner and catches it earlier.
Regards,
Soufiane Dani
11 Feb 2026 at 06:35 by dan.carpenter@linaro.org:
> Please send this email to the list.
>
> This information is not secret and should be included in the
> commit message.
>
> regards,
> dan carpenter
>
>
prev parent reply other threads:[~2026-02-11 13:37 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260210-atomisp-fix-v1-1-024429cbff31@tutanota.com>
[not found] ` <aYt-vrc7h7CJOmSu@stanley.mountain>
2026-02-11 8:11 ` [PATCH] staging: atomisp: fix heap buffer overflow in framebuffer conversion Sakari Ailus
2026-02-11 8:59 ` Andy Shevchenko
2026-02-11 11:28 ` johannes.goede
2026-02-11 11:39 ` Andy Shevchenko
2026-02-11 11:50 ` johannes.goede
2026-02-11 11:54 ` Sakari Ailus
2026-02-11 12:31 ` johannes.goede
2026-02-11 13:27 ` Andy Shevchenko
2026-02-11 13:43 ` soufianeda
2026-02-27 23:58 ` Sakari Ailus
[not found] ` <Ol83sWa--F-9@tutanota.com>
[not found] ` <aYwVNjC7Zbhr_4vo@stanley.mountain>
2026-02-11 13:37 ` soufianeda [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=OlBv1uI--R-9@tutanota.com \
--to=soufianeda@tutanota.com \
--cc=andy@kernel.org \
--cc=dan.carpenter@linaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=johannes.goede@oss.qualcomm.com \
--cc=linux-media@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--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