[PATCH v2 4/4] tst-env-setuid: Delete LD_DEBUG_OUTPUT output
Adhemerval Zanella Netto
adhemerval.zanella@linaro.org
Mon Aug 4 18:44:52 GMT 2025
On 19/07/25 11:43, H.J. Lu wrote:
> Update tst-env-setuid.c to delete LD_DEBUG_OUTPUT output, instead of
> leaving it behind.
>
> This partially fixes BZ #33182.
>
> Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
LGTM, thanks.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
> ---
> elf/tst-env-setuid.c | 26 ++++++++++++++++++++++----
> 1 file changed, 22 insertions(+), 4 deletions(-)
>
> diff --git a/elf/tst-env-setuid.c b/elf/tst-env-setuid.c
> index 7209acd616..ff3eda7f91 100644
> --- a/elf/tst-env-setuid.c
> +++ b/elf/tst-env-setuid.c
> @@ -40,6 +40,8 @@ static char SETGID_CHILD[] = "setgid-child";
> # define PROFILE_LIB "tst-sonamemove-runmod2.so"
> #endif
>
> +#define LD_DEBUG_OUTPUT "/tmp/some-file"
> +
> struct envvar_t
> {
> const char *env;
> @@ -61,7 +63,7 @@ static const struct envvar_t filtered_envvars[] =
> { "MALLOC_TRIM_THRESHOLD_", FILTERED_VALUE },
> { "RES_OPTIONS", FILTERED_VALUE },
> { "LD_DEBUG", "all" },
> - { "LD_DEBUG_OUTPUT", "/tmp/some-file" },
> + { "LD_DEBUG_OUTPUT", LD_DEBUG_OUTPUT },
> { "LD_WARN", FILTERED_VALUE },
> { "LD_VERBOSE", FILTERED_VALUE },
> { "LD_BIND_NOW", "0" },
> @@ -74,6 +76,14 @@ static const struct envvar_t unfiltered_envvars[] =
> { "LD_ASSUME_KERNEL", UNFILTERED_VALUE },
> };
>
> +static void
> +unlink_ld_debug_output (pid_t pid)
> +{
> + char *output = xasprintf ("%s.%d", LD_DEBUG_OUTPUT, pid);
> + unlink (output);
> + free (output);
> +}
> +
> static int
> test_child (void)
> {
> @@ -138,13 +148,21 @@ do_test (int argc, char **argv)
> /* Setgid child process. */
> if (argc == 2 && strcmp (argv[1], SETGID_CHILD) == 0)
> {
> + pid_t ppid = getppid ();
> +
> if (getgid () == getegid ())
> - /* This can happen if the file system is mounted nosuid. */
> - FAIL_UNSUPPORTED ("SGID failed: GID and EGID match (%jd)\n",
> - (intmax_t) getgid ());
> + {
> + /* This can happen if the file system is mounted nosuid. */
> + unlink_ld_debug_output (ppid);
> +
> + FAIL_UNSUPPORTED ("SGID failed: GID and EGID match (%jd)\n",
> + (intmax_t) getgid ());
> + }
>
> int ret = test_child ();
>
> + unlink_ld_debug_output (ppid);
> +
> if (ret != 0)
> exit (1);
> return 0;
More information about the Libc-alpha
mailing list