tests/testdisplay: fix heap overflow
PATCH 1/3 tests/testdisplay: fix heap overflow
Also simplify the code by using dirname(3).
--- tests/testdisplay.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-)
tests/testdisplay.c +4 -13
@@ -51,6 +51,7 @@#include <cairo.h> #include <errno.h> #include <getopt.h> +#include <libgen.h> #include <math.h> #include <stdint.h> #include <stdbool.h>
@@ -563,24 +564,14 @@ static gboolean input_event(GIOChannel *source, GIOCondition condition,return TRUE; } -static void enter_exec_path (char **argv ) +static void enter_exec_path (char **argv) { -char *exec_path =NULL ; -char *pos =NULL ; -short len_path =0 ; +char *exec_path;int ret; - len_path =strlen ( argv[0 ] ); - exec_path = (char *)malloc (len_path); - -memcpy (exec_path, argv[0 ], len_path); - pos =strrchr (exec_path,'/' ); -if (pos !=NULL ) - *(pos+1 ) ='\0' ; - + exec_path =dirname (argv[0 ]); ret =chdir (exec_path);igt_assert_eq (ret,0 ); -free (exec_path); }static void restore_termio_mode (int sig)
Signature · 17 lines
2.21.0 --------------------------------------------------------------------- Intel Finland Oy Registered Address: PL 281, 00181 Helsinki Business Identity Code: 0357606 - 4 Domiciled in Helsinki This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies. _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 2/3 meson: add -Wno-missing-braces
Enabling -Werror=missing-braces results in this error with Clang:
../tests/kms_vrr.c:203:20: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
drmVBlank vbl = { 0 };
^
{}I don't believe there is any value in keeping this, so let's just disable it.
--- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meson.build +1 -1
@@ -38,6 +38,7 @@ cc_args = [ '-Wno-type-limits', '-Wno-unused-parameter', '-Wno-unused-result', + '-Wno-missing-braces', '-Werror=address', '-Werror=array-bounds',
@@ -45,7 +46,6 @@ cc_args = [ '-Werror=init-self', '-Werror=int-to-pointer-cast', '-Werror=main', - '-Werror=missing-braces', '-Werror=nonnull', '-Werror=pointer-to-int-cast', '-Werror=return-type',
Signature · 17 lines
2.21.0 --------------------------------------------------------------------- Intel Finland Oy Registered Address: PL 281, 00181 Helsinki Business Identity Code: 0357606 - 4 Domiciled in Helsinki This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies. _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 3/3 runner/executor: refactor error handling
In reply to Simon Ser* Refactor to use goto error handling
* Make execute_test_process noreturn to remove uninitialized variable warning
* Check fork() return value
--- runner/executor.c | 63 ++++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 31 deletions(-)
runner/executor.c +32 -31
@@ -753,9 +753,10 @@ static int monitor_output(pid_t child,return killed; } -static void execute_test_process (int outfd,int errfd, -struct settings *settings, -struct job_list_entry *entry) +static void __attribute__((noreturn)) +execute_test_process (int outfd,int errfd, +struct settings *settings, +struct job_list_entry *entry) {char *argv[4 ] = {};size_t rootlen;
@@ -884,9 +885,9 @@ static int execute_next_entry(struct execute_state *state, }if (!open_output_files (dirfd, outputs, true)) { -close (dirfd);fprintf (stderr,"Error opening output files\n" ); -return -1 ; + result =-1 ; + goto out_dirfd; }if (settings->sync) {
@@ -895,14 +896,9 @@ static int execute_next_entry(struct execute_state *state, }if (pipe (outpipe) ||pipe (errpipe)) { -close_outputs (outputs); -close (dirfd); -close (outpipe[0 ]); -close (outpipe[1 ]); -close (errpipe[0 ]); -close (errpipe[1 ]);fprintf (stderr,"Error creating pipes: %s\n" ,strerror (errno)); -return -1 ; + result =-1 ; + goto out_pipe; }if ((kmsgfd =open ("/dev/kmsg" ,O_RDONLY |O_CLOEXEC )) <0 ) {
@@ -923,14 +919,8 @@ static int execute_next_entry(struct execute_state *state,if (sigfd <0 ) {/* TODO: Handle better */ fprintf (stderr,"Cannot monitor child process with signalfd\n" ); -close (outpipe[0 ]); -close (errpipe[0 ]); -close (outpipe[1 ]); -close (errpipe[1 ]); -close (kmsgfd); -close_outputs (outputs); -close (dirfd); -return -1 ; + result =-1 ; + goto out_kmsgfd; }if (settings->log_level >=LOG_LEVEL_NORMAL ) {
@@ -951,19 +941,15 @@ static int execute_next_entry(struct execute_state *state,* Flush outputs before forking so our (buffered) output won't * end up in the test outputs. */ -fflush (stdout);fflush (stderr); -if ((child =fork ())) { -int outfd = outpipe[0 ]; -int errfd = errpipe[0 ]; -close (outpipe[1 ]); -close (errpipe[1 ]); - - result =monitor_output (child, outfd, errfd, kmsgfd, sigfd, - outputs, time_spent, settings); - }else { + child =fork (); +if (child <0 ) { +fprintf (stderr,"Failed to fork()" ); + result =-1 ; + goto out_kmsgfd; + }else if (child ==0 ) {int outfd = outpipe[1 ];int errfd = errpipe[1 ];close (outpipe[0 ]);
@@ -974,13 +960,28 @@ static int execute_next_entry(struct execute_state *state,setenv ("IGT_SENTINEL_ON_STDERR" ,"1" ,1 );execute_test_process (outfd, errfd, settings, entry); +/* unreachable */ } -/* TODO: Refactor this whole function to use onion teardown */ +int outfd = outpipe[0 ]; +int errfd = errpipe[0 ];close (outpipe[1 ]);close (errpipe[1 ]); + outpipe[1 ] = errpipe[1 ] =-1 ; + + result =monitor_output (child, outfd, errfd, kmsgfd, sigfd, + outputs, time_spent, settings); + +out_kmsgfd:close (kmsgfd); +out_pipe: +close_outputs (outputs); +close (outpipe[0 ]); +close (outpipe[1 ]); +close (errpipe[0 ]); +close (errpipe[1 ]);close_outputs (outputs); +out_dirfd:close (dirfd);return result;
Signature · 17 lines
2.21.0 --------------------------------------------------------------------- Intel Finland Oy Registered Address: PL 281, 00181 Helsinki Business Identity Code: 0357606 - 4 Domiciled in Helsinki This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies. _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Gah. Sorry about this, I accidentally sent 3 patches instead of just the first one.
Please ignore all patches except the first.
---------------------------------------------------------------------
Intel Finland Oy
Registered Address: PL 281, 00181 Helsinki
Business Identity Code: 0357606 - 4
Domiciled in Helsinki
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Quoting Simon Ser (2019-03-20 11:15:54)
Quoted 31 lines
Also simplify the code by using dirname(3).
Signed-off-by Simon Ser <[email protected]>--- tests/testdisplay.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-)tests/testdisplay.c +3
-4@@ -51,6 +51,7 @@#include <cairo.h> #include <errno.h> #include <getopt.h> +#include <libgen.h> #include <math.h> #include <stdint.h> #include <stdbool.h> @@ -563,24 +564,14 @@ static gboolean input_event(GIOChannel *source, GIOCondition condition,return TRUE; } -static void enter_exec_path (char **argv ) +static void enter_exec_path (char **argv) { -char *exec_path =NULL ; -char *pos =NULL ; -short len_path =0 ; +char *exec_path;int ret;
tests/testdisplay.c static gboolean input_event(GIOChannel *source, GIOCondition condition, · line 572
Quoted 10 lines
tests/testdisplay.c +1
-8- len_path =strlen ( argv[0 ] ); - exec_path = (char *)malloc (len_path); - -memcpy (exec_path, argv[0 ], len_path); - pos =strrchr (exec_path,'/' ); -if (pos !=NULL ) - *(pos+1 ) ='\0' ; - + exec_path =dirname (argv[0 ]);
dirname() modifies inplace, so it might not be suitable as presumably we were copying the argv[0] for a reason :)
exec_path = strcpy(argv[0]);
if (exec_path)
exec_path = dirname(exec_path);
igt_assert_eq(chdir(exec_path), 0);free(exec_path);
And if we are not allowed to modify argv, why not say so and make it const?
-Chris
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Quoted 48 lines · Chris Wilson
Quoting Simon Ser (2019-03-20 11:15:54)
Quoted 32 lines
Also simplify the code by using dirname(3).
Signed-off-by Simon Ser <[email protected]>--- tests/testdisplay.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-)tests/testdisplay.c +3
-4@@ -51,6 +51,7 @@#include <cairo.h> #include <errno.h> #include <getopt.h> +#include <libgen.h> #include <math.h> #include <stdint.h> #include <stdbool.h> @@ -563,24 +564,14 @@ static gboolean input_event(GIOChannel *source, GIOCondition condition, return TRUE; } -static void enter_exec_path (char **argv ) +static void enter_exec_path (char **argv) { -char *exec_path =NULL ; -char *pos =NULL ; -short len_path =0 ; +char *exec_path;int ret;tests/testdisplay.c static gboolean input_event(GIOChannel · line 573
Quoted 10 lines
tests/testdisplay.c +1
-8- len_path =strlen ( argv[0 ] ); - exec_path = (char *)malloc (len_path); - -memcpy (exec_path, argv[0 ], len_path); - pos =strrchr (exec_path,'/' ); -if (pos !=NULL ) - *(pos+1 ) ='\0' ; - + exec_path =dirname (argv[0 ]);
dirname()modifies inplace, so it might not be suitable as presumably we
were copying the argv[0] for a reason :)
Quoted 8 lines
exec_path=strcpy(argv[0]);
if (exec_path)exec_path = dirname(exec_path);
igt_assert_eq(chdir(exec_path), 0);free(exec_path);And if we are not allowed to modify argv, why not say so and make it const?
That's a good point. I thought dirname returned a pointer to statically allocated memory, but as you said and per the spec libc is also allowed to modify the argument in place.
Will send v2 shortly.
Quoted 1 line
-Chris
---------------------------------------------------------------------
Intel Finland Oy
Registered Address: PL 281, 00181 Helsinki
Business Identity Code: 0357606 - 4
Domiciled in Helsinki
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Patchwork
CI[igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/3] tests/testdisplay: fix heap overflow
In reply to Simon Ser== Series Details ==
== Series Details ==
Series: series starting with [i-g-t,1/3] tests/testdisplay: fix heap overflow
URL : https://patchwork.freedesktop.org/series/58243/
State : success
== Summary ==
CI Bug Log - changes from CI_DRM_5780 -> IGTPW_2665
====================================================
Summary
-------
**SUCCESS**
No regressions found.
External URL: https://patchwork.freedesktop.org/api/1.0/series/58243/revisions/1/mbox/
Known issues
------------
Here are the changes found in IGTPW_2665 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@gem_exec_basic@basic-bsd2:
- fi-kbl-7500u: NOTRUN -> SKIP [fdo#109271] +9
* igt@gem_exec_suspend@basic-s3:
- fi-blb-e6850: PASS -> INCOMPLETE [fdo#107718]
* igt@kms_busy@basic-flip-b:
- fi-gdg-551: PASS -> FAIL [fdo#103182]
* igt@kms_chamelium@dp-crc-fast:
- fi-kbl-7500u: NOTRUN -> DMESG-WARN [fdo#103841]
* igt@kms_frontbuffer_tracking@basic:
- fi-byt-clapper: PASS -> FAIL [fdo#103167]
* igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b:
- fi-byt-clapper: PASS -> FAIL [fdo#103191] / [fdo#107362] +1
* igt@prime_vgem@basic-fence-flip:
- fi-ilk-650: PASS -> FAIL [fdo#104008]
* igt@runner@aborted:
- fi-kbl-7500u: NOTRUN -> FAIL [fdo#103841]
#### Possible fixes ####
* igt@i915_selftest@live_execlists:
- fi-apl-guc: INCOMPLETE [fdo#103927] / [fdo#109720] -> PASS
* igt@i915_selftest@live_uncore:
- fi-ivb-3770: DMESG-FAIL [fdo#110210] -> PASS
* igt@kms_frontbuffer_tracking@basic:
- fi-icl-u2: FAIL [fdo#103167] -> PASS
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
[fdo#103182]: https://bugs.freedesktop.org/show_bug.cgi?id=103182
[fdo#103191]: https://bugs.freedesktop.org/show_bug.cgi?id=103191
[fdo#103375]: https://bugs.freedesktop.org/show_bug.cgi?id=103375
[fdo#103841]: https://bugs.freedesktop.org/show_bug.cgi?id=103841
[fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
[fdo#104008]: https://bugs.freedesktop.org/show_bug.cgi?id=104008
[fdo#107362]: https://bugs.freedesktop.org/show_bug.cgi?id=107362
[fdo#107718]: https://bugs.freedesktop.org/show_bug.cgi?id=107718
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109720]: https://bugs.freedesktop.org/show_bug.cgi?id=109720
[fdo#109779]: https://bugs.freedesktop.org/show_bug.cgi?id=109779
[fdo#110210]: https://bugs.freedesktop.org/show_bug.cgi?id=110210
Participating hosts (48 -> 43)
------------------------------
Additional (1): fi-kbl-7500u
Missing (6): fi-kbl-soraka fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-ctg-p8600
Build changes
-------------
* IGT: IGT_4892 -> IGTPW_2665
CI_DRM_5780: 774f8c588542dda6d73161429cbf1e027789d6ef @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_2665: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2665/
IGT_4892: 8ae86621d6fff60b6e20c6b0f9b336785c935b0f @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2665/
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev