[igt-dev] [PATCH i-g-t] runner_tests: Fix the file descriptor leakage subtest

Ser, Simon simon.ser at intel.com
Wed Jun 5 10:04:40 UTC 2019


On Tue, 2019-06-04 at 18:12 +0300, Arkadiusz Hiler wrote:
> Some libraries (looking at you, GnuTLS) may leave fds opened after the
> implicitly called library constructor. We don't have full control over
> them as they may be dependencies of our dependencies and may get pulled
> in if the user's and distribution's compile/configure/USE are just
> right.
> 
> Let's close all the non-standard fds ahead of executing anything in the
> igt_runner tests, so we can test for descriptor leakage caused by any of
> the igt_runner code-paths exercised there.
> 
> Cc: Antonio Argenziano <antonio.argenziano at intel.com>
> Cc: Petri Latvala <petri.latvala at intel.com>
> Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler at intel.com>
> ---
>  runner/runner_tests.c | 21 ++++++++++++++++++++-
>  1 file changed, 20 insertions(+), 1 deletion(-)
> 
> diff --git a/runner/runner_tests.c b/runner/runner_tests.c
> index 1fc09688..c09cda70 100644
> --- a/runner/runner_tests.c
> +++ b/runner/runner_tests.c
> @@ -208,8 +208,27 @@ igt_main
>  {
>  	struct settings *settings = malloc(sizeof(*settings));
>  
> -	igt_fixture
> +	igt_fixture {
> +		int i;
> +
> +		/*
> +		 * Let's close all the non-standard fds ahead of executing
> +		 * anything, so we can test for descriptor leakage caused by
> +		 * any of the igt_runner code-paths exercised here.
> +		 *
> +		 * See file-descriptor-leakage subtest at the end.
> +		 *
> +		 * Some libraries (looking at you, GnuTLS) may leave fds opened
> +		 * after the implicitly called library constructor. We don't
> +		 * have full control over them as they may be dependencies of
> +		 * our dependencies and may get pulled in if the user's and
> +		 * distribution's compile/configure/USE are just right.
> +		 */
> +		for (i = 3; i < 400; i++)
> +			close(i);

Do we care about not polluting errno?

In any case:

Reviewed-by: Simon Ser <simon.ser at intel.com>

> +
>  		init_settings(settings);
> +	}
>  
>  	igt_subtest("default-settings") {
>  		const char *argv[] = { "runner",


More information about the igt-dev mailing list