From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50084.outbound.protection.outlook.com [40.107.5.84]) by sourceware.org (Postfix) with ESMTPS id 143CC389681A for ; Wed, 7 Apr 2021 07:57:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 143CC389681A Received: from AM5PR0601CA0046.eurprd06.prod.outlook.com (2603:10a6:203:68::32) by HE1PR0801MB1915.eurprd08.prod.outlook.com (2603:10a6:3:4f::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.28; Wed, 7 Apr 2021 07:57:49 +0000 Received: from AM5EUR03FT012.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:68:cafe::24) by AM5PR0601CA0046.outlook.office365.com (2603:10a6:203:68::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.17 via Frontend Transport; Wed, 7 Apr 2021 07:57:49 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; sourceware.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;sourceware.org; dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT012.mail.protection.outlook.com (10.152.16.161) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.17 via Frontend Transport; Wed, 7 Apr 2021 07:57:48 +0000 Received: ("Tessian outbound 82c2d58b350b:v90"); Wed, 07 Apr 2021 07:57:48 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: c2fe0c0ca2bf6ebe X-CR-MTA-TID: 64aa7808 Received: from c77403269eba.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 9CD22836-BE31-48E4-BDFE-BD54C4466B39.1; Wed, 07 Apr 2021 07:57:41 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id c77403269eba.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 07 Apr 2021 07:57:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GVXgrx8Hc53oXeOtlkQeCCTWWHrIaw0D8xtoGc40J8chmbZSGL/PAPo343BuoHTWXl+KOWBDNB2uXkC3vXEO4ONJVe+6MtCwOzZlL6TIMa+mu0VhNJj8TxWkIK3L6axrSBo2NdiQYfIJs3wLFmRzQo9WkXUNuXzFENrl5aleZnOuKZioIUn1lpX/z7vgeTHNJ5Mj5dYmREzPndthj/F2tlgWIB1B439f+qbWvwXXttrZxqKyzJT0CN85ua0uDtJj3wEPhKi29xw4YUKwsmEkMNNgmSlGMn4iZf90k/qjY1xhs7DVNMpAUWFP13zUd4Y+SHbSl+cO+Yu7WW4as/jsqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+Wa1R7BmIP3W0jM1URHXuaZxEU5uQdeGNUCB380Q6S8=; b=UjspgcExc8a3TkWpXCAkqFqUnRvl+gdrTJALnfXq0eUnljuF1UQS6xcOuGynWu1fxYkWPPJY4aOUzK4XCp/e7KkQ6dNP5T+mPubn7Dzc9P6trHxsWLMTXQDczibuL5ML8K2iUX1sAZCOGP6x0Ms+euo7LB+ohmmYfOQuWinL11F+UIT6Io4q9RgRD+77AqLRtRyXq9ZaZE4djVXF8x1ny2dXpJDty18Vjqf8+hPX+3TfQwRr/srPQaONDfmzxOXTxrMzfJRanSITLOH1Dt9jieiDJHZd5YjQhgqjZn5NL2JAfOsbXPYZ5otO3WFcr4vjHxICUGmXnfTLoTAbhlUxdA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none Authentication-Results-Original: linaro.org; dkim=none (message not signed) header.d=none;linaro.org; dmarc=none action=none header.from=arm.com; Received: from PA4PR08MB6320.eurprd08.prod.outlook.com (2603:10a6:102:e5::9) by PAXPR08MB6784.eurprd08.prod.outlook.com (2603:10a6:102:139::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.29; Wed, 7 Apr 2021 07:57:39 +0000 Received: from PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::c99f:671d:bb2c:f20b]) by PA4PR08MB6320.eurprd08.prod.outlook.com ([fe80::c99f:671d:bb2c:f20b%7]) with mapi id 15.20.4020.017; Wed, 7 Apr 2021 07:57:39 +0000 Date: Wed, 7 Apr 2021 08:57:37 +0100 From: Szabolcs Nagy To: Adhemerval Zanella Cc: libc-alpha@sourceware.org Subject: Re: [PATCH 06/15] elf: Fix comments and logic in _dl_add_to_slotinfo Message-ID: <20210407075735.GO23289@arm.com> References: <068770faf123b7c227f5f1e130812f7976e74cef.1613390045.git.szabolcs.nagy@arm.com> <20210406154828.GM23289@arm.com> Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) X-Originating-IP: [217.140.106.54] X-ClientProxiedBy: LO4P123CA0114.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:192::11) To PA4PR08MB6320.eurprd08.prod.outlook.com (2603:10a6:102:e5::9) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from arm.com (217.140.106.54) by LO4P123CA0114.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:192::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.27 via Frontend Transport; Wed, 7 Apr 2021 07:57:39 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8c866481-84a5-4df0-92a8-08d8f99ad64f X-MS-TrafficTypeDiagnostic: PAXPR08MB6784:|HE1PR0801MB1915: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:10000;OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 68gGcp+NtiCds8lGNbI047zCknHHvINvTNALC3Bpnw6v8qQ/t+bt2+r/4wBLwICsqoF6hIds+y7wQjKp5+QU06nXiRsGhv5YYRuHC+lmJtoFh/7eGKjqyMFH9l8XKqZ7q9lRGQLtMIQELugJvGW61CJctpjYE7hL55LQp1z0jNmJCb7xqIONtq/0Irclx2GXkV6IuMTBySJls/vcrAIMa+PdVv7+x6V+zAx4rUm+StHN+5yicEQuqzwpyMhYvZJMIkKGPAthUE9kgiqPvokJhKCHVRs4GQqhcofvO55qRGI6gtXX1d4wTadfT4n2y1K8rZq/kmdUBEQleGF/N7Wg4Kdx+p9xfuvszLWsCbpoeK/wgztadH0YGI5GxurjsioJlBUupAlLUg71xijTVx/rIYKJnV24jDmtIoXQCNeI16wwMkhuxq1RbC/JgoYLjhQHGLfNw8F1mTjLHO7eBZjsuIlz4ekAvs/Lx/BjGeNcb0GxBf8brvHPIakj9wR/uJ/Djx21hn+z53EvnaNkpntl2iHRcGsD5msPWJEGOJg51ogx/3tg4ptVPjo8OEhr3k779Q8059xLZ81CuS4mt35YY2KtgsfX4ZSD4bESTw1SIGSTbFMZGjpUDd0z3qzHcBnjtHKyVGm4X1DD/eqK0p5LuXxVb2QwA0tm1Uf87xuVWHpTcgJUS51F9tbk8xBUOwCM X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PA4PR08MB6320.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(396003)(39860400002)(346002)(376002)(366004)(33656002)(44832011)(2906002)(53546011)(38350700001)(8886007)(1076003)(5660300002)(86362001)(4326008)(36756003)(956004)(2616005)(26005)(316002)(52116002)(7696005)(83380400001)(55016002)(66556008)(8676002)(66476007)(6916009)(66946007)(186003)(478600001)(8936002)(38100700001)(16526019); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?b3J5aFAwWDg4dm5OK28xRGoyZXg0RjRkUXFNbmIxem4yaGlROXVyUmdGdDBK?= =?utf-8?B?TTVMOEppMDRyemFUL2dodnJVOExLQXlURjVVUUxzSU9lR0thd3RrczhBY2NC?= =?utf-8?B?SVZwNzlJNG01NktVY2wyWndUNllFUjRwdWsyWnJRSHh3VnUvQjdrOVVncHpx?= =?utf-8?B?ZFg4M0V0SHVBMFJuZ1kyZ0FscVcrMGRQcml4cmVnSHl4a1M5NVNITGdEdzFj?= =?utf-8?B?WXkvNG8rNWl5Q0dQaFNwblRvbGE5aithY2pyRlh1UzdTOXp4RHNrZWUwOGhu?= =?utf-8?B?UWV6NzhoRS8xZGxRaTc3eEpHVElZK0ZaVE1FSU9sL09SRjhQZkgwQlQ5ejgx?= =?utf-8?B?TEZTSlJFNkpkTFRuK2FMS1NyMHBpRXprVTRnTmVJcHZiQ2FPQkJ5UElvcWtD?= =?utf-8?B?czVsQVZxTjNRbDgvRVpIRnJrUndQaytpZ3RMZ2Jhc1dzUDNjVXJGYyt6dmNh?= =?utf-8?B?UmdVdlNGTFhhM0xHUHpTSzhFU3JWZlpuZDZaSjJlVmd1K1lBREVQeXVLczRF?= =?utf-8?B?SWVGL0xLbDFqWFpqRmRZZjJzY2NzaXlSV0hDdnp2cHZGSnYxVGZaK0ZveXp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wxbk5PRitSWjV2WHhzcmRWNmVE?= =?utf-8?B?OWZyLzZ2Y2hSaEJiNG5FZngwUm5tZFQyaDY3c3lzbUpJdkhKQUJsYTZMaytK?= =?utf-8?B?MkZWcGtjT1NmT01wanhYaGJsU0lBb1JHWm1TYi9Ea01Nam5MQm95U0pkL0JH?= =?utf-8?B?cTBaWGNyNE45U01NOGtUVnV1dkgzaHBtSDRIRERIZ2duZDN0LzViWWRCb3VR?= =?utf-8?B?Q2dDTWhZWVROMVl5ME4zNzdZR2dKYnprSTJjNGZvcFB2Q1l0UVJTVzZkSFdJ?= =?utf-8?Q?e4uVqU1I6OCq6+K9t7ECHV6k6Y8H1T+ajXMPQtp?= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6784 Original-Authentication-Results: linaro.org; dkim=none (message not signed) header.d=none;linaro.org; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT012.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: ea17fdf2-9730-4915-be24-08d8f99ad07d X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4PY9MCyWSteMGEZGLVr+6uqGwR9nxMIHCNwOgk+KB+92wEiuXC6LY3XhWfXtv5kvPD1g//YoFaQQWZNSnuK1jvVCUx7RNYXqrgDq+RpO8ipB8mJYTsZivT96AoiNTUJgli8bPPT6xyKxjKo3cV5QAnbd0e0SrstM97maOUNEJ99ybLJ/gbj7TQkhserma4XJnjTYEZ9FYoHYPX5efhoUYRgDjueBlquxZQkTueAFPK81f7u3Fv1K/RfQAGRWi2CfJ+ypExonPAx5iSdRBROA4TJQmpW/5sI1s7nkX8ZWVVq9R9V5Z4oQ6VKoJUjUw/jD1jatG/cJs8TmYybES2skmun1yai888AIudmG4OCPPO2it/wWHQhSxwgLWdiO6S3gS96L7/E5KovC5xJHpYRnNKO+XpbtnS1yQnJZDoAYtCqQVLiDIabA0Ds0+BT/f7RO+50yHBu186yrJ6Kv9zswb5gAkCyarjv8p0NBGwqGMUgyOZl9wbNuZpMniue1DqqYhbIFT3GyFg1T6iE3NA9tpLpM42vSkuMroioEaAgHB0lRFPjqY9Ugo38IvZ1UmbLTFKTEleS4qcEyfr5/SYJcxiVhGa2M33ZktAD8OhjmCm1RqQji+lEsvtJ2/ABy3dGrvoudumTvf9BkXdUHmQsUCxnhO8hPSPU/9K85yMQ7MDQ= X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(4636009)(136003)(376002)(39860400002)(396003)(346002)(36840700001)(46966006)(6862004)(4326008)(2906002)(8886007)(82740400003)(70586007)(81166007)(478600001)(82310400003)(86362001)(33656002)(83380400001)(356005)(36860700001)(47076005)(8936002)(8676002)(53546011)(956004)(2616005)(44832011)(36756003)(55016002)(336012)(16526019)(7696005)(186003)(1076003)(26005)(5660300002)(316002)(70206006); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Apr 2021 07:57:48.8184 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8c866481-84a5-4df0-92a8-08d8f99ad64f X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM5EUR03FT012.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0801MB1915 X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Apr 2021 07:57:54 -0000 The 04/06/2021 14:47, Adhemerval Zanella wrote: > On 06/04/2021 12:48, Szabolcs Nagy wrote: > > The 04/02/2021 17:50, Adhemerval Zanella via Libc-alpha wrote: > >> On 15/02/2021 08:59, Szabolcs Nagy via Libc-alpha wrote: > >>> From: Szabolcs Nagy > >>> > >>> Since > >>> > >>> commit a509eb117fac1d764b15eba64993f4bdb63d7f3c > >>> Avoid late dlopen failure due to scope, TLS slotinfo updates [BZ #25112] > >>> > >>> the generation counter update is not needed in the failure path. > >> > >> It is not clear to me from just the commit reference why it would > >> be safe to remove the GL(dl_tls_generation) update on > >> _dl_add_to_slotinfo. > >> > >> The dl_open_worker calls update_tls_slotinfo which in turn call > >> might call _dl_add_to_slotinfo *after* the demarcation point. Will > >> it terminate the process? > > > > in that commit the logic got changed such that allocations > > happen before the demarcation point in resize_tls_slotinfo. > > > > this is the reason for the do_add bool argument in > > _dl_add_to_slotinfo: it's called twice and the first call > > with do_add==false is only there to ensure everything is > > allocated before the demarcation point (so module loading > > can be reverted, no need to bump the generation count). > > > > i guess this is not visible by just looking at the > > _dl_add_to_slotinfo code. > > Right, so if I reading correctly once _dl_add_to_slotinfo (..., true) > is called by update_tls_slotinfo, the malloc that create a new > dtv_slotinfo_list won't be called (since it was already allocated > previously) since the entry was already pre-allocated and thus the > search part at line 978-987 will find. Is that correct? yes if you have an idea how to make things clearer let me know. > > > > note that adding some asserts to ensure there is no allocation > > when do_add==true does not work: rtld uses the same api, but > > without the do_add==false preallocation step since at startup > > time allocation failure is fatal anyway. > > Right, the _dl_signal_error will trigger a fatal_error since > lcatch won't be override yet. > > Thanks for the explanation. > > > > >>> --- > >>> elf/dl-tls.c | 11 +---------- > >>> 1 file changed, 1 insertion(+), 10 deletions(-) > >>> > >>> diff --git a/elf/dl-tls.c b/elf/dl-tls.c > >>> index 79b93ad91b..24d00c14ef 100644 > >>> --- a/elf/dl-tls.c > >>> +++ b/elf/dl-tls.c > >>> @@ -998,16 +998,7 @@ _dl_add_to_slotinfo (struct link_map *l, bool do_add) > >>> + TLS_SLOTINFO_SURPLUS * sizeof (struct dtv_slotinfo)); > >>> if (listp == NULL) > >>> { > >>> - /* We ran out of memory. We will simply fail this > >>> - call but don't undo anything we did so far. The > >>> - application will crash or be terminated anyway very > >>> - soon. */ > >>> - > >>> - /* We have to do this since some entries in the dtv > >>> - slotinfo array might already point to this > >>> - generation. */ > >>> - ++GL(dl_tls_generation); > >>> - > >>> + /* We ran out of memory while resizing the dtv slotinfo list. */ > >>> _dl_signal_error (ENOMEM, "dlopen", NULL, N_("\ > >>> cannot create TLS data structures")); > >>> } --