Skip to contentSkip to conversation

drm: use drm_warn() in validate_blend_mode_for_alpha_formats()

PATCH In review Leandro Ribeiro 6 participants 9 messages Jul 31 – Aug 27

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

v2 cover drm: use drm_warn() in validate_blend_mode_for_alpha_formats()

This replaces a WARN() with drm_warn() in
validate_blend_mode_for_alpha_formats().

The condition is expected to be triggered by existing drivers while they adapt to the new blend mode requirement, so it should not use the kernel warning report mechanism. WARN() output can cause fuzzers to stop when they encounter a "WARNING:" message.

drm_warn() keeps the warning visible to driver developers without triggering a WARN().

Changes in v2:
- Make the warning message more explicit
- Add a "Fixes" tag to commit

Leandro Ribeiro (1):
drm: use drm_warn() in validate_blend_mode_for_alpha_formats()

 drivers/gpu/drm/drm_mode_config.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Signature · 1 line
2.55.0
#1 lore raw

PATCH v2 1/1 drm: use drm_warn() in validate_blend_mode_for_alpha_formats()

Commit 860e748bddcc ("drm: ensure blend mode supported if pixel format with alpha exposed") introduced a WARN() to let driver developers know that a previously valid behavior should now be changed.

But WARN() should not be used for that, as it's a kernel warning report mechanism for conditions that are not expected to happen. It also produces a stack trace. Instead, a simple warning-level log message should have been used, as drivers were expected to trigger the condition.

This is causing problems for fuzzers, as they may stop when encountering a "BUG:" or "WARNING:" in the logs.

Replace WARN() with drm_warn() in this function, avoiding these issues.

Fixes 860e748bddcc ("drm: ensure blend mode supported if pixel format with alpha exposed")
---
 drivers/gpu/drm/drm_mode_config.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_mode_config.c +3 -2
index 3bcc7bf0900c..cff347c723ef 100644
@@ -869,8 +869,9 @@ static void validate_blend_mode_for_alpha_formats(struct drm_plane *plane)
 	for (i = 0; i < plane->format_count; i++) {
 		fmt = drm_format_info(plane->format_types[i]);
 		if (fmt->has_alpha) {
-			WARN(1, "[PLANE:%d:%s] pixel format with alpha exposed but blend mode not setup",
-			     plane->base.id, plane->name);
+			drm_warn(plane->dev,
+				 "[PLANE:%d:%s] pixel format with alpha exposed but blend mode not setup. Please fix.",
+				 plane->base.id, plane->name);
 			break;
 		}
 	}
Signature · 1 line
2.55.0
#2 lore raw
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

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

New issues:
- [Low] Missing trailing newline in drm_warn() format string.

Pre-existing issues:
- [High] Missing NULL check on the return value of drm_format_info() before dereferencing it. --

--- Patch [1]: [PATCH v2 1/1] drm: use drm_warn() in validate_blend_mode_for_alpha_formats() --- commit e7f907e9d21d7af4bbeb8c955471b68c362de2e1
Author: Leandro Ribeiro <[email protected]>

drm: use drm_warn() in validate_blend_mode_for_alpha_formats()

This commit replaces a WARN() with drm_warn() in validate_blend_mode_for_alpha_formats() to prevent fuzzers from stopping when drivers encounter a pixel format with alpha exposed but no blend mode setup.

drivers/gpu/drm/drm_mode_config.c static void validate_blend_mode_for_alpha_formats(struct drm_plane *plane) · line 871

Quoted 8 lines
drivers/gpu/drm/drm_mode_config.c +0 -0
index 3bcc7bf0900c4..cff347c723ef0 100644
@@ -869,8 +869,9 @@ static void validate_blend_mode_for_alpha_formats(struct drm_plane *plane)
 	for (i = 0; i < plane->format_count; i++) {
 		fmt = drm_format_info(plane->format_types[i]);
 		if (fmt->has_alpha) {

[Severity: High]
This isn't a bug introduced by this patch, but is it possible for drm_format_info() to return NULL here?

If a driver exposes an unknown or unsupported format in the format_types array, drm_format_info() returns NULL, and this line will trigger a NULL pointer dereference during plane validation.

drivers/gpu/drm/drm_mode_config.c static void validate_blend_mode_for_alpha_formats(struct drm_plane *plane) · line 873

Quoted 4 lines
drivers/gpu/drm/drm_mode_config.c +2 -2
-			WARN(1, "[PLANE:%d:%s] pixel format with alpha exposed but blend mode not setup",
-			     plane->base.id, plane->name);
+			drm_warn(plane->dev,
+				 "[PLANE:%d:%s] pixel format with alpha exposed but blend mode not setup. Please fix.",

[Severity: Low]
Should this format string end with a newline character?

Without a trailing \n, this warning message might remain buffered or get concatenated with subsequent unrelated kernel log messages.

Quoted 4 lines
drivers/gpu/drm/drm_mode_config.c +1 -0
+				 plane->base.id, plane->name);
 			break;
 		}
 	}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#3 lore raw
In reply to Leandro Ribeiro

Who is supposed to take this patch?

Since this problem is preventing syzbot from testing changes in linux-next kernels for more than three weeks, I expect this patch to be applied as soon as possible.

Quoted 20 lines · Leandro Ribeiro

Commit 860e748bddcc ("drm: ensure blend mode supported if pixel format with alpha exposed") introduced a WARN() to let driver developers know that a previously valid behavior should now be changed.

But WARN() should not be used for that, as it's a kernel warning report mechanism for conditions that are not expected to happen. It also produces a stack trace. Instead, a simple warning-level log message should have been used, as drivers were expected to trigger the condition.

This is causing problems for fuzzers, as they may stop when encountering a "BUG:" or "WARNING:" in the logs.

Replace WARN() with drm_warn() in this function, avoiding these issues.

Fixes 860e748bddcc ("drm: ensure blend mode supported if pixel format with alpha exposed")
---
 drivers/gpu/drm/drm_mode_config.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
#4 lore raw

Merge window will open shortly. Can we have this fix applied before commit 860e748bddcc ("drm: ensure blend mode supported if pixel format with alpha exposed") hits upstream?

Quoted 27 lines · Tetsuo Handa

Who is supposed to take this patch?

Since this problem is preventing syzbot from testing changes in linux-next kernels for more than three weeks, I expect this patch to be applied as soon as possible.

Quoted 20 lines · Leandro Ribeiro

Commit 860e748bddcc ("drm: ensure blend mode supported if pixel format with alpha exposed") introduced a WARN() to let driver developers know that a previously valid behavior should now be changed.

But WARN() should not be used for that, as it's a kernel warning report mechanism for conditions that are not expected to happen. It also produces a stack trace. Instead, a simple warning-level log message should have been used, as drivers were expected to trigger the condition.

This is causing problems for fuzzers, as they may stop when encountering a "BUG:" or "WARNING:" in the logs.

Replace WARN() with drm_warn() in this function, avoiding these issues.

Fixes 860e748bddcc ("drm: ensure blend mode supported if pixel format with alpha exposed")
---
 drivers/gpu/drm/drm_mode_config.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
#5 lore raw

Hi Tetsuo,

Quoted 3 lines · Tetsuo Handa

Merge window will open shortly. Can we have this fix applied before commit 860e748bddcc ("drm: ensure blend mode supported if pixel format with alpha exposed") hits upstream?

This has now gone into drm-misc-next-fixes for the next pull in the cycle, and is already in DRM's for-linux-next.

Cheers,
Daniel

Reviewed-by on v2 1/1
#6 lore raw
In reply to Leandro Ribeiro

Hi Leandro,

Quoted 10 lines · Leandro Ribeiro

Commit 860e748bddcc ("drm: ensure blend mode supported if pixel format with alpha exposed") introduced a WARN() to let driver developers know that a previously valid behavior should now be changed.

But WARN() should not be used for that, as it's a kernel warning report mechanism for conditions that are not expected to happen. It also produces a stack trace. Instead, a simple warning-level log message should have been used, as drivers were expected to trigger the condition.

Quoted 7 lines

This is causing problems for fuzzers, as they may stop when encountering a "BUG:" or "WARNING:" in the logs.

Replace WARN() with drm_warn() in this function, avoiding these issues.

Fixes 860e748bddcc ("drm: ensure blend mode supported if pixel format with alpha exposed")

Thanks, this is:

I'll fix up the newline when applying.

Cheers,
Daniel

#7 lore raw
Quoted 19 lines · Daniel Stone

Hi Leandro,

Quoted 15 lines · Leandro Ribeiro

Commit 860e748bddcc ("drm: ensure blend mode supported if pixel format with alpha exposed") introduced a WARN() to let driver developers know that a previously valid behavior should now be changed.

But WARN() should not be used for that, as it's a kernel warning report mechanism for conditions that are not expected to happen. It also produces a stack trace. Instead, a simple warning-level log message should have been used, as drivers were expected to trigger the condition.

This is causing problems for fuzzers, as they may stop when encountering a "BUG:" or "WARNING:" in the logs.

Replace WARN() with drm_warn() in this function, avoiding these issues.

Quoted 7 lines
Quoted 2 lines
Fixes 860e748bddcc ("drm: ensure blend mode supported if pixel format with alpha exposed")

Thanks, this is:

I'll fix up the newline when applying.

Hi Maarten, Maxime and Thomas,

can you cherry-pick this fix for drm-misc-fixes and send a pull-request to Dave and Simona before the end of this week? I think this should land in rc1 because people are already complaining about the warnings and it will take some time to fix all affected drivers. I'm not even sure if those fixes can land in mainline after rc1.

If you don't have the time to do this or the other fixes in drm-misc-fixes are not yet ready for mainline, I will ask Linus to pick this fix directly.

Viktor

maintainer
#8 lore raw
Quoted 36 lines · Viktor Jägersküpper
Quoted 19 lines · Daniel Stone

Hi Leandro,

Quoted 15 lines · Leandro Ribeiro

Commit 860e748bddcc ("drm: ensure blend mode supported if pixel format with alpha exposed") introduced a WARN() to let driver developers know that a previously valid behavior should now be changed.

But WARN() should not be used for that, as it's a kernel warning report mechanism for conditions that are not expected to happen. It also produces a stack trace. Instead, a simple warning-level log message should have been used, as drivers were expected to trigger the condition.

This is causing problems for fuzzers, as they may stop when encountering a "BUG:" or "WARNING:" in the logs.

Replace WARN() with drm_warn() in this function, avoiding these issues.

Quoted 7 lines
Quoted 2 lines
Fixes 860e748bddcc ("drm: ensure blend mode supported if pixel format with alpha exposed")

Thanks, this is:

I'll fix up the newline when applying.

Hi Maarten, Maxime and Thomas,

can you cherry-pick this fix for drm-misc-fixes and send a pull-request to Dave and Simona before the end of this week? I think this should land in rc1 because people are already complaining about the warnings and it will take some time to fix all affected drivers. I'm not even sure if those fixes can land in mainline after rc1.

Quoted 3 lines

If you don't have the time to do this or the other fixes in drm-misc-fixes are not yet ready for mainline, I will ask Linus to pick this fix directly.

This has been sent last week:
https://lore.kernel.org/dri-devel/20260820-fabulous-nimble-woodpecker-ffa695@houat/

Maxime