From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 68CD23858D20 for ; Thu, 28 Sep 2023 11:44:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 68CD23858D20 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38SBb0TR002718; Thu, 28 Sep 2023 11:44:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : subject : to : references : from : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=vrOOonoOEuBkDXaRZ3Hld72yNqypdtrtjRPO2PyJBi4=; b=BR1NGhPD5VSTX8GSU8BAuaD2eQWQPkdWYhncTkfLNPKYEFC2ZwaS0fe4aS5pD6vTgIgs WWousHNGV5HXZ74nCaeXfW+KxwTSTu9DxMHtH5Yi/lTewqvSSVaWu5pwS+74FicpIifH LWbAzJLK5q8MqoCtheHHL69rgOHkLGaHX/x8Es2LIg7DKBwYTZ+kEeezPOMrggH16loH c5x/tfofcABhJBSbV6BCYrZyUL2w0Q1/Zm9db+BeATiq88xxgnOoR8Gx/SW1ryRjjsXk GPZj+vERwH1X+EWlWIzu4oViJFId9fVc7Aw0Xo84WYngiDGlznDGmPQPlmH7Vk+afLoi 0w== Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3td77sjfqq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Sep 2023 11:44:34 +0000 Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 38SA0hs9030409; Thu, 28 Sep 2023 11:44:34 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3tad223dw5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Sep 2023 11:44:31 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 38SBiUej20906534 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Sep 2023 11:44:30 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 08B152004D; Thu, 28 Sep 2023 11:44:30 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C53E12004B; Thu, 28 Sep 2023 11:44:28 +0000 (GMT) Received: from [9.152.222.232] (unknown [9.152.222.232]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 28 Sep 2023 11:44:28 +0000 (GMT) Message-ID: Date: Thu, 28 Sep 2023 13:44:25 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH] test-container: Use nftw instead of rm -rf Content-Language: en-US To: Adhemerval Zanella Netto , libc-alpha@sourceware.org References: <20230927192013.2071605-1-adhemerval.zanella@linaro.org> <6a83644f-98e9-5329-a8e9-c8a731e716ac@linux.ibm.com> <64a68058-0371-40fd-b65d-369f53539e35@linaro.org> From: Stefan Liebler In-Reply-To: <64a68058-0371-40fd-b65d-369f53539e35@linaro.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: gxejgNlEiPQeZPeEjva6ybj0Nc5QS4_i X-Proofpoint-ORIG-GUID: gxejgNlEiPQeZPeEjva6ybj0Nc5QS4_i X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-09-28_09,2023-09-28_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1011 priorityscore=1501 spamscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 phishscore=0 lowpriorityscore=0 adultscore=0 malwarescore=0 mlxscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2309280098 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,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 13:11, Adhemerval Zanella Netto wrote: > > > 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 ;) ? Yes, the patch is fine. Reviewed-by: Stefan Liebler > >>> 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. */ >>