drm/i915: zero fill vma name buffer
Subsystems (2)
PATCH 1/1 drm/i915: zero fill vma name buffer
In capture_vma() Coverity complains of a possible buffer overrun. Even though this is a static function where all call sites can be checked, limiting the copy length could save some future grief.
CID 93300 (#1 of 1): Copy into fixed size buffer (STRING_OVERFLOW)
4. fixed_size_dest: You might overrun the 16-character fixed-size string c->name by copying name without checking the length.
5. parameter_as_source: Note: This defect has an elevated risk because the source argument is a parameter of the current function.
1326 strcpy(c->name, name);
Fix any possible overflows by using strncpy(). Zero fill the name buffer to guarantee ASCII string NULL termination.
--- drivers/gpu/drm/i915/i915_gpu_error.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_gpu_error.c +4 -3
@@ -1297,10 +1297,11 @@ static bool record_context(struct i915_gem_context_coredump *e,return simulated; } +#define VMA_NAME_LEN 16struct intel_engine_capture_vma {struct intel_engine_capture_vma *next;struct i915_vma *vma; -char name[16 ]; +char name[VMA_NAME_LEN ]; }; static struct intel_engine_capture_vma *
@@ -1314,7 +1315,7 @@ capture_vma(struct intel_engine_capture_vma *next,if (!vma)return next; - c =kmalloc (sizeof (*c), gfp); + c =kzalloc (sizeof (*c), gfp);if (!c)return next;
@@ -1323,7 +1324,7 @@ capture_vma(struct intel_engine_capture_vma *next,return next; } -strcpy (c->name, name); +strncpy (c->name, name,VMA_NAME_LEN -1 ); c->vma = vma;/* reference held while active */ c->next = next;
Signature · 1 line
2.33.0
Patchwork
CI[Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915: zero fill vma name buffer
== Series Details ==
== Series Details ==
Series: drm/i915: zero fill vma name buffer
URL : https://patchwork.freedesktop.org/series/94708/
State : warning
== Summary ==
$ dim checkpatch origin/drm-tip 3215090a38c8 drm/i915: zero fill vma name buffer -:11: WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line) #11: 4. fixed_size_dest: You might overrun the 16-character fixed-size string c->name
-:61: CHECK:SPACING: spaces preferred around that '-' (ctx:VxV) #61: FILE: drivers/gpu/drm/i915/i915_gpu_error.c:1347:
+ strncpy(c->name, name, VMA_NAME_LEN-1);
^
total: 0 errors, 1 warnings, 1 checks, 28 lines checked
Patchwork
CI[Intel-gfx] ✗ Fi.CI.BAT: failure for drm/i915: zero fill vma name buffer
In reply to Tim Gardner== Series Details ==
== Series Details ==
Series: drm/i915: zero fill vma name buffer
URL : https://patchwork.freedesktop.org/series/94708/
State : failure
== Summary ==
CI Bug Log - changes from CI_DRM_10593 -> Patchwork_21066
====================================================
Summary
-------
**FAILURE**
Serious unknown changes coming with Patchwork_21066 absolutely need to be verified manually.
If you think the reported changes have nothing to do with the changes introduced in Patchwork_21066, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.
External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21066/index.html
Possible new issues
-------------------
Here are the unknown changes that may have been introduced in Patchwork_21066:
### IGT changes ###
#### Possible regressions ####
* igt@i915_module_load@reload:
- fi-rkl-guc: NOTRUN -> [INCOMPLETE][1]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21066/fi-rkl-guc/igt@[email protected]
- fi-skl-6700k2: NOTRUN -> [INCOMPLETE][2]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21066/fi-skl-6700k2/igt@[email protected]
- fi-skl-guc: [PASS][3] -> [INCOMPLETE][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10593/fi-skl-guc/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21066/fi-skl-guc/igt@[email protected]
- fi-icl-y: [PASS][5] -> [INCOMPLETE][6]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10593/fi-icl-y/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21066/fi-icl-y/igt@[email protected]
#### Warnings ####
* igt@i915_module_load@reload:
- fi-cml-u2: [INCOMPLETE][7] ([i915#4136]) -> [INCOMPLETE][8]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10593/fi-cml-u2/igt@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21066/fi-cml-u2/igt@[email protected]
- fi-kbl-soraka: [INCOMPLETE][9] ([i915#4136]) -> [INCOMPLETE][10]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10593/fi-kbl-soraka/igt@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21066/fi-kbl-soraka/igt@[email protected]
#### Suppressed ####
The following results come from untrusted machines, tests, or statuses. They do not affect the overall result.
* igt@i915_module_load@reload:
- {fi-tgl-dsi}: [INCOMPLETE][11] ([i915#4136]) -> [INCOMPLETE][12]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10593/fi-tgl-dsi/igt@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21066/fi-tgl-dsi/igt@[email protected]
- {fi-ehl-2}: [INCOMPLETE][13] ([i915#4136]) -> [INCOMPLETE][14]
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10593/fi-ehl-2/igt@[email protected]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21066/fi-ehl-2/igt@[email protected]
Known issues
------------
Here are the changes found in Patchwork_21066 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@amdgpu/amd_cs_nop@fork-gfx0:
- fi-icl-u2: NOTRUN -> [SKIP][15] ([fdo#109315]) +17 similar issues
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21066/fi-icl-u2/igt@amdgpu/[email protected]
* igt@core_hotunplug@unbind-rebind:
- fi-cfl-guc: [PASS][16] -> [INCOMPLETE][17] ([i915#4130])
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10593/fi-cfl-guc/igt@[email protected]
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21066/fi-cfl-guc/igt@[email protected]
- fi-tgl-1115g4: NOTRUN -> [INCOMPLETE][18] ([i915#4130])
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21066/fi-tgl-1115g4/igt@[email protected]
- fi-cfl-8700k: [PASS][19] -> [INCOMPLETE][20] ([i915#4130])
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10593/fi-cfl-8700k/igt@[email protected]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21066/fi-cfl-8700k/igt@[email protected]
- fi-rkl-11600: [PASS][21] -> [INCOMPLETE][22] ([i915#4130])
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10593/fi-rkl-11600/igt@[email protected]
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21066/fi-rkl-11600/igt@[email protected]
* igt@gem_huc_copy@huc-copy:
- fi-tgl-1115g4: NOTRUN -> [SKIP][23] ([i915#2190])
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21066/fi-tgl-1115g4/igt@[email protected]
* igt@i915_pm_backlight@basic-brightness:
- fi-tgl-1115g4: NOTRUN -> [SKIP][24] ([i915#1155])
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21066/fi-tgl-1115g4/igt@[email protected]
* igt@kms_chamelium@common-hpd-after-suspend:
- fi-tgl-1115g4: NOTRUN -> [SKIP][25] ([fdo#111827]) +8 similar issues
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21066/fi-tgl-1115g4/igt@[email protected]
* igt@kms_cursor_legacy@basic-busy-flip-before-cursor-atomic:
- fi-tgl-1115g4: NOTRUN -> [SKIP][26] ([i915#4103]) +1 similar issue
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21066/fi-tgl-1115g4/igt@[email protected]
* igt@kms_force_connector_basic@force-load-detect:
- fi-tgl-1115g4: NOTRUN -> [SKIP][27] ([fdo#109285])
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21066/fi-tgl-1115g4/igt@[email protected]
* igt@kms_pipe_crc_basic@nonblocking-crc-pipe-a:
- fi-rkl-11600: [PASS][28] -> [SKIP][29] ([i915#3919] / [i915#4098])
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10593/fi-rkl-11600/igt@[email protected]
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21066/fi-rkl-11600/igt@[email protected]
* igt@kms_psr@primary_mmap_gtt:
- fi-tgl-1115g4: NOTRUN -> [SKIP][30] ([i915#1072]) +3 similar issues
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21066/fi-tgl-1115g4/igt@kms_psr@primary_mmap_gtt.html
* igt@prime_vgem@basic-userptr:
- fi-tgl-1115g4: NOTRUN -> [SKIP][31] ([i915#3301])
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21066/fi-tgl-1115g4/igt@[email protected]
* igt@runner@aborted:
- fi-kbl-8809g: NOTRUN -> [FAIL][32] ([i915#2722] / [i915#3363])
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21066/fi-kbl-8809g/igt@[email protected]
- fi-cml-u2: NOTRUN -> [FAIL][33] ([i915#2082] / [i915#2426] / [i915#3363])
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21066/fi-cml-u2/igt@[email protected]
- fi-rkl-guc: NOTRUN -> [FAIL][34] ([i915#2426])
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21066/fi-rkl-guc/igt@[email protected]
- fi-tgl-1115g4: NOTRUN -> [FAIL][35] ([i915#1602] / [i915#2722])
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21066/fi-tgl-1115g4/igt@[email protected]
- fi-skl-guc: NOTRUN -> [FAIL][36] ([i915#2426] / [i915#3363])
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21066/fi-skl-guc/igt@[email protected]
- fi-skl-6700k2: NOTRUN -> [FAIL][37] ([i915#2426] / [i915#3363])
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21066/fi-skl-6700k2/igt@[email protected]
#### Possible fixes ####
* igt@core_hotunplug@unbind-rebind:
- fi-skl-6700k2: [INCOMPLETE][38] ([i915#4130]) -> [PASS][39]
[38]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10593/fi-skl-6700k2/igt@[email protected]
[39]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21066/fi-skl-6700k2/igt@[email protected]
- fi-rkl-guc: [INCOMPLETE][40] ([i915#4130]) -> [PASS][41]
[40]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10593/fi-rkl-guc/igt@[email protected]
[41]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21066/fi-rkl-guc/igt@[email protected]
- fi-icl-u2: [INCOMPLETE][42] ([i915#4130]) -> [PASS][43]
[42]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10593/fi-icl-u2/igt@[email protected]
[43]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21066/fi-icl-u2/igt@[email protected]
* igt@i915_module_load@reload:
- fi-kbl-guc: [INCOMPLETE][44] -> [PASS][45]
[44]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10593/fi-kbl-guc/igt@[email protected]
[45]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21066/fi-kbl-guc/igt@[email protected]
#### Warnings ####
* igt@i915_module_load@reload:
- fi-kbl-8809g: [INCOMPLETE][46] -> [INCOMPLETE][47] ([i915#4136])
[46]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10593/fi-kbl-8809g/igt@[email protected]
[47]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21066/fi-kbl-8809g/igt@[email protected]
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[fdo#109285]: https://bugs.freedesktop.org/show_bug.cgi?id=109285
[fdo#109315]: https://bugs.freedesktop.org/show_bug.cgi?id=109315
[fdo#111827]: https://bugs.freedesktop.org/show_bug.cgi?id=111827
[i915#1072]: https://gitlab.freedesktop.org/drm/intel/issues/1072
[i915#1155]: https://gitlab.freedesktop.org/drm/intel/issues/1155
[i915#1602]: https://gitlab.freedesktop.org/drm/intel/issues/1602
[i915#2082]: https://gitlab.freedesktop.org/drm/intel/issues/2082
[i915#2190]: https://gitlab.freedesktop.org/drm/intel/issues/2190
[i915#2426]: https://gitlab.freedesktop.org/drm/intel/issues/2426
[i915#2722]: https://gitlab.freedesktop.org/drm/intel/issues/2722
[i915#2932]: https://gitlab.freedesktop.org/drm/intel/issues/2932
[i915#3301]: https://gitlab.freedesktop.org/drm/intel/issues/3301
[i915#3363]: https://gitlab.freedesktop.org/drm/intel/issues/3363
[i915#3690]: https://gitlab.freedesktop.org/drm/intel/issues/3690
[i915#3919]: https://gitlab.freedesktop.org/drm/intel/issues/3919
[i915#4098]: https://gitlab.freedesktop.org/drm/intel/issues/4098
[i915#4103]: https://gitlab.freedesktop.org/drm/intel/issues/4103
[i915#4130]: https://gitlab.freedesktop.org/drm/intel/issues/4130
[i915#4136]: https://gitlab.freedesktop.org/drm/intel/issues/4136
Participating hosts (39 -> 37)
------------------------------
Additional (1): fi-tgl-1115g4
Missing (3): fi-bdw-samus fi-bsw-cyan bat-dg1-6
Build changes
-------------
* Linux: CI_DRM_10593 -> Patchwork_21066
CI-20190529: 20190529
CI_DRM_10593: 6bc334de7baec4510b614dc80c330bf81fb8ca6f @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_6209: 07d6594ed02f55b68d64fa6dd7f80cfbc1ce4ef8 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_21066: 3215090a38c8278c2a4e4562d4a74dc697764af0 @ git://anongit.freedesktop.org/gfx-ci/linux
== Linux commits ==
3215090a38c8 drm/i915: zero fill vma name buffer
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21066/index.html
Quoted 54 lines · Tim Gardner
In
capture_vma()Coverity complains of a possible buffer overrun. Even though this is a static function where all call sites can be checked, limiting the copy length could save some future grief.CID 93300 (#1 of 1): Copy into fixed size buffer (
STRING_OVERFLOW)
4.fixed_size_dest: You might overrun the 16-character fixed-size stringc->nameby copying name without checking the length.
5.parameter_as_source: Note: This defect has an elevated risk because the source argument is a parameter of the current function.
1326strcpy(c->name, name);Fix any possible overflows by using
strncpy(). Zero fill the name buffer to guarantee ASCII string NULL termination.Cc Jani Nikula <[email protected]>Cc Joonas Lahtinen <[email protected]>Cc Rodrigo Vivi <[email protected]>Cc David Airlie <[email protected]>Cc Daniel Vetter <[email protected]>Signed-off-by Tim Gardner <[email protected]>--- drivers/gpu/drm/i915/i915_gpu_error.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/gpu/drm/i915/i915_gpu_error.c +3
-2@@ -1297,10 +1297,11 @@ static bool record_context(struct i915_gem_context_coredump *e,return simulated; } +#define VMA_NAME_LEN 16struct intel_engine_capture_vma {struct intel_engine_capture_vma *next;struct i915_vma *vma; -char name[16 ]; +char name[VMA_NAME_LEN ]; }; static struct intel_engine_capture_vma *@@ -1314,7 +1315,7 @@ capture_vma(struct intel_engine_capture_vma *next,if (!vma)return next; - c =kmalloc (sizeof (*c), gfp); + c =kzalloc (sizeof (*c), gfp);if (!c)return next;
drivers/gpu/drm/i915/i915_gpu_error.c capture_vma(struct intel_engine_capture_vma *next, · line 1327
Quoted 5 lines
drivers/gpu/drm/i915/i915_gpu_error.c +1
-1@@ -1323,7 +1324,7 @@ capture_vma(struct intel_engine_capture_vma *next,return next; } -strcpy (c->name, name); +strncpy (c->name, name,VMA_NAME_LEN -1 );
GCC is supposed to catch any problems here as you say in the commit message.
But to fix I suggest a single line change to strlcpy(c->name, name, sizeof(c->name)) which always null terminates as bonus.
Probably same in i915_vma_coredump_create() which with strncpy would have a theoretical chance of attempting to copy over a non-null-terminated string.
Regards,
Tvrtko
Quoted 4 lines
drivers/gpu/drm/i915/i915_gpu_error.c +0
-0c->vma = vma;/* reference held while active */ c->next = next;
Jani Nikula
maintainerQuoted 58 lines · Tvrtko Ursulin
Quoted 57 lines · Tim Gardner
In
capture_vma()Coverity complains of a possible buffer overrun. Even though this is a static function where all call sites can be checked, limiting the copy length could save some future grief.CID 93300 (#1 of 1): Copy into fixed size buffer (
STRING_OVERFLOW)
4.fixed_size_dest: You might overrun the 16-character fixed-size stringc->nameby copying name without checking the length.
5.parameter_as_source: Note: This defect has an elevated risk because the source argument is a parameter of the current function.
1326strcpy(c->name, name);Fix any possible overflows by using
strncpy(). Zero fill the name buffer to guarantee ASCII string NULL termination.Cc Jani Nikula <[email protected]>Cc Joonas Lahtinen <[email protected]>Cc Rodrigo Vivi <[email protected]>Cc David Airlie <[email protected]>Cc Daniel Vetter <[email protected]>Signed-off-by Tim Gardner <[email protected]>--- drivers/gpu/drm/i915/i915_gpu_error.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/gpu/drm/i915/i915_gpu_error.c +3
-2@@ -1297,10 +1297,11 @@ static bool record_context(struct i915_gem_context_coredump *e,return simulated; } +#define VMA_NAME_LEN 16struct intel_engine_capture_vma {struct intel_engine_capture_vma *next;struct i915_vma *vma; -char name[16 ]; +char name[VMA_NAME_LEN ]; }; static struct intel_engine_capture_vma *@@ -1314,7 +1315,7 @@ capture_vma(struct intel_engine_capture_vma *next,if (!vma)return next; - c =kmalloc (sizeof (*c), gfp); + c =kzalloc (sizeof (*c), gfp);if (!c)return next;@@ -1323,7 +1324,7 @@ capture_vma(struct intel_engine_capture_vma *next,return next; }
Quoted 7 lines
drivers/gpu/drm/i915/i915_gpu_error.c capture_vma(struct intel_engine_capture_vma *next, · line 1327
Quoted 2 lines
drivers/gpu/drm/i915/i915_gpu_error.c +1
-1-strcpy (c->name, name); +strncpy (c->name, name,VMA_NAME_LEN -1 );GCC is supposed to catch any problems here as you say in the commit message.
But to fix I suggest a single line change to
strlcpy(c->name, name, sizeof(c->name))which always null terminates as bonus.
strscpy() is preferred over both strncpy() and strlcpy(). :)
BR,
Jani.
Quoted 13 lines
Probably same in
i915_vma_coredump_create()which with strncpy would have a theoretical chance of attempting to copy over a non-null-terminated string.Regards,
Tvrtko
Quoted 4 lines
drivers/gpu/drm/i915/i915_gpu_error.c +0
-0c->vma = vma;/* reference held while active */ c->next = next;
Signature · 1 line
Jani Nikula, Intel Open Source Graphics Center
Quoted 64 lines · Jani Nikula
Quoted 63 lines · Tvrtko Ursulin
Quoted 54 lines · Tim Gardner
In
capture_vma()Coverity complains of a possible buffer overrun. Even though this is a static function where all call sites can be checked, limiting the copy length could save some future grief.CID 93300 (#1 of 1): Copy into fixed size buffer (
STRING_OVERFLOW)
4.fixed_size_dest: You might overrun the 16-character fixed-size stringc->nameby copying name without checking the length.
5.parameter_as_source: Note: This defect has an elevated risk because the source argument is a parameter of the current function.
1326strcpy(c->name, name);Fix any possible overflows by using
strncpy(). Zero fill the name buffer to guarantee ASCII string NULL termination.Cc Jani Nikula <[email protected]>Cc Joonas Lahtinen <[email protected]>Cc Rodrigo Vivi <[email protected]>Cc David Airlie <[email protected]>Cc Daniel Vetter <[email protected]>Signed-off-by Tim Gardner <[email protected]>--- drivers/gpu/drm/i915/i915_gpu_error.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/gpu/drm/i915/i915_gpu_error.c +3
-2@@ -1297,10 +1297,11 @@ static bool record_context(struct i915_gem_context_coredump *e,return simulated; } +#define VMA_NAME_LEN 16struct intel_engine_capture_vma {struct intel_engine_capture_vma *next;struct i915_vma *vma; -char name[16 ]; +char name[VMA_NAME_LEN ]; }; static struct intel_engine_capture_vma *@@ -1314,7 +1315,7 @@ capture_vma(struct intel_engine_capture_vma *next,if (!vma)return next; - c =kmalloc (sizeof (*c), gfp); + c =kzalloc (sizeof (*c), gfp);if (!c)return next;drivers/gpu/drm/i915/i915_gpu_error.c capture_vma(struct intel_engine_capture_vma *next, · line 1327
Quoted 5 lines
drivers/gpu/drm/i915/i915_gpu_error.c +1
-1@@ -1323,7 +1324,7 @@ capture_vma(struct intel_engine_capture_vma *next,return next; } -strcpy (c->name, name); +strncpy (c->name, name,VMA_NAME_LEN -1 );GCC is supposed to catch any problems here as you say in the commit message.
Quoted 8 lines
Quoted 2 lines
But to fix I suggest a single line change to
strlcpy(c->name, name, sizeof(c->name))which always null terminates as bonus.
strscpy()is preferred over bothstrncpy()andstrlcpy(). :)BR,
Jani.
Good call. v2 on the way.
rtg
Quoted 14 lines
Quoted 13 lines
Probably same in
i915_vma_coredump_create()which with strncpy would have a theoretical chance of attempting to copy over a non-null-terminated string.Regards,
Tvrtko
Quoted 4 lines
drivers/gpu/drm/i915/i915_gpu_error.c +0
-0c->vma = vma;/* reference held while active */ c->next = next;
Signature · 3 lines
----------- Tim Gardner Canonical, Inc
PATCH v2 1/1 drm/i915: use strscpy() to avoid buffer overrun
In capture_vma() Coverity complains of a possible buffer overrun. Even though this is a static function where all call sites can be checked, limiting the copy length could save some future grief.
CID 93300 (#1 of 1): Copy into fixed size buffer (STRING_OVERFLOW)
4. fixed_size_dest: You might overrun the 16-character fixed-size string c->name by copying name without checking the length.
5. parameter_as_source: Note: This defect has an elevated risk because the source argument is a parameter of the current function.
1326 strcpy(c->name, name);
Fix any possible overflows by using strscpy() which guarantees NULL termination.
Also correct 2 other strcpy() call sites with the same potential for Coverity warnings or overruns.
v2 - Change $SUBJECT from "drm/i915: zero fill vma name buffer"
Use strscpy() instead of strncpy(). Its a much simpler change.
--- drivers/gpu/drm/i915/i915_gpu_error.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_gpu_error.c +3 -3
@@ -1015,7 +1015,7 @@ i915_vma_coredump_create(const struct intel_gt *gt,return NULL ; } -strcpy (dst->name, name); +strscpy (dst->name, name,sizeof (dst->name)); dst->next =NULL ; dst->gtt_offset = vma->node.start;
@@ -1279,7 +1279,7 @@ static bool record_context(struct i915_gem_context_coredump *e,rcu_read_lock (); task =pid_task (ctx->pid,PIDTYPE_PID );if (task) { -strcpy (e->comm, task->comm); +strscpy (e->comm, task->comm,sizeof (e->comm)); e->pid = task->pid; }rcu_read_unlock ();
@@ -1323,7 +1323,7 @@ capture_vma(struct intel_engine_capture_vma *next,return next; } -strcpy (c->name, name); +strscpy (c->name, name,sizeof (c->name)); c->vma = vma;/* reference held while active */ c->next = next;
Signature · 1 line
2.33.0
Re: [Intel-gfx] [PATCH v2] drm/i915: use strscpy() to avoid buffer overrun
Quoted 56 lines · Tim Gardner
In
capture_vma()Coverity complains of a possible buffer overrun. Even though this is a static function where all call sites can be checked, limiting the copy length could save some future grief.CID 93300 (#1 of 1): Copy into fixed size buffer (
STRING_OVERFLOW)
4.fixed_size_dest: You might overrun the 16-character fixed-size stringc->nameby copying name without checking the length.
5.parameter_as_source: Note: This defect has an elevated risk because the source argument is a parameter of the current function.
1326strcpy(c->name, name);Fix any possible overflows by using
strscpy()which guarantees NULL termination.Also correct 2 other
strcpy()call sites with the same potential for Coverity warnings or overruns.v2 - Change $SUBJECT from "drm/i915: zero fill vma name buffer"
Usestrscpy()instead ofstrncpy(). Its a much simpler change.Cc Jani Nikula <[email protected]>Cc Joonas Lahtinen <[email protected]>Cc Rodrigo Vivi <[email protected]>Cc David Airlie <[email protected]>Cc Daniel Vetter <[email protected]>Signed-off-by Tim Gardner <[email protected]>--- drivers/gpu/drm/i915/i915_gpu_error.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/gpu/drm/i915/i915_gpu_error.c +2
-2@@ -1015,7 +1015,7 @@ i915_vma_coredump_create(const struct intel_gt *gt,return NULL ; } -strcpy (dst->name, name); +strscpy (dst->name, name,sizeof (dst->name)); dst->next =NULL ; dst->gtt_offset = vma->node.start;@@ -1279,7 +1279,7 @@ static bool record_context(struct i915_gem_context_coredump *e,rcu_read_lock (); task =pid_task (ctx->pid,PIDTYPE_PID );if (task) { -strcpy (e->comm, task->comm); +strscpy (e->comm, task->comm,sizeof (e->comm)); e->pid = task->pid; }rcu_read_unlock ();
drivers/gpu/drm/i915/i915_gpu_error.c capture_vma(struct intel_engine_capture_vma *next, · line 1329
Quoted 8 lines
drivers/gpu/drm/i915/i915_gpu_error.c +1
-1@@ -1323,7 +1323,7 @@ capture_vma(struct intel_engine_capture_vma *next,return next; } -strcpy (c->name, name); +strscpy (c->name, name,sizeof (c->name)); c->vma = vma;/* reference held while active */ c->next = next;
Regards,
Tvrtko
Patchwork
CI[Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915: zero fill vma name buffer (rev2)
In reply to Tim Gardner== Series Details ==
== Series Details ==
Series: drm/i915: zero fill vma name buffer (rev2)
URL : https://patchwork.freedesktop.org/series/94708/
State : warning
== Summary ==
$ dim checkpatch origin/drm-tip 129ca4e746b8 drm/i915: use strscpy() to avoid buffer overrun -:11: WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line) #11: 4. fixed_size_dest: You might overrun the 16-character fixed-size string c->name
total: 0 errors, 1 warnings, 0 checks, 24 lines checked
Patchwork
CI[Intel-gfx] ✗ Fi.CI.BAT: failure for drm/i915: zero fill vma name buffer (rev2)
In reply to Tim Gardner== Series Details ==
== Series Details ==
Series: drm/i915: zero fill vma name buffer (rev2)
URL : https://patchwork.freedesktop.org/series/94708/
State : failure
== Summary ==
CI Bug Log - changes from CI_DRM_10596 -> Patchwork_21074
====================================================
Summary
-------
**FAILURE**
Serious unknown changes coming with Patchwork_21074 absolutely need to be verified manually.
If you think the reported changes have nothing to do with the changes introduced in Patchwork_21074, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.
External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21074/index.html
Possible new issues
-------------------
Here are the unknown changes that may have been introduced in Patchwork_21074:
### IGT changes ###
#### Possible regressions ####
* igt@core_hotunplug@unbind-rebind:
- fi-rkl-guc: [PASS][1] -> [DMESG-WARN][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10596/fi-rkl-guc/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21074/fi-rkl-guc/igt@[email protected]
#### Suppressed ####
The following results come from untrusted machines, tests, or statuses. They do not affect the overall result.
* igt@i915_module_load@reload:
- {fi-tgl-dsi}: [INCOMPLETE][3] ([i915#4130] / [i915#4136]) -> [INCOMPLETE][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10596/fi-tgl-dsi/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21074/fi-tgl-dsi/igt@[email protected]
- {fi-ehl-2}: [INCOMPLETE][5] ([i915#4136]) -> [INCOMPLETE][6]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10596/fi-ehl-2/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21074/fi-ehl-2/igt@[email protected]
Known issues
------------
Here are the changes found in Patchwork_21074 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@amdgpu/amd_basic@cs-gfx:
- fi-skl-6700k2: NOTRUN -> [SKIP][7] ([fdo#109271]) +17 similar issues
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21074/fi-skl-6700k2/igt@amdgpu/[email protected]
* igt@amdgpu/amd_basic@cs-sdma:
- fi-cfl-8109u: NOTRUN -> [SKIP][8] ([fdo#109271]) +17 similar issues
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21074/fi-cfl-8109u/igt@amdgpu/[email protected]
- fi-kbl-7500u: NOTRUN -> [SKIP][9] ([fdo#109271]) +17 similar issues
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21074/fi-kbl-7500u/igt@amdgpu/[email protected]
* igt@amdgpu/amd_cs_nop@sync-fork-gfx0:
- fi-cfl-8700k: NOTRUN -> [SKIP][10] ([fdo#109271]) +17 similar issues
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21074/fi-cfl-8700k/igt@amdgpu/[email protected]
* igt@core_hotunplug@unbind-rebind:
- fi-tgl-1115g4: NOTRUN -> [INCOMPLETE][11] ([i915#4130])
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21074/fi-tgl-1115g4/igt@[email protected]
- fi-icl-u2: [PASS][12] -> [INCOMPLETE][13] ([i915#4130])
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10596/fi-icl-u2/igt@[email protected]
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21074/fi-icl-u2/igt@[email protected]
- fi-kbl-7567u: [PASS][14] -> [INCOMPLETE][15] ([i915#4130])
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10596/fi-kbl-7567u/igt@[email protected]
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21074/fi-kbl-7567u/igt@[email protected]
* igt@gem_huc_copy@huc-copy:
- fi-tgl-1115g4: NOTRUN -> [SKIP][16] ([i915#2190])
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21074/fi-tgl-1115g4/igt@[email protected]
* igt@i915_module_load@reload:
- fi-kbl-guc: [PASS][17] -> [INCOMPLETE][18] ([i915#4139])
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10596/fi-kbl-guc/igt@[email protected]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21074/fi-kbl-guc/igt@[email protected]
- fi-icl-y: [PASS][19] -> [INCOMPLETE][20] ([i915#4130])
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10596/fi-icl-y/igt@[email protected]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21074/fi-icl-y/igt@[email protected]
* igt@i915_pm_backlight@basic-brightness:
- fi-tgl-1115g4: NOTRUN -> [SKIP][21] ([i915#1155])
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21074/fi-tgl-1115g4/igt@[email protected]
* igt@kms_chamelium@common-hpd-after-suspend:
- fi-tgl-1115g4: NOTRUN -> [SKIP][22] ([fdo#111827]) +8 similar issues
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21074/fi-tgl-1115g4/igt@[email protected]
* igt@kms_cursor_legacy@basic-busy-flip-before-cursor-atomic:
- fi-tgl-1115g4: NOTRUN -> [SKIP][23] ([i915#4103]) +1 similar issue
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21074/fi-tgl-1115g4/igt@[email protected]
* igt@kms_force_connector_basic@force-load-detect:
- fi-tgl-1115g4: NOTRUN -> [SKIP][24] ([fdo#109285])
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21074/fi-tgl-1115g4/igt@[email protected]
* igt@kms_psr@primary_mmap_gtt:
- fi-tgl-1115g4: NOTRUN -> [SKIP][25] ([i915#1072]) +3 similar issues
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21074/fi-tgl-1115g4/igt@kms_psr@primary_mmap_gtt.html
* igt@prime_vgem@basic-userptr:
- fi-tgl-1115g4: NOTRUN -> [SKIP][26] ([i915#3301])
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21074/fi-tgl-1115g4/igt@[email protected]
* igt@runner@aborted:
- fi-kbl-8809g: NOTRUN -> [FAIL][27] ([i915#2722] / [i915#3363])
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21074/fi-kbl-8809g/igt@[email protected]
- fi-cml-u2: NOTRUN -> [FAIL][28] ([i915#2082] / [i915#2426] / [i915#3363])
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21074/fi-cml-u2/igt@[email protected]
- fi-tgl-1115g4: NOTRUN -> [FAIL][29] ([i915#1602] / [i915#2722])
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21074/fi-tgl-1115g4/igt@[email protected]
#### Possible fixes ####
* igt@core_hotunplug@unbind-rebind:
- fi-cfl-8700k: [INCOMPLETE][30] ([i915#4130]) -> [PASS][31]
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10596/fi-cfl-8700k/igt@[email protected]
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21074/fi-cfl-8700k/igt@[email protected]
- fi-kbl-7500u: [INCOMPLETE][32] ([i915#4130]) -> [PASS][33]
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10596/fi-kbl-7500u/igt@[email protected]
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21074/fi-kbl-7500u/igt@[email protected]
- fi-cfl-8109u: [INCOMPLETE][34] ([i915#4130]) -> [PASS][35]
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10596/fi-cfl-8109u/igt@[email protected]
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21074/fi-cfl-8109u/igt@[email protected]
* igt@i915_module_load@reload:
- fi-skl-6700k2: [INCOMPLETE][36] ([i915#4130] / [i915#4136]) -> [PASS][37]
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10596/fi-skl-6700k2/igt@[email protected]
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21074/fi-skl-6700k2/igt@[email protected]
#### Warnings ####
* igt@i915_module_load@reload:
- fi-kbl-8809g: [INCOMPLETE][38] -> [INCOMPLETE][39] ([i915#4136])
[38]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10596/fi-kbl-8809g/igt@[email protected]
[39]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21074/fi-kbl-8809g/igt@[email protected]
- fi-cml-u2: [INCOMPLETE][40] ([i915#4136]) -> [INCOMPLETE][41] ([i915#4130])
[40]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10596/fi-cml-u2/igt@[email protected]
[41]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21074/fi-cml-u2/igt@[email protected]
- fi-kbl-soraka: [INCOMPLETE][42] ([i915#4130] / [i915#4136]) -> [INCOMPLETE][43] ([i915#4136])
[42]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_10596/fi-kbl-soraka/igt@[email protected]
[43]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21074/fi-kbl-soraka/igt@[email protected]
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109285]: https://bugs.freedesktop.org/show_bug.cgi?id=109285
[fdo#111827]: https://bugs.freedesktop.org/show_bug.cgi?id=111827
[i915#1072]: https://gitlab.freedesktop.org/drm/intel/issues/1072
[i915#1155]: https://gitlab.freedesktop.org/drm/intel/issues/1155
[i915#1602]: https://gitlab.freedesktop.org/drm/intel/issues/1602
[i915#2082]: https://gitlab.freedesktop.org/drm/intel/issues/2082
[i915#2190]: https://gitlab.freedesktop.org/drm/intel/issues/2190
[i915#2426]: https://gitlab.freedesktop.org/drm/intel/issues/2426
[i915#2722]: https://gitlab.freedesktop.org/drm/intel/issues/2722
[i915#3301]: https://gitlab.freedesktop.org/drm/intel/issues/3301
[i915#3363]: https://gitlab.freedesktop.org/drm/intel/issues/3363
[i915#4103]: https://gitlab.freedesktop.org/drm/intel/issues/4103
[i915#4130]: https://gitlab.freedesktop.org/drm/intel/issues/4130
[i915#4136]: https://gitlab.freedesktop.org/drm/intel/issues/4136
[i915#4139]: https://gitlab.freedesktop.org/drm/intel/issues/4139
Participating hosts (37 -> 36)
------------------------------
Additional (1): fi-tgl-1115g4
Missing (2): fi-bsw-cyan fi-bdw-samus
Build changes
-------------
* Linux: CI_DRM_10596 -> Patchwork_21074
CI-20190529: 20190529
CI_DRM_10596: 3e450101ba783c61e51898a84b7758efbb505e8f @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_6209: 07d6594ed02f55b68d64fa6dd7f80cfbc1ce4ef8 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_21074: 129ca4e746b820a9c29ef1d1be70da6af98f2eaa @ git://anongit.freedesktop.org/gfx-ci/linux
== Linux commits ==
129ca4e746b8 drm/i915: use strscpy() to avoid buffer overrun
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_21074/index.html