All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Anthony McGivern" <anthony.mcgivern@arm.com>,
	devicetree@vger.kernel.org
Cc: robh@kernel.org, conor+dt@kernel.org, media-ci@linuxtv.org
Subject: Re: [PATCH 22/24] media: mali-c720: Add parameters video node
Date: Tue, 24 Nov 2026 17:45:55 +0000	[thread overview]
Message-ID: <sashiko-outbox-231739@kernel.org> (raw)
In-Reply-To: <20261124-b4-initial-upstream-candidate-v1-22-0cb9bde1bd30@arm.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] media: mali-c720: fortify_panic() in
  mali_c720_params_buf_prepare()
--

commit e3100256e90cde8dbdd6f531f1884f00ae417d6f
Author: Anthony McGivern <Anthony.McGivern@arm.com>

media: mali-c720: Add parameters video node

This commit adds a metadata output video node that validates and copies
queued userspace ISP parameter blocks into the context register image for
CDMA loading.

> diff --git a/drivers/media/platform/arm/mali-c720/mali-c720-params.c b/drivers/media/platform/arm/mali-c720/mali-c720-params.c
> new file mode 100644
> index 0000000000000..e6e0ca070f0ea
> --- /dev/null
> +++ b/drivers/media/platform/arm/mali-c720/mali-c720-params.c

[ ... ]

> +static int mali_c720_params_buf_prepare(struct vb2_buffer *vb)
> +{
> +	struct mali_c720_params *params = vb2_get_drv_priv(vb->vb2_queue);
> +	struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
> +	struct mali_c720_params_buf *buf = to_mali_c720_params_buf(vbuf);
> +	struct mali_c720 *mali_c720 = params->mali_c720;
> +	struct v4l2_isp_params_buffer *config = vb2_plane_vaddr(vb, 0);
> +	struct dma_buf *dbuf = vb->planes[0].dbuf;
> +	size_t block_offset = 0;
> +	int ret;
> +
> +	ret = v4l2_isp_params_validate_buffer_size(mali_c720->dev,
> +						   vb,
> +						   v4l2_isp_buffer_size
> +						   (MALI_C720_PARAMS_MAX_SIZE));
> +	if (ret)
> +		return ret;
> +
> +	if (dbuf) {
> +		ret = dma_buf_begin_cpu_access(dbuf, DMA_FROM_DEVICE);
> +		if (ret)
> +			return ret;
> +	}
> +
> +	/*
> +	 * Copy the parameters buffer provided by userspace to the internal
> +	 * scratch buffer. This protects against the chance of userspace making
> +	 * changes to the buffer content whilst the driver processes it.
> +	 */
> +	memcpy(buf->config, config,
> +	       v4l2_isp_buffer_size(MALI_C720_PARAMS_MAX_SIZE));

[Severity: High]
Can this memcpy() trigger a fortify_panic() when CONFIG_FORTIFY_SOURCE and
CONFIG_CC_HAS_COUNTED_BY are enabled?

Both buf->config and config are typed as struct v4l2_isp_params_buffer *
(an alias of struct v4l2_isp_buffer), which declares its flexible array as:

include/uapi/linux/media/v4l2-isp.h:
	struct v4l2_isp_buffer {
		__u32 version;
		__u32 data_size;
		__u8 data[] __counted_by(data_size);
	};

Fortified memcpy() evaluates __builtin_dynamic_object_size() on both
pointers using offsetof(struct v4l2_isp_buffer, data) + ptr->data_size.
At this point buf->config->data_size has not been populated yet (holding 0
or a prior frame's size), and config->data_size is smaller than
MALI_C720_PARAMS_MAX_SIZE whenever userspace queues a subset of parameter
blocks, so the bounds check against
v4l2_isp_buffer_size(MALI_C720_PARAMS_MAX_SIZE) fails and panics the
kernel.

Typing config as void * (or copying through a void * destination before
populating data_size, as v4l2_isp_params_validate_buffer() does) avoids
evaluating the __counted_by(data_size) bound during the copy.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261124-b4-initial-upstream-candidate-v1-0-0cb9bde1bd30@arm.com?part=22

  reply	other threads:[~2026-11-24 17:45 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 17:07 [PATCH 00/24] Add Arm Mali-C720 Image Signal Processor Driver Anthony McGivern
2026-11-24 17:07 ` [PATCH 01/24] media: uapi: Add 24-bit Bayer media bus formats Anthony McGivern
2026-11-24 17:07 ` [PATCH 02/24] dt-bindings: media: Add bindings for Arm Mali-C720 Anthony McGivern
2026-11-24 17:18   ` sashiko-bot
2026-11-25  8:51   ` Krzysztof Kozlowski
2026-11-26 14:55     ` Anthony McGivern
2026-11-26 15:12       ` Krzysztof Kozlowski
2026-11-27 12:32         ` Anthony McGivern
2026-11-27 12:49           ` Laurent Pinchart
2026-11-27 14:25             ` Anthony McGivern
2026-11-24 17:07 ` [PATCH 03/24] media: uapi: Add a control ID base for Mali-C720 ISP Anthony McGivern
2026-11-24 17:07 ` [PATCH 04/24] media: mali-c720: Add register access helpers Anthony McGivern
2026-11-24 17:07 ` [PATCH 05/24] media: mali-c720: Add hardware identification Anthony McGivern
2026-11-25  8:52   ` Krzysztof Kozlowski
2026-11-26 15:00     ` Anthony McGivern
2026-11-24 17:07 ` [PATCH 06/24] media: mali-c720: Add format handling Anthony McGivern
2026-11-24 17:07 ` [PATCH 07/24] media: mali-c720: Add hardware discovery support Anthony McGivern
2026-11-24 17:07 ` [PATCH 08/24] media: mali-c720: Add context manager and interrupt handling Anthony McGivern
2026-11-24 17:07 ` [PATCH 09/24] media: mali-c720: Add input frontend subdevice Anthony McGivern
2026-11-24 17:07 ` [PATCH 10/24] media: mali-c720: Add ISP and human vision subdevices Anthony McGivern
2026-11-24 17:07 ` [PATCH 11/24] media: mali-c720: Add full-resolution output subdevice Anthony McGivern
2026-11-24 17:21   ` sashiko-bot
2026-11-24 17:07 ` [PATCH 12/24] media: mali-c720: Add video capture nodes Anthony McGivern
2026-11-24 17:35   ` sashiko-bot
2026-11-24 17:07 ` [PATCH 13/24] media: mali-c720: Add Mali-C720 ISP driver Anthony McGivern
2026-11-25  8:55   ` Krzysztof Kozlowski
2026-11-26 15:53     ` Anthony McGivern
2026-12-01 18:40       ` Linus Walleij
2026-12-01 22:10         ` Laurent Pinchart
2026-12-01 22:20           ` Linus Walleij
2026-11-24 17:07 ` [PATCH 14/24] media: mali-c720: Add test pattern generator subdevices Anthony McGivern
2026-11-24 17:07 ` [PATCH 15/24] media: Documentation: Add Mali-C720 ISP documentation Anthony McGivern
2026-11-24 17:20   ` sashiko-bot
2026-11-28  0:43   ` kernel test robot
2026-11-24 17:07 ` [PATCH 16/24] media: uapi: Add Mali-C720 statistics meta format Anthony McGivern
2026-11-24 17:07 ` [PATCH 17/24] media: uapi: Add statistics structs to mali-c720-config.h Anthony McGivern
2026-11-24 17:26   ` sashiko-bot
2026-11-24 17:07 ` [PATCH 18/24] media: mali-c720: Add 3A statistics video node Anthony McGivern
2026-11-24 17:31   ` sashiko-bot
2026-11-24 17:07 ` [PATCH 19/24] media: Documentation: Document Mali-C720 statistics capture Anthony McGivern
2026-11-24 17:25   ` sashiko-bot
2026-11-24 17:07 ` [PATCH 20/24] media: uapi: Add Mali-C720 parameters meta format Anthony McGivern
2026-11-24 17:07 ` [PATCH 21/24] media: uapi: Add parameter structs to mali-c720-config.h Anthony McGivern
2026-11-24 17:33   ` sashiko-bot
2026-11-24 17:07 ` [PATCH 22/24] media: mali-c720: Add parameters video node Anthony McGivern
2026-11-24 17:45   ` sashiko-bot [this message]
2026-11-24 17:07 ` [PATCH 23/24] media: Documentation: Document Mali-C720 parameter settings Anthony McGivern
2026-11-24 17:07 ` [PATCH 24/24] MAINTAINERS: Add entry for mali-c720 driver Anthony McGivern

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=sashiko-outbox-231739@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=anthony.mcgivern@arm.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=media-ci@linuxtv.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.