All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Maxime Ripard" <mripard@kernel.org>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 23/70] drm/sitronix: st7571: Switch to drm_atomic_helper_crtc_create_state
Date: Fri, 21 Aug 2026 15:14:30 +0000	[thread overview]
Message-ID: <20260821151430.E48E51F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260821-drm-no-more-crtc-reset-v1-23-fb793475c05a@kernel.org>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Pre-existing issues:
- [High] Unconditional 8-line page iterations in `st7571_transform_xy` cause an out-of-bounds read when `nlines` is not a multiple of 8.
- [High] Mismatch between framebuffer pitch during conversion and reading causes display corruption and invalid reads from `hwbuf`.
--

--- Patch [23]: [PATCH 23/70] drm/sitronix: st7571: Switch to drm_atomic_helper_crtc_create_state ---
commit cf528fe94124a1e49e93edb3680754d3976e2864
Author: Maxime Ripard <mripard@kernel.org>

drm/sitronix: st7571: Switch to drm_atomic_helper_crtc_create_state
    
The st7571 crtc implementation uses the deprecated
drm_atomic_helper_crtc_reset() as its reset hook. Switch to
drm_atomic_helper_crtc_create_state() instead.

> diff --git a/drivers/gpu/drm/sitronix/st7571.c b/drivers/gpu/drm/sitronix/st7571.c
> index 20954c33eca93..fc3ba5e8600f6 100644
> --- a/drivers/gpu/drm/sitronix/st7571.c
> +++ b/drivers/gpu/drm/sitronix/st7571.c
> @@ -424,7 +424,7 @@ static const struct drm_crtc_helper_funcs st7571_crtc_helper_funcs = {
>  };
>  
>  static const struct drm_crtc_funcs st7571_crtc_funcs = {
> -	.reset = drm_atomic_helper_crtc_reset,
> +	.atomic_create_state = drm_atomic_helper_crtc_create_state,
>  	.destroy = drm_crtc_cleanup,
>  	.set_config = drm_atomic_helper_set_config,
>  	.page_flip = drm_atomic_helper_page_flip,

[Severity: High]
This isn't a bug introduced by this patch, but does this code cause an
out-of-bounds read when nlines is not a multiple of 8?

In drivers/gpu/drm/sitronix/st7571.c:st7571_probe():
	st7571->hwbuf = devm_kzalloc(st7571->dev,
				     (st7571->nlines * st7571->ncols * st7571->bpp) / 8,
				     GFP_KERNEL);

If nlines is not a multiple of 8, hwbuf is allocated strictly based on the
unaligned nlines value.

During a display update:

drivers/gpu/drm/sitronix/st7571.c:st7571_fb_update_rect_monochrome():
	for (int y = rect->y1; y < rect->y2; y += ST7571_PAGE_HEIGHT) {

drivers/gpu/drm/sitronix/st7571.c:st7571_transform_xy():
	for (int i = 0; i < 8; i++) {
		int row_idx = y + i;
		u8 byte = p[row_idx * row_len + x];

This iterates 8 times vertically, which could read beyond the allocated buffer
if nlines is smaller than the assumed 8-line page height.


[Severity: High]
This is a pre-existing issue, but does a mismatch between the framebuffer
pitch during conversion and reading cause invalid reads from hwbuf?

In drivers/gpu/drm/sitronix/st7571.c:st7571_prepare_buffer_monochrome():
	dst_pitch = DIV_ROUND_UP(drm_rect_width(rect), 8);
	iosys_map_set_vaddr(&dst, st7571->hwbuf);
	drm_fb_xrgb8888_to_mono(&dst, &dst_pitch, vmap, fb, rect, fmtcnv_state);

The converted partial damage is tightly packed at offset 0 of hwbuf with a
dynamic pitch.

However, when reading the data:

drivers/gpu/drm/sitronix/st7571.c:st7571_fb_update_rect_monochrome():
	row[x] = st7571_transform_xy(st7571->hwbuf, x, y, 1);

drivers/gpu/drm/sitronix/st7571.c:st7571_transform_xy():
	u8 row_len = 16 * bpp;
	...
	int row_idx = y + i;
	u8 byte = p[row_idx * row_len + x];

st7571_transform_xy() accesses hwbuf using absolute coordinates and assumes a
full-screen layout with a fixed pitch, which seems to completely miss the
packed damage data.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260821-drm-no-more-crtc-reset-v1-0-fb793475c05a@kernel.org?part=23

  reply	other threads:[~2026-08-21 15:14 UTC|newest]

Thread overview: 96+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-21 14:38 [PATCH 00/70] drm/crtc: Convert all drivers to atomic_create_state and remove reset Maxime Ripard
2026-08-21 14:38 ` Maxime Ripard
2026-08-21 14:38 ` [PATCH 01/70] drm/adp: Switch to drm_atomic_helper_crtc_create_state Maxime Ripard
2026-08-21 14:55   ` sashiko-bot
2026-08-21 14:38 ` [PATCH 02/70] drm/amdgpu: vkms: " Maxime Ripard
2026-08-21 14:38 ` [PATCH 03/70] drm/arm: hdlcd: " Maxime Ripard
2026-08-21 14:38 ` [PATCH 04/70] drm/armada: " Maxime Ripard
2026-08-21 14:38 ` [PATCH 05/70] drm/exynos: " Maxime Ripard
2026-08-21 14:38 ` [PATCH 06/70] drm/fsl-dcu: " Maxime Ripard
2026-08-21 14:38 ` [PATCH 07/70] drm/gud: " Maxime Ripard
2026-08-21 14:38 ` [PATCH 08/70] drm/hisilicon: hibmc: " Maxime Ripard
2026-08-21 14:38 ` [PATCH 09/70] drm/hisilicon: kirin: " Maxime Ripard
2026-08-21 20:06   ` John Stultz
2026-08-21 14:38 ` [PATCH 10/70] drm/hyperv: " Maxime Ripard
2026-08-21 14:38 ` [PATCH 11/70] drm/imx: dc: " Maxime Ripard
2026-08-21 15:00   ` sashiko-bot
2026-08-21 14:38 ` [PATCH 12/70] drm/imx: dcss: " Maxime Ripard
2026-08-21 14:38 ` [PATCH 13/70] drm/ingenic: " Maxime Ripard
2026-08-21 14:38 ` [PATCH 14/70] drm/kmb: " Maxime Ripard
2026-08-21 14:38 ` [PATCH 15/70] drm/logicvc: " Maxime Ripard
2026-08-21 14:38 ` [PATCH 16/70] drm/meson: " Maxime Ripard
2026-08-21 14:38   ` Maxime Ripard
2026-08-21 14:38 ` [PATCH 17/70] drm/msm: mdp4: " Maxime Ripard
2026-08-22  7:51   ` Dmitry Baryshkov
2026-08-21 14:38 ` [PATCH 18/70] drm/mxs: mxsfb: " Maxime Ripard
2026-08-21 15:12   ` sashiko-bot
2026-08-21 14:38 ` [PATCH 19/70] drm/qxl: " Maxime Ripard
2026-08-21 14:38 ` [PATCH 20/70] drm/renesas: shmobile: " Maxime Ripard
2026-08-21 14:38 ` [PATCH 21/70] drm/simple-kms: Remove unused reset_crtc hook Maxime Ripard
2026-08-21 14:38 ` [PATCH 22/70] drm/simple-kms: Switch to drm_atomic_helper_crtc_create_state Maxime Ripard
2026-08-21 14:38 ` [PATCH 23/70] drm/sitronix: st7571: " Maxime Ripard
2026-08-21 15:14   ` sashiko-bot [this message]
2026-08-21 14:39 ` [PATCH 24/70] drm/sprd: " Maxime Ripard
2026-08-21 14:39 ` [PATCH 25/70] drm/sti: " Maxime Ripard
2026-08-21 14:39 ` [PATCH 26/70] drm/stm: " Maxime Ripard
2026-08-21 14:39 ` [PATCH 27/70] drm/sun4i: " Maxime Ripard
2026-08-21 14:39 ` [PATCH 28/70] drm/tests: " Maxime Ripard
2026-08-21 14:39 ` [PATCH 29/70] drm/tilcdc: Move hardware reset to CRTC creation Maxime Ripard
2026-08-21 15:13   ` sashiko-bot
2026-08-21 14:39 ` [PATCH 30/70] drm/tilcdc: Switch to drm_atomic_helper_crtc_create_state Maxime Ripard
2026-08-21 14:39 ` [PATCH 31/70] drm/tiny: appletbdrm: " Maxime Ripard
2026-08-21 15:16   ` sashiko-bot
2026-08-21 14:39 ` [PATCH 32/70] drm/tiny: bochs: " Maxime Ripard
2026-08-21 14:39 ` [PATCH 33/70] drm/tiny: cirrus: " Maxime Ripard
2026-08-21 14:39 ` [PATCH 34/70] drm/tiny: pixpaper: " Maxime Ripard
2026-08-21 15:26   ` sashiko-bot
2026-08-21 14:39 ` [PATCH 35/70] drm/tiny: sharp: " Maxime Ripard
2026-08-21 15:25   ` sashiko-bot
2026-08-21 14:39 ` [PATCH 36/70] drm/udl: " Maxime Ripard
2026-08-21 14:39 ` [PATCH 37/70] drm/vbox: " Maxime Ripard
2026-08-21 14:39 ` [PATCH 38/70] drm/verisilicon: " Maxime Ripard
2026-08-21 14:39 ` [PATCH 39/70] drm/virtio: " Maxime Ripard
2026-08-21 14:39 ` [PATCH 40/70] drm/xlnx: " Maxime Ripard
2026-08-21 14:39 ` [PATCH 41/70] drm/mipi-dbi: " Maxime Ripard
2026-08-21 14:39 ` [PATCH 42/70] drm/atomic-helper: Remove drm_atomic_helper_crtc_reset Maxime Ripard
2026-08-21 14:39 ` [PATCH 43/70] sysfb: Convert to create_state Maxime Ripard
2026-08-21 14:39 ` [PATCH 44/70] drm/amdgpu: dm: Convert to atomic_create_state Maxime Ripard
2026-08-21 15:28   ` sashiko-bot
2026-08-21 14:39 ` [PATCH 45/70] drm/komeda: " Maxime Ripard
2026-08-21 14:39 ` [PATCH 46/70] drm/malidp: " Maxime Ripard
2026-08-21 14:39 ` [PATCH 47/70] drm/ast: " Maxime Ripard
2026-08-21 14:39 ` [PATCH 48/70] drm/atmel-hlcdc: " Maxime Ripard
2026-08-21 14:39 ` [PATCH 49/70] drm/imx: ipuv3: " Maxime Ripard
2026-08-21 14:39 ` [PATCH 50/70] drm/loongsoon: Move hardware reset to CRTC creation Maxime Ripard
2026-08-21 15:36   ` sashiko-bot
2026-08-21 14:39 ` [PATCH 51/70] drm/loongson: Convert to atomic_create_state Maxime Ripard
2026-08-21 15:35   ` sashiko-bot
2026-08-21 14:39 ` [PATCH 52/70] drm/mediatek: " Maxime Ripard
2026-08-21 14:39 ` [PATCH 53/70] drm/mgag200: " Maxime Ripard
2026-08-21 14:39 ` [PATCH 54/70] drm/msm: dpu1: " Maxime Ripard
2026-08-22  8:14   ` Dmitry Baryshkov
2026-08-21 14:39 ` [PATCH 55/70] drm/msm: mdp5: " Maxime Ripard
2026-08-22  8:47   ` Dmitry Baryshkov
2026-08-21 14:39 ` [PATCH 56/70] drm/mxsfb: lcdif: " Maxime Ripard
2026-08-21 14:39 ` [PATCH 57/70] drm/nouveau: " Maxime Ripard
2026-08-21 14:39   ` Maxime Ripard
2026-08-21 20:51   ` lyude
2026-08-21 14:39 ` [PATCH 58/70] drm/omapdrm: " Maxime Ripard
2026-08-21 14:39 ` [PATCH 59/70] drm/rcar-du: " Maxime Ripard
2026-08-21 14:39 ` [PATCH 60/70] drm/rzg2l-du: " Maxime Ripard
2026-08-21 14:39 ` [PATCH 61/70] drm/rockchip: vop: " Maxime Ripard
2026-08-21 14:39   ` Maxime Ripard
2026-08-21 14:39 ` [PATCH 62/70] drm/rockchip: vop2: " Maxime Ripard
2026-08-21 14:39   ` Maxime Ripard
2026-08-21 14:39 ` [PATCH 63/70] drm/sitronix: st7920: " Maxime Ripard
2026-08-21 15:41   ` sashiko-bot
2026-08-21 14:39 ` [PATCH 64/70] drm/solomon: ssd130x: " Maxime Ripard
2026-08-21 14:39 ` [PATCH 65/70] drm/tegra: " Maxime Ripard
2026-08-21 14:39 ` [PATCH 66/70] drm/vc4: " Maxime Ripard
2026-08-21 14:39 ` [PATCH 67/70] drm/vkms: " Maxime Ripard
2026-08-21 14:39 ` [PATCH 68/70] drm/vmwgfx: " Maxime Ripard
2026-08-21 14:39 ` [PATCH 69/70] drm/atomic-helper: Remove __drm_atomic_helper_crtc_reset Maxime Ripard
2026-08-21 15:45   ` sashiko-bot
2026-08-22  8:47   ` Dmitry Baryshkov
2026-08-21 14:39 ` [PATCH 70/70] drm/crtc: Remove reset Maxime Ripard
2026-08-21 15:51   ` sashiko-bot

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=20260821151430.E48E51F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=mripard@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.