drm_edid: potential range checking issue?
Subsystems (2)
Hi list, :)
Just going through some Smatch warnings.
drivers/gpu/drm/drm_edid.c +1032 add_detailed_modes() 'data->data.timings' 5 <= 5
1027 /* Six modes per detailed section */
1028 for (i = 0; i < 6; i++) {
1029 struct std_timing *std;
1030 struct drm_display_mode *newmode;
1031
1032 std = &data->data.timings[i];
^^^^^^^^^^^^^^^^^^^^^^In include/drm/drm_edid.h this array has 5 elements not 6.
struct detailed_non_pixel {
u8 pad1;
u8 type; /* ff=serial, fe=string, fd=monitor range, fc=monitor name
fb=color point data, fa=standard timing data,
f9=undefined, f8=mfg. reserved */
u8 pad2;
union {
struct detailed_data_string str;
struct detailed_data_monitor_range range;
struct detailed_data_wpindex color;
struct std_timing timings[5];
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
struct cvt_timing cvt[4];
} data;
} __attribute__((packed));regards,
dan carpenter
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
Ping. This off-by-one overflow is still there in -next.
I'm not sure how to fix it because both the declaraion and the use in add_detailed_modes() look deliberate.
regards,
dan carpenter
Quoted 31 lines · Dan Carpenter
Hi list, :)
Just going through some Smatch warnings.
drivers/gpu/drm/drm_edid.c+1032add_detailed_modes()'data->data.timings' 5 <= 5
1027 /* Six modes per detailed section */
1028 for (i = 0; i < 6; i++) {
1029 structstd_timing*std;
1030 structdrm_display_mode*newmode;
10311032 std = &data->data.timings[i]; ^^^^^^^^^^^^^^^^^^^^^^In
include/drm/drm_edid.hthis array has 5 elements not 6.struct detailed_non_pixel { u8 pad1; u8 type; /* ff=serial, fe=string, fd=monitor range, fc=monitor name fb=color point data, fa=standard timing data, f9=undefined, f8=mfg. reserved */ u8 pad2; union { struct detailed_data_string str; struct detailed_data_monitor_range range; struct detailed_data_wpindex color; struct std_timing timings[5]; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ struct cvt_timing cvt[4]; } data; } __attribute__((packed));
Quoted 2 lines
regards,
dan carpenter
------------------------------------------------------------------------------
--
Quoted 14 lines · Dan Carpenter
Quoted 14 lines
In
include/drm/drm_edid.hthis array has 5 elements not 6.struct detailed_non_pixel { u8 pad1; u8 type; /* ff=serial, fe=string, fd=monitor range, fc=monitor name fb=color point data, fa=standard timing data, f9=undefined, f8=mfg. reserved */ u8 pad2; union { struct detailed_data_string str; struct detailed_data_monitor_range range; struct detailed_data_wpindex color; struct std_timing timings[5]; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This decl is wrong, should be 6. From the 1.4 spec:
"Six additional Standard Timings may be listed as a display descriptor (tag #FAh)."
The 1.3 spec is a little less explicit about it, but does show 6 standard timing codes in the 0xFA detailed subblock, terminated by 0x0A in the 18th byte. I don't have the docs for 1.2 or earlier, but we're paranoid enough about not adding broken timings that we should be fine.
- ajax
------------------------------------------------------------------------------
--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel
PATCH 1/1 drm_edid: There should be 6 Standard Timings
Smatch complained that we initialize 6 elements in add_detailed_modes() but the timings[] array is declared with 5 elements. Adam Jackson verified that 6 is the correct number of timings.
Quoted 5 lines · Adam Jackson
Quoted 2 lines
Quoted 2 lines
struct std_timing timings[5]; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^This decl is wrong, should be 6. From the 1.4 spec:
Quoted 7 lines
"Six additional Standard Timings may be listed as a display descriptor (tag #FAh)."
The 1.3 spec is a little less explicit about it, but does show 6 standard timing codes in the
0xFAdetailed subblock, terminated by0x0Ain the 18th byte. I don't have the docs for 1.2 or earlier, but we're paranoid enough about not adding broken timings that we should be fine.
This patch is basically a clean up, because timings[] is declared inside a union and increasing the number of elements here doesn't change the overall size of the union.
---
This patch applies to drm-next.
include/drm/drm_edid.h +1 -1
@@ -120,7 +120,7 @@ struct detailed_non_pixel {struct detailed_data_string str;struct detailed_data_monitor_range range;struct detailed_data_wpindex color; -struct std_timing timings[5 ]; +struct std_timing timings[6 ];struct cvt_timing cvt[4 ]; } data; } __attribute__((packed));
------------------------------------------------------------------------------
--
Re: [patch] drm_edid: There should be 6 Standard Timings
Quoted 18 lines · Dan Carpenter
Smatch complained that we initialize 6 elements in
add_detailed_modes()but the timings[] array is declared with 5 elements. Adam Jackson verified that 6 is the correct number of timings.Quoted 5 lines · Adam Jackson
Quoted 2 lines
Quoted 2 lines
struct std_timing timings[5]; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^This decl is wrong, should be 6. From the 1.4 spec:
Quoted 7 lines
"Six additional Standard Timings may be listed as a display descriptor (tag #FAh)."
The 1.3 spec is a little less explicit about it, but does show 6 standard timing codes in the
0xFAdetailed subblock, terminated by0x0Ain the 18th byte. I don't have the docs for 1.2 or earlier, but we're paranoid enough about not adding broken timings that we should be fine.
Quoted 5 lines
This patch is basically a clean up, because timings[] is declared inside a union and increasing the number of elements here doesn't change the overall size of the union.
Signed-off-by Dan Carpenter <[email protected]>
- ajax
------------------------------------------------------------------------------
--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel