All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Màxim Pedraza Padilla" <maximpedraza@gmail.com>
Cc: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org,
	robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v5 03/13] drm: client: add splash client
Date: Tue, 13 Oct 2026 09:43:13 +0000	[thread overview]
Message-ID: <sashiko-outbox-169372@kernel.org> (raw)
In-Reply-To: <20261013093243.505776-4-maximpedraza@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] drm: out-of-bounds read and unaligned access in BMP blitting
- [High] drm: integer overflow in BGRT padding validation allows OOB write
--

commit 099d44ed94a2ad19b8702756f34790d1e8ae5693
Author: Francesco Valla <francesco@valla.it>

drm: client: add splash client

This commit adds a new DRM client to draw a simple splash screen during boot.
It supports displaying an EFI BGRT logo, a static BMP image loaded via
firmware, or a plain background color. The splash can be enabled via kernel
command line parameters.

> diff --git a/drivers/gpu/drm/clients/drm_splash.c b/drivers/gpu/drm/clients/drm_splash.c
> new file mode 100644
> --- /dev/null
> +++ b/drivers/gpu/drm/clients/drm_splash.c
[ ... ]
> +static void drm_splash_blit_pix16(struct iosys_map *map, unsigned int dpitch,
> +				  unsigned int x_pad, unsigned int y_pad,
> +				  const u8 *sbuf8, unsigned int spitch,
> +				  unsigned int width, unsigned int height,
> +				  bool invert_y, u32 format)
> +{
> +	unsigned int x, y, src_offset, dst_offset;
> +	u32 scolor, dcolor, wr_off;
> +
> +	for (y = 0; y < height; y++) {
> +		src_offset = (invert_y ? (height - y - 1) : y) * spitch;
> +		dst_offset = (y_pad + y) * dpitch;
> +
> +		for (x = 0; x < width; x++) {
> +			scolor = *(const u32 *)(&sbuf8[src_offset + 3 * x]);

[Severity: High]
Could this 32-bit cast cause memory safety and endianness issues?

The code casts a byte pointer to a 32-bit integer pointer to read a 3-byte
(24bpp) pixel. This introduces a few potential problems.

First, it performs unaligned memory accesses, which can trigger fatal
alignment exceptions on architectures that do not support hardware unaligned
loads, such as SPARC or some older ARM platforms.

Second, for the last pixel in an image row where there are no padding bytes,
the 4-byte read extends 1 byte beyond the end of the row. On the final row of
the image, this reads 1 byte past the end of the mapped memory buffer. This
could trigger a KASAN out-of-bounds read or a fatal page fault if the read
crosses an unmapped page boundary.

Finally, on big-endian architectures, reading the 3 bytes plus an arbitrary
4th byte directly into a u32 will scramble the internal BGR color channels,
resulting in corrupted colors.

Does this same cast pattern need to be addressed in drm_splash_blit_pix24()
and drm_splash_blit_pix32() below as well?

> +			dcolor = drm_draw_color_from_xrgb8888(scolor, format);
> +			wr_off = dst_offset + (x_pad + x) * sizeof(u16);
> +
> +			iosys_map_wr(map, wr_off, u16, dcolor);
> +		}
> +	}
> +}
[ ... ]
> +	if (splash->use_bgrt) {
> +		x_pad = efi_bgrt_image_offset_x();
> +		y_pad = efi_bgrt_image_offset_y();
> +
> +		if ((x_pad + bmp_width) > scanout->width ||
> +		    (y_pad + bmp_height) > scanout->height) {

[Severity: High]
Is this bounds check vulnerable to an integer overflow?

The x_pad and y_pad values are sourced directly from the ACPI BGRT table
via efi_bgrt_image_offset_x() and efi_bgrt_image_offset_y(), which return
32-bit unsigned integers. Because x_pad and scanout->width are unsigned int,
and bmp_width is a positive s32, the addition is evaluated as an unsigned
integer.

If an attacker provides an extremely large value for x_pad, such as
0xFFFFFFFF, in a compromised ACPI table, x_pad + bmp_width will wrap around
to a small number. This would bypass the greater-than scanout->width check.

Later during blitting, these wrapped offsets are used to calculate the write
offset. For example, calculating wr_off = dst_offset + (x_pad + x) * 3
would result in a massive out-of-bounds write and potential kernel memory
corruption.

Would it be safer to check these bounds using an overflow-safe method, or
perhaps by checking if x_pad > scanout->width - bmp_width?

> +			drm_err(client->dev, "splash: BGRT image would overflow");
> +			return -EINVAL;
> +		}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261013093243.505776-1-maximpedraza@gmail.com?part=3

  reply	other threads:[~2026-10-13  9:43 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-13  9:32 [PATCH v5 00/13] Add splash DRM client Màxim Pedraza Padilla
2026-10-13  9:32 ` [PATCH v5 01/13] drm/clients: Kconfig: indent DRM_CLIENT_DEFAULT with tabs Màxim Pedraza Padilla
2026-10-13  9:32 ` [PATCH v5 02/13] efi: bgrt: add accessors for the boot graphics Màxim Pedraza Padilla
2026-10-13  9:32 ` [PATCH v5 03/13] drm: client: add splash client Màxim Pedraza Padilla
2026-10-13  9:43   ` sashiko-bot [this message]
2026-10-13  9:32 ` [PATCH v5 04/13] MAINTAINERS: add entry for DRM " Màxim Pedraza Padilla
2026-10-13  9:32 ` [PATCH v5 05/13] drm: docs: remove bootsplash from TODO Màxim Pedraza Padilla
2026-10-13  9:32 ` [PATCH v5 06/13] dt-bindings: display: add a boot logo node under /chosen Màxim Pedraza Padilla
2026-10-13  9:32 ` [PATCH v5 07/13] drm/client: splash: add a device tree image source Màxim Pedraza Padilla
2026-10-13  9:51   ` sashiko-bot
2026-10-13  9:32 ` [PATCH v5 08/13] drm/client: splash: place the device tree image where it asks Màxim Pedraza Padilla
2026-10-13  9:32 ` [PATCH v5 09/13] drm/client: splash: turn the device tree image as " Màxim Pedraza Padilla
2026-10-13  9:32 ` [PATCH v5 10/13] drm/client: splash: take the background colour from the image source Màxim Pedraza Padilla
2026-10-13  9:32 ` [PATCH v5 11/13] drm/client: splash: turn the BGRT image on panels mounted turned Màxim Pedraza Padilla
2026-10-13  9:32 ` [PATCH v5 12/13] drm/client: splash: prefer what the command line asks for Màxim Pedraza Padilla
2026-10-13  9:32 ` [PATCH v5 13/13] drm/client: splash: document the image sources and parameters Màxim Pedraza Padilla

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-169372@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=maximpedraza@gmail.com \
    --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.