mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/4] drm/log: Fix out-of-bounds read on empty message length
@ 2026-07-29  8:45 oushixiong1025
  2026-07-29  8:45 ` [PATCH 2/4] drm/log: Fix division by zero when scale module parameter is 0 oushixiong1025
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: oushixiong1025 @ 2026-07-29  8:45 UTC (permalink / raw)
  To: Jocelyn Falempe
  Cc: Javier Martinez Canillas, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, dri-devel,
	linux-kernel, Shixiong Ou

From: Shixiong Ou <oushixiong@kylinos.cn>

drm_log_draw_kmsg_record() accesses s[len - 1] to strip the trailing
newline, but len is unsigned int. If len is 0, the subtraction wraps
to UINT_MAX, causing an out-of-bounds read.

Add an early return when len is 0.

Signed-off-by: Shixiong Ou <oushixiong@kylinos.cn>
---
 drivers/gpu/drm/clients/drm_log.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/clients/drm_log.c b/drivers/gpu/drm/clients/drm_log.c
index e3e02c84a4cf..294b3be1a6b3 100644
--- a/drivers/gpu/drm/clients/drm_log.c
+++ b/drivers/gpu/drm/clients/drm_log.c
@@ -162,6 +162,9 @@ static void drm_log_draw_kmsg_record(struct drm_log_scanout *scanout,
 {
 	u32 prefix_len = 0;
 
+	if (!len)
+		return;
+
 	if (len > TS_PREFIX_LEN && s[0] == '[' && s[6] == '.' && s[TS_PREFIX_LEN] == ']')
 		prefix_len = TS_PREFIX_LEN + 1;
 
-- 
2.25.1


No virus found
		Checked by Hillstone Network AntiVirus


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-08-13 14:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-29  8:45 [PATCH 1/4] drm/log: Fix out-of-bounds read on empty message length oushixiong1025
2026-07-29  8:45 ` [PATCH 2/4] drm/log: Fix division by zero when scale module parameter is 0 oushixiong1025
2026-07-29  9:48   ` Jani Nikula
2026-07-29 15:16 ` [PATCH 1/4] drm/log: Fix out-of-bounds read on empty message length Jocelyn Falempe
2026-08-13 14:06 ` Jocelyn Falempe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®