dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Devarsh Thakkar" <devarsht@ti.com>
Cc: conor+dt@kernel.org, robh@kernel.org,
	dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v2 06/14] drm/solomon: ssd16xx: Add support for Solomon SSD1677 controller
Date: Sun, 27 Sep 2026 18:40:50 +0000	[thread overview]
Message-ID: <20260927184050.A83521F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260927182329.4193961-7-devarsht@ti.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] drm/solomon: heap buffer overflow during 1bpp framebuffer conversion
- [High] drm/solomon: illegal DMA mapping of .rodata via SPI tx_buf
--

commit 097c6bbe33ac16a0e3a2bddb2a05e16d23d7914c
Author: Devarsh Thakkar <devarsht@ti.com>

drm/solomon: ssd16xx: Add support for Solomon SSD1677 controller

Add infrastructure to support the Solomon SSD1677 e-paper controller
(up to 960x680 pixels, 10-bit pixel-level X/Y RAM addressing).

> diff --git a/drivers/gpu/drm/solomon/ssd16xx.c b/drivers/gpu/drm/solomon/ssd16xx.c
> index c478309d08e9f..93fa064cf5894 100644
> --- a/drivers/gpu/drm/solomon/ssd16xx.c
> +++ b/drivers/gpu/drm/solomon/ssd16xx.c
[ ... ]
> @@ -420,6 +426,29 @@ static const struct ssd16xx_controller_config ssd16xx_controller_configs[] = {
>  		},
>  		.ctrl2_load_temp_lut     = SSD1683_CTRL2_LOAD_TEMP_LUT,
>  	},
> +	[SSD1677] = {
> +		/*
> +		 * 10-bit pixel-level X/Y addressing; only deep sleep mode
> +		 * 0x03 is supported (no RAM-retain mode). Border waveform
> +		 * encoding matches SSD1683.
> +		 */
> +		.max_width  = 960,
> +		.max_height = 680,
> +		.ram_x_address_bits = 10,

[Severity: High]
Does this configuration allow panels with widths that are not a multiple of 8,
leading to a heap buffer overflow during framebuffer conversion?

Because ram_x_address_bits is 10, it bypasses the multiple-of-8 width check in
ssd16xx_probe():

	if (device->controller_cfg->ram_x_address_bits == 8 &&
	    device->width % 8 != 0) {
		drm_err(drm, "panel width %u not a multiple of 8 required for byte-addressed X controller)\n",
			device->width);
		return -EINVAL;
	}

This permits device->width to not be a multiple of 8. However,
ssd16xx_alloc_tx_bufs() calculates the buffer size using global packing:

	size_t frame_size = DIV_ROUND_UP(device->width * device->height, 8);
	device->tx_buf = drmm_kmalloc(&device->drm, frame_size, GFP_KERNEL);

But ssd16xx_convert_fb_to_1bpp() pads each row to a byte boundary:

	for (y = rect->y1; y < rect->y2; y++) {
		...
		if (++bit_pos == 8) {
			dst[dst_idx++] = byte;
			byte = 0;
			bit_pos = 0;
		}
		...
		if (bit_pos > 0) {
			dst[dst_idx++] = byte;
			byte = 0;
			bit_pos = 0;
		}
	}

This padding means it writes DIV_ROUND_UP(width, 8) * height bytes in total,
which exceeds the allocated frame_size, causing memory corruption past the end
of device->tx_buf.

[ ... ]
> @@ -691,21 +736,34 @@ static int ssd16xx_hw_init(struct ssd16xx_device *device)
>  
>  	ssd16xx_hw_reset(device);
>  
> -	/* Software reset */
> +	/* Software reset (0x12): resets command/parameter registers to defaults. */
>  	ssd16xx_send_cmd(device, SSD16XX_CMD_SW_RESET, &err);
>  	ssd16xx_wait_for_device(device, &err);
>  
>  	/* Internal temperature sensor (SSD1683/SSD1680 only; not present in SSD1673) */
>  	if (device->controller_cfg->has_temp_sensor_ctrl) {
>  		ssd16xx_send_cmd(device, SSD1683_CMD_TEMPERATURE_SENSOR_CONTROL, &err);
>  		ssd16xx_send_data(device, SSD1683_TEMP_SENSOR_INTERNAL, &err);
>  	}
>  
> +	/*
> +	 * Booster soft-start (0x0C): panel-specific charge pump tuning.
> +	 * Some panels (e.g. PIXPAPER 4.26m on SSD1677) require this step;
> +	 * others (e.g. GDEY042T81 on SSD1683) omit it.
> +	 */
> +	if (device->device_cfg->booster_soft_start_data) {
> +		ssd16xx_send_cmd(device, SSD16XX_CMD_BOOSTER_SOFT_START, &err);
> +		ssd16xx_send_data_bulk(device,
> +				       device->device_cfg->booster_soft_start_data,
> +				       device->device_cfg->booster_soft_start_len,
> +				       &err);

[Severity: High]
Does this pass a .rodata pointer directly to the SPI core, causing an illegal
DMA mapping?

The booster_soft_start_data pointer comes from the device configuration, which
points to static const tuning data. When this is passed to
ssd16xx_send_data_bulk() under 4-wire SPI mode:

	if (device->dc) {
		/* 4-wire SPI: D/C# GPIO high selects data mode */
		xfer.tx_buf = data;
		xfer.len = len;
		gpiod_set_value_cansleep(device->dc, 1);
		ssd16xx_spi_sync(device->spi, &msg, err);

The SPI core will attempt to DMA map the xfer.tx_buf. Mapping .rodata for DMA
is prohibited and can cause kernel panics or mapping failures.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260927182329.4193961-1-devarsht@ti.com?part=6

  reply	other threads:[~2026-09-27 18:40 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-27 18:23 [PATCH v2 00/14] Add DRM driver for Solomon SSD16xx e-paper display controllers Devarsh Thakkar
2026-09-27 18:23 ` [PATCH v2 01/14] dt-bindings: vendor-prefixes: Add Dalian Good Display Co., Ltd Devarsh Thakkar
2026-09-27 18:23 ` [PATCH v2 02/14] dt-bindings: display: Add Solomon SSD16xx e-paper controller binding Devarsh Thakkar
2026-09-27 18:37   ` sashiko-bot
2026-10-01  6:28   ` Krzysztof Kozlowski
2026-10-05 16:36     ` Devarsh Thakkar
2026-09-27 18:23 ` [PATCH v2 03/14] dt-bindings: display: solomon, ssd16xx: Add Solomon SSD1677 controller Devarsh Thakkar
2026-09-27 18:35   ` [PATCH v2 03/14] dt-bindings: display: solomon,ssd16xx: " sashiko-bot
2026-10-01  6:26   ` Krzysztof Kozlowski
2026-09-27 18:23 ` [PATCH v2 04/14] drm/solomon: Add DRM driver for Solomon SSD16xx e-paper display controllers Devarsh Thakkar
2026-09-27 18:42   ` sashiko-bot
2026-09-28  7:00   ` Thomas Zimmermann
2026-09-29 16:43     ` Devarsh Thakkar
2026-09-27 18:23 ` [PATCH v2 05/14] drm/solomon: ssd16xx: Add clear_on_init/close/disable session management Devarsh Thakkar
2026-09-27 18:38   ` sashiko-bot
2026-09-27 18:23 ` [PATCH v2 06/14] drm/solomon: ssd16xx: Add support for Solomon SSD1677 controller Devarsh Thakkar
2026-09-27 18:40   ` sashiko-bot [this message]
2026-09-27 18:23 ` [PATCH v2 07/14] drm/solomon: ssd16xx: Add power management support Devarsh Thakkar
2026-09-27 18:41   ` sashiko-bot
2026-09-27 18:23 ` [PATCH v2 08/14] drm/solomon: ssd16xx: Expose refresh mode as plane property Devarsh Thakkar
2026-09-27 18:43   ` sashiko-bot
2026-09-27 18:23 ` [PATCH v2 09/14] drm/solomon: ssd16xx: Expose color " Devarsh Thakkar
2026-09-27 18:43   ` sashiko-bot
2026-09-27 18:23 ` [PATCH v2 10/14] drm/solomon: ssd16xx: Expose session management as plane properties Devarsh Thakkar
2026-09-27 18:38   ` sashiko-bot
2026-09-27 18:23 ` [PATCH v2 11/14] drm/solomon: ssd16xx: support panels whose RAM X order is reversed Devarsh Thakkar
2026-09-27 18:23 ` [PATCH v2 12/14] MAINTAINERS: Add entry for Solomon SSD16xx DRM driver Devarsh Thakkar
2026-09-27 18:23 ` [PATCH v2 13/14] arm64: defconfig: Enable DRM_SSD16XX for AM62L3 EVM Devarsh Thakkar
2026-09-27 18:23 ` [DO_NOT_MERGE PATCH v2 14/14] arm64: dts: ti: Add AM62L3 EVM overlay for GDEY042T81 e-paper display Devarsh Thakkar
2026-09-27 18:40   ` sashiko-bot
2026-10-02  8:56 ` [PATCH v2 00/14] Add DRM driver for Solomon SSD16xx e-paper display controllers LiangCheng Wang

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=20260927184050.A83521F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devarsht@ti.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox