From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x234.google.com (mail-oi1-x234.google.com [IPv6:2607:f8b0:4864:20::234]) by sourceware.org (Postfix) with ESMTPS id F2D293858D20 for ; Thu, 28 Sep 2023 11:11:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F2D293858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-oi1-x234.google.com with SMTP id 5614622812f47-3af65455e7cso304543b6e.1 for ; Thu, 28 Sep 2023 04:11:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695899508; x=1696504308; darn=sourceware.org; h=content-transfer-encoding:in-reply-to:organization:from:references :to:content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=RZobNM8eft1Ph3DtXB6IxXs02VMzjCrhIJreJqES9Hc=; b=gP2J+ZFwE6if6iWzGjfRiWWciaP+5iAeNOxsVhvWT8m11OnycY5Y+7zjXoaguZxV+m 8XQ9XDDExXPdaTxe43W8qUC9h+jmPC6Jcpc6wLrNYDYaKBDGJs6bEawh/AsQ1VyTL18L 5bmZAJmac8y3QlY9PY+AOF9F2NE8aOYYveq5u0JzxjWq1ALYdrq+EN8/dWZThdMgBQ4I aTKlou09H0mJnPbKbhGTlHlJzl34dlryisSIDmoj4NDiuBkdcIHlOd1I7SQnSTLGgqtX nZxkz70b2hW8wlyGVrE72nsLuZW+6dtJ7lOA1qoRDFsdp/Hxzcf8/Sm277uSi2gjGlMa EP0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695899508; x=1696504308; h=content-transfer-encoding:in-reply-to:organization:from:references :to:content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=RZobNM8eft1Ph3DtXB6IxXs02VMzjCrhIJreJqES9Hc=; b=WYuap1aVDIf6xJ+e0Z1FxiUkrrTTf4SXogmEO7SLdgH+kg/xgR9ZDtB4QuyG8gDafH /jYKq23j0LK692sZw43zPWQ6AjpexXEkNvTkAhsbRXbntGWsGqCDN7N24U5ELX2kF54k PptuR7eehrhAz06xLKKFbQ4kMob32s4cULz+xsQIGPQQovYnpoxhnnRqsidSbxpOqd9x iBKhwbfBjsVZfHy4GWGdYx8I1FkzmwoLkXJMY10vlxjKwfXxiO01z2U64bMGXS8mcR0u XgGWau154t6bFjzZViwOWs9GC7sdeilaljZ1/XtYhm76lzGWVlqD5jHGQqMq4L4fCYbZ c4IA== X-Gm-Message-State: AOJu0YzwZw22vz1He5MvuGPthOgOk8a6klAvtw/9DtLfIA45vR40nom6 2YmEON2jldhw/GJEWEjasmw9d+WKv8mDGTgIte2zFw== X-Google-Smtp-Source: AGHT+IEXByyaGoAlssvlOo6+OcVyaq17RSvTJD7TBbpNKfyrDA3xH0V2dq4KULZEOC3fgc6WPi/C4Q== X-Received: by 2002:a54:4806:0:b0:3ae:144f:f99b with SMTP id j6-20020a544806000000b003ae144ff99bmr794282oij.4.1695899508661; Thu, 28 Sep 2023 04:11:48 -0700 (PDT) Received: from ?IPV6:2804:1b3:a7c1:6eb0:6d4f:92fe:5e4e:27d3? ([2804:1b3:a7c1:6eb0:6d4f:92fe:5e4e:27d3]) by smtp.gmail.com with ESMTPSA id v26-20020aa7851a000000b0068a2d78890csm2485897pfn.68.2023.09.28.04.11.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 28 Sep 2023 04:11:47 -0700 (PDT) Message-ID: <64a68058-0371-40fd-b65d-369f53539e35@linaro.org> Date: Thu, 28 Sep 2023 08:11:45 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] test-container: Use nftw instead of rm -rf Content-Language: en-US To: libc-alpha@sourceware.org, Stefan Liebler References: <20230927192013.2071605-1-adhemerval.zanella@linaro.org> <6a83644f-98e9-5329-a8e9-c8a731e716ac@linux.ibm.com> From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: <6a83644f-98e9-5329-a8e9-c8a731e716ac@linux.ibm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 28/09/23 06:40, Stefan Liebler wrote: > On 27.09.23 21:20, Adhemerval Zanella wrote: >> If the binary to run is 'env', test-containers skips it and adds >> any required environment variable on the process envs variables. >> This simplifies the required code to spawn new process (no need >> to build an env-like program). >> >> However, this is an issue for recursive_remove if there is any >> LD_PRELOAD, since test-container will not prepend the loader command >> along with required paths. If the required preloaded library can >> not be loaded by the system glibc, the 'post-clean rsync' will >> eventually fail. >> >> One example is if system glibc does not support DT_RELR and the >> built glibc does, the nss/tst-nss-gai-hv2-canonname test fails >> with: >> >> ../scripts/evaluate-test.sh nss/tst-nss-gai-hv2-canonname $? false false >> 86_64-linux-gnu/nss/tst-nss-gai-hv2-canonname.test-result >> rm: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_ABI_DT_RELR' not >> found (required by x86_64-linux-gnu/malloc/libc_malloc_debug.so) >> >> Instead trying to figure out the required loader arguments on how >> to spawn the 'rm -rf', replace the command with a nftw call. >> > Just as information, I've also recognized this issue. For me (on > x86_64/s390x), I got "*** stack smashing detected ***: terminated" in > this rm due to preloading with the fresh build libc_malloc_debug.so. > In malloc_hook_ini -> generic_hook_ini -> initialize_malloc_check, we have: > TUNABLE_GET (check, int32_t, TUNABLE_CALLBACK (set_mallopt_check)); > In __tunable_get_val, the tunables ID from current-build and system for > glibc.malloc.check differs. In my case it is 30, which is beyond the > range of the systems tunable_list[]. This leads to storing a 8byte value > to passed valp. Unfortunately it points to a 4 byte int32_t and the > other 4 bytes belong to the stack smashing canary. Indeed the tunables might another problem, thanks for checking it. > > Your patch solves the issue for me. Is it a reviewed-by ;) ? >> Checked on x86_64-linux-gnu. >> --- >> support/test-container.c | 34 +++++++++++----------------------- >> 1 file changed, 11 insertions(+), 23 deletions(-) >> >> diff --git a/support/test-container.c b/support/test-container.c >> index 788b091ea0..95dfef1a99 100644 >> --- a/support/test-container.c >> +++ b/support/test-container.c >> @@ -37,6 +37,7 @@ >> #include >> #include >> #include >> +#include >> >> #ifdef __linux__ >> #include >> @@ -405,32 +406,19 @@ file_exists (char *path) >> return 0; >> } >> >> +static int >> +unlink_cb (const char *fpath, const struct stat *sb, int typeflag, >> + struct FTW *ftwbuf) >> +{ >> + return remove (fpath); >> +} >> + >> static void >> recursive_remove (char *path) >> { >> - pid_t child; >> - int status; >> - >> - child = fork (); >> - >> - switch (child) { >> - case -1: >> - perror("fork"); >> - FAIL_EXIT1 ("Unable to fork"); >> - case 0: >> - /* Child. */ >> - execlp ("rm", "rm", "-rf", path, NULL); >> - FAIL_EXIT1 ("exec rm: %m"); >> - default: >> - /* Parent. */ >> - waitpid (child, &status, 0); >> - /* "rm" would have already printed a suitable error message. */ >> - if (! WIFEXITED (status) >> - || WEXITSTATUS (status) != 0) >> - FAIL_EXIT1 ("exec child returned status: %d", status); >> - >> - break; >> - } >> + int r = nftw (path, unlink_cb, 1000, FTW_DEPTH | FTW_PHYS); >> + if (r == -1) >> + FAIL_EXIT1 ("recursive_remove failed"); >> } >> >> /* Used for both rsync and the mytest.script "cp" command. */ >