From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by sourceware.org (Postfix) with ESMTPS id 783AC3858D38 for ; Sat, 5 Nov 2022 02:34:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 783AC3858D38 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=huawei.com Received: from canpemm500006.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4N41mJ4ybLzmVh2; Sat, 5 Nov 2022 10:34:40 +0800 (CST) Received: from [10.67.110.83] (10.67.110.83) by canpemm500006.china.huawei.com (7.192.105.130) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Sat, 5 Nov 2022 10:34:47 +0800 Subject: Re: [PATCH] elf/tlsdeschtab.h: Add the Malloc return value check in _dl_make_tlsdesc_dynamic() To: Szabolcs Nagy CC: , , , References: <20221104093000.25169-1-nixiaoming@huawei.com> From: Xiaoming Ni Message-ID: Date: Sat, 5 Nov 2022 10:34:47 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.0.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.110.83] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500006.china.huawei.com (7.192.105.130) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_STATUS,NICE_REPLY_A,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 2022/11/4 19:00, Szabolcs Nagy wrote: > The 11/04/2022 17:30, Xiaoming Ni wrote: >> Check the return value of malloc based on the function header comment of >> _dl_make_tlsdesc_dynamic(). If the return value fails, NULL is returned. >> >> Signed-off-by: Xiaoming Ni > > note that allocation failure is not recoverable here: > the caller cannot really deal with NULL so tls access > will crash. _dl_make_tlsdesc_dynamic() is called by "void elf_machine_rela()" Whether to add _dl_error_printf() to elf_machine_rela() when _dl_make_tlsdesc_dynamic() returns NULL ? Or change "void elf_machine_rela()" to non-void ? > > i think the patch is good, but it will only help if > the failure is propagated to _dl_relocate_object and > handled in dlopen by returning an error. > > let me know if you don't have commit access, then i > can commit it for you. > I don't have permission to submit, thank you for your review and help. > Reviewed-by: Szabolcs Nagy Thanks Xiaoming Ni > >> --- >> elf/tlsdeschtab.h | 2 ++ >> 1 file changed, 2 insertions(+) >> >> diff --git a/elf/tlsdeschtab.h b/elf/tlsdeschtab.h >> index 8c02e45a49..82733159e3 100644 >> --- a/elf/tlsdeschtab.h >> +++ b/elf/tlsdeschtab.h >> @@ -110,6 +110,8 @@ _dl_make_tlsdesc_dynamic (struct link_map *map, size_t ti_offset) >> } >> >> *entry = td = malloc (sizeof (struct tlsdesc_dynamic_arg)); >> + if (! td) >> + return 0; >> /* This may be higher than the map's generation, but it doesn't >> matter much. Worst case, we'll have one extra DTV update per >> thread. */ >> -- >> 2.27.0 >> > . >