Message ID | e2a6e000b123c4e5ddacfce1511a364b509b9ea1.1618301209.git.szabolcs.nagy@arm.com |
---|---|
State | Committed |
Commit | d2b997c7172e9a00895a9deb379f8782fbd2e36f |
Delegated to: | Adhemerval Zanella Netto |
Headers |
Return-Path: <libc-alpha-bounces@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A082E393C867; Tue, 13 Apr 2021 08:18:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A082E393C867 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1618301920; bh=yyIM7j/3Zh3VF5KEnLq2eX6J9U7OSx0D/qsSFCiHiqI=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Li3hhyx7hofB97licSB3pZDbUfxYdE3ODxzJPy+rZ8RXiCZeR5iBqBtD3Rk3ge75k lGOwpb6N/K7rUaOJUP3PnPgXrgeqFJ0zRbavivetPtlovRYHmSLF8WebLvBLQ/lbg0 /VzIid/qLa3Rx7aEODn0Ws71g9DM2WoRUMHoDehM= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-eopbgr140040.outbound.protection.outlook.com [40.107.14.40]) by sourceware.org (Postfix) with ESMTPS id 88384393C855 for <libc-alpha@sourceware.org>; Tue, 13 Apr 2021 08:18:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 88384393C855 Received: from AM5PR0202CA0021.eurprd02.prod.outlook.com (2603:10a6:203:69::31) by DB9PR08MB6748.eurprd08.prod.outlook.com (2603:10a6:10:2a7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.18; Tue, 13 Apr 2021 08:18:35 +0000 Received: from AM5EUR03FT010.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:69:cafe::53) by AM5PR0202CA0021.outlook.office365.com (2603:10a6:203:69::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.16 via Frontend Transport; Tue, 13 Apr 2021 08:18:35 +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 AM5EUR03FT010.mail.protection.outlook.com (10.152.16.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.17 via Frontend Transport; Tue, 13 Apr 2021 08:18:35 +0000 Received: ("Tessian outbound 82c2d58b350b:v90"); Tue, 13 Apr 2021 08:18:35 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 8aae81b631ee2eb6 X-CR-MTA-TID: 64aa7808 Received: from 9e609ae978dd.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id A8D37FD4-0817-4407-A185-FAC352E16A9F.1; Tue, 13 Apr 2021 08:18:13 +0000 Received: from EUR03-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 9e609ae978dd.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 13 Apr 2021 08:18:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LB7E1/tW7sRU2NNtcL9OvLLZ3+tNaL70zsWsSGAoAWiw7wbmNM7fyfqfGXSbB0CMRF5iVZtUfiCcG4o6s77N6EGcEolPSia6k60BUCjUSm9WlX2KVUjYBRI0mKigeIGh07T7BROrmn4t93FNBTcp97HIp2s/CUpUBX8luR9MJbN5wzPumh6H11zape1sykTpW/U9d/opgap20voV1NQdBSQ8QaaiGRUwZPuVjUtq7fvfPvwdbDfoY0PxaUU8GhRo539zG4I4f6xVOdBe9GflRLCMNpduAzYduNHeIYZ1ctaV8UUETu9I5xdzHSGOTQW0xNbjNIK3Du0BP4SmpsF8Kw== 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=yyIM7j/3Zh3VF5KEnLq2eX6J9U7OSx0D/qsSFCiHiqI=; b=P/wM80WeY4ohBcS2Uw9IUVXMPVJxErK7mmrMHv4EOK1KV+EWIdXoEamndvBFCid6IW14r+tXTF/EPCHPNAnZguXrGSXFKvmlwCgegH0PeXxNvHv/BQHo5S0l6q9RHjw0UPDhyUnORYBoaVyN/O48oJuB5dJYl8ytjlYnbwKRReroFzk9NcGpjD4jlWGpN0Tbqha0AEA767QL+t6FUxOzKhl1hO+FpJLXQ/rKBbi80WdXm989i1h5BJ/PB8V2d2vyJ9LN3G1dWBCfL2blmSG3tAdzXncf9BzDJhhTn9CHQjncFk+bHfibSqURF2scfiJF/4I//amLzObhM0+CATWuEA== 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: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=arm.com; Received: from PA4PR08MB6320.eurprd08.prod.outlook.com (2603:10a6:102:e5::9) by PAXPR08MB6541.eurprd08.prod.outlook.com (2603:10a6:102:15a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.19; Tue, 13 Apr 2021 08:18:11 +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.022; Tue, 13 Apr 2021 08:18:11 +0000 To: libc-alpha@sourceware.org Subject: [PATCH v2 01/14] elf: Fix a DTV setup issue [BZ #27136] Date: Tue, 13 Apr 2021 09:18:00 +0100 Message-Id: <e2a6e000b123c4e5ddacfce1511a364b509b9ea1.1618301209.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <cover.1618301209.git.szabolcs.nagy@arm.com> References: <cover.1618301209.git.szabolcs.nagy@arm.com> Content-Type: text/plain X-Originating-IP: [217.140.106.55] X-ClientProxiedBy: SN7PR04CA0165.namprd04.prod.outlook.com (2603:10b6:806:125::20) To PA4PR08MB6320.eurprd08.prod.outlook.com (2603:10a6:102:e5::9) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (217.140.106.55) by SN7PR04CA0165.namprd04.prod.outlook.com (2603:10b6:806:125::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.17 via Frontend Transport; Tue, 13 Apr 2021 08:18:10 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 98b75176-8f6d-43a7-329a-08d8fe54bbad X-MS-TrafficTypeDiagnostic: PAXPR08MB6541:|DB9PR08MB6748: X-Microsoft-Antispam-PRVS: <DB9PR08MB674880D4DFB116839ACECF6CED4F9@DB9PR08MB6748.eurprd08.prod.outlook.com> x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:7219;OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: q4B62CaUioE+S5hAqjjyCOx9tqG0hDmkBX2oxXeYIF6G8WFDn0xnvM7ID5nCDDRKN09aSLylojWK9vMDUMn+kXO6aib1jzMsr71qT3fDh+zYvMLIPI/Xkq/KTEvupjCyiScvdjIfZUIaACyRzMiAQzHm2KcGf/qb3DY0vuWf54nPhWiIrSTCj/Lyq+Yima57oFxSBqpMfqvhdju4sSHig8qrdIh1VqclnCvLVUr0aAoHALtRx8zL8JBSy9sFPJrcVOFWwLHHosEJaD45EghxqsT/AuvbW3L5jsaCO9zoOfI9FqoVZN/vZKImhJGhjrN6Ir9zR3BMosiIFYXqRqEnX5S/hdlep+Xutplp5Ok+/kKgbK7niVQArJ+Tr87KAwI8yT7JDI2htJDL7LfJHdgKKUbdGUrEzpMlh1h5gCWdTdopjDzyJm9V7WISfLEesKPwnuhfT1ThO/h54CwQcVp5Up++7qJcHwKbZGI+LGx22XTAmj3Pb6W/mk7iOJnO2XFO9xMVaPumYsMzsga+TqBIFGNCUaTWRFD7gerjPvWv0noDOtlf4KS3gwJmJpoDeZasXFjHe7OCTCYwD+zqpacYJXdE1uQoupRn2yg097aLyQJrrvIU36SNY2P3rJue/OhtHZH4M90NbAxLQPyWDwRU8Bnpl49hWoOkpc3noXqpJY+/ba+3NRYmaGRiieoMeWBA 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)(396003)(376002)(346002)(366004)(39860400002)(136003)(16526019)(316002)(8936002)(478600001)(52116002)(83380400001)(26005)(186003)(6512007)(69590400012)(6916009)(66946007)(8676002)(2906002)(36756003)(86362001)(66476007)(6506007)(44832011)(5660300002)(38100700002)(6486002)(6666004)(66556008)(38350700002)(4744005)(956004)(2616005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: ISqgv40STjRmad4PkoS2oEShpNa6FHfDpjQ0dYBRsjNr1N+KLUw7otLV+cV1bi9dqi2mrM6SBc7Q2cEWVpa1gIKE6kmf25hY0SJpWnAg/goIyrh00M8MFSDyKlP8a16raYU3473glT9LWwwg+zMLL/xrLUGfGJSLkRCJVwHvriRCe0pOtzaPTPvMVLWg+YB7nzmmOgD/pUu3dxprCLPzLslZngudZ2f1JGovhLx0nLuo1rPxJ2vIJTgSoG3PqlcJeyFfH5oSnJeWpco5/bs/DsLecMmUx4WEGTMun27xyc6bpjvMtAD64Xj/5Z6/Diy/j7Qwdiqj+OSSBVvT4jvKIuO78wTFBOf7kBHWC+5t21CFHacgpbhsRn67gorK1n659xvPA+5vnFD26c0HX5q6BhdTBixbTYZzQ23yzfPU55HHf8wKUw2GVTT3KBwK9sWEWq8Qcq+q2SlTYaCastlfzUAs/dGokJdBCPnNjT6Zt7CNvF9rGXE46e7lYiK9UvEhRDuYnjemLXeeAb4nwS1ZTnWSDJTWTIidWfiSp9yIQr40x4WheFDmWkS2rRu+rwRH4bNZskw2XPAgNNnpT27KqhIai/4OCHvz+CZduuiYQHaJzeIqzTSDcqwb30dWE/MjwmkR9LA1OBJ6yI5qbPJMuxYKwbHVzOkKtx09uGbTRAtO5UKangSJsRgcKmnUORWUEPxhkjlDXuIyKQJVIj0GABHEPArlFt53kth6jpZCgy+uYngKFulyLleUJMA4PZYYfRxujTLJOjsj5npheKOa76nJDZBysl0u8zbSKEGiIT1R8dVA8mScUaVNkDGj73u6XmgrA93R0HD19+3LXpTJdAwXQV6DhPc29fL2cfqTR1e9GzKFZFZJlztP7EEQiMj/e0lvrhn4yfyMeNuGNVl5yyhpttuggKrvc3NcigJZDq+vuXWgt+8ZhHWYO3zJ6NBkMd9GSvSfBsqvZWGnyAfdyJmM+UahgdaP/FFtux/k8YjGfygHU+hsVsDMbu3+AI38ezwPA/3kPPAOQszzJGy/mdLIKmTzw+AZvJID26fVCIZ3MDdlELgRjQVUof9hhAMOOdy9j4A4jOeqVKbTbn3UG5RZqH20Po+8hIqmQRh1NIY5FeeiP4PPAoL0hsBqg8H26yuEk6OR/droDOP7x0EeRegCBcUE8T0zTupw5Y3LA6K1wyoQl1ShhziSTP86XJNOYZVb6MJeZstCM0rowBOHuWdrVzVgIMEHJ1W7TqrfYZ19Z4VrUr0QMbqQE3And8fC2IcdLyxwBL0GCFamfNAEkBfObXerWiXHZR9d2LoKYHEwm7mswX14/O6xW0gjS1Be X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6541 Original-Authentication-Results: sourceware.org; dkim=none (message not signed) header.d=none; sourceware.org; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT010.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 6dd5fcf4-c8aa-498b-cac4-08d8fe54ad38 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CSKY7l01L/IKbWDKjMJ1+uSP6NrfWjiw9jbZ3YPqQpL2JYnIEYVRYHcs+ZdU2vNFaN+D1raKrC240kTJV2Gj8w5WKRs5F5Q6V2Ui8hT3ACnX3VLUvvRCwN2+LyQ1rBYosA32M3cpyyqzlD2oWthjkx9WC3xoUGPZgdZkBpqCpRbcSiH76yzX4tnhgdkt+YDMtLKL8oC0DnIVe7fTeL5tHC+xuzKXqjJEQi7skpIEJbowrc3Cg2F0z61fRNW+ahIA1Thyp2xid1IzfwvLjL2rVqtOADZmZWVW6coe+9RWN9CuwAMk7biqQLgKhi9JYvAXulWi88LxJ6zlWO6P1bEv7vyb0hET65uKqPRvtIFscBYbzCMu6KSLYU4upPLjiqds3LNXSrq9/ZNnf8oP1dw19AgpSUG2suUVOZvVhym3NtuvuEfocU5Fags+dnqsRRfX42N4khdDgxVMUPkagCfiDV8kKYXyP4+BRw/fDsK4JorLNt+qcfPtL2LbZB8Xi88/ejwFvvW5uPgiNKSPeoEEFCeapeDS47JNsXDGwl65nXdtxG0twZTQm8RcA5pVBrOifvInSTO+lujlAeLq/HF8JgVro8em9VosVQWz54Y6OiohfPI8n3sKFKMsyYeowqsbPp5meel1D49j718F2/F0l7Hv62o0Y2RJrm71j3TedF77bBeeOZ5EIuuPxI3yd9uR 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)(39860400002)(396003)(136003)(376002)(346002)(46966006)(36840700001)(336012)(2906002)(316002)(478600001)(956004)(70586007)(5660300002)(82310400003)(356005)(2616005)(36860700001)(44832011)(81166007)(186003)(6916009)(83380400001)(6506007)(8936002)(82740400003)(26005)(4744005)(6512007)(36756003)(8676002)(69590400012)(86362001)(47076005)(6486002)(70206006)(16526019)(6666004); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2021 08:18:35.1713 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 98b75176-8f6d-43a7-329a-08d8fe54bbad 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: AM5EUR03FT010.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB6748 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 <libc-alpha.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/libc-alpha/> List-Post: <mailto:libc-alpha@sourceware.org> List-Help: <mailto:libc-alpha-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=subscribe> From: Szabolcs Nagy via Libc-alpha <libc-alpha@sourceware.org> Reply-To: Szabolcs Nagy <szabolcs.nagy@arm.com> Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" <libc-alpha-bounces@sourceware.org> |
Series |
Dynamic TLS related data race fixes
|
|
Commit Message
Szabolcs Nagy
April 13, 2021, 8:18 a.m. UTC
The max modid is a valid index in the dtv, it should not be skipped.
The bug is observable if the last module has modid == 64 and its
generation is same or less than the max generation of the previous
modules. Then dtv[0].counter implies dtv[64] is initialized but
it isn't. Fixes bug 27136.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
---
elf/dl-tls.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Apr 13 2021, Szabolcs Nagy via Libc-alpha wrote:
> The max modid is a valid index in the dtv, it should not be skipped.
Does this check in _dl_allocate_tls_init need to be adjusted as well?
/* Check if the current dtv is big enough. */
if (dtv[-1].counter < GL(dl_tls_max_dtv_idx))
Andreas.
The 04/13/2021 10:36, Andreas Schwab wrote: > On Apr 13 2021, Szabolcs Nagy via Libc-alpha wrote: > > > The max modid is a valid index in the dtv, it should not be skipped. > > Does this check in _dl_allocate_tls_init need to be adjusted as well? > > /* Check if the current dtv is big enough. */ > if (dtv[-1].counter < GL(dl_tls_max_dtv_idx)) no, that seems fine because counter is not the dtv length but the maximum valid index (dtv[dtv[-1].counter] is valid, the dtv array size is counter+2 to accomodate for dtv[-1] and [0])
On Apr 13 2021, Szabolcs Nagy wrote: > The 04/13/2021 10:36, Andreas Schwab wrote: >> On Apr 13 2021, Szabolcs Nagy via Libc-alpha wrote: >> >> > The max modid is a valid index in the dtv, it should not be skipped. >> >> Does this check in _dl_allocate_tls_init need to be adjusted as well? >> >> /* Check if the current dtv is big enough. */ >> if (dtv[-1].counter < GL(dl_tls_max_dtv_idx)) > > no, that seems fine because counter is not the dtv length but > the maximum valid index (dtv[dtv[-1].counter] is valid, the > dtv array size is counter+2 to accomodate for dtv[-1] and [0]) Since both dtv[-1].counter and GL(dl_tls_max_dtv_idx) are indexes, not lengths, I would expect them to be compared with <=. Andreas.
The 04/13/2021 12:22, Andreas Schwab wrote: > On Apr 13 2021, Szabolcs Nagy wrote: > > > The 04/13/2021 10:36, Andreas Schwab wrote: > >> On Apr 13 2021, Szabolcs Nagy via Libc-alpha wrote: > >> > >> > The max modid is a valid index in the dtv, it should not be skipped. > >> > >> Does this check in _dl_allocate_tls_init need to be adjusted as well? > >> > >> /* Check if the current dtv is big enough. */ > >> if (dtv[-1].counter < GL(dl_tls_max_dtv_idx)) > > > > no, that seems fine because counter is not the dtv length but > > the maximum valid index (dtv[dtv[-1].counter] is valid, the > > dtv array size is counter+2 to accomodate for dtv[-1] and [0]) > > Since both dtv[-1].counter and GL(dl_tls_max_dtv_idx) are indexes, not > lengths, I would expect them to be compared with <=. but the code is /* Check if the current dtv is big enough. */ if (dtv[-1].counter < GL(dl_tls_max_dtv_idx)) { /* Resize the dtv. */ dtv = _dl_resize_dtv (dtv, GL(dl_tls_max_dtv_idx)); in case of == there is no need to resize: the dtv array is large enough for the observed GL(dl_tls_max_dtv_idx).
On Apr 13 2021, Szabolcs Nagy wrote: > The 04/13/2021 12:22, Andreas Schwab wrote: >> On Apr 13 2021, Szabolcs Nagy wrote: >> >> > The 04/13/2021 10:36, Andreas Schwab wrote: >> >> On Apr 13 2021, Szabolcs Nagy via Libc-alpha wrote: >> >> >> >> > The max modid is a valid index in the dtv, it should not be skipped. >> >> >> >> Does this check in _dl_allocate_tls_init need to be adjusted as well? >> >> >> >> /* Check if the current dtv is big enough. */ >> >> if (dtv[-1].counter < GL(dl_tls_max_dtv_idx)) >> > >> > no, that seems fine because counter is not the dtv length but >> > the maximum valid index (dtv[dtv[-1].counter] is valid, the >> > dtv array size is counter+2 to accomodate for dtv[-1] and [0]) >> >> Since both dtv[-1].counter and GL(dl_tls_max_dtv_idx) are indexes, not >> lengths, I would expect them to be compared with <=. > > but the code is > > /* Check if the current dtv is big enough. */ > if (dtv[-1].counter < GL(dl_tls_max_dtv_idx)) > { > /* Resize the dtv. */ > dtv = _dl_resize_dtv (dtv, GL(dl_tls_max_dtv_idx)); > > in case of == there is no need to resize: the dtv array is > large enough for the observed GL(dl_tls_max_dtv_idx). I think it would be easier to understand if the condition would be written as (GL(dl_tls_max_dtv_idx) > dtv[-1].counter). Andreas.
diff --git a/elf/dl-tls.c b/elf/dl-tls.c index dd76829e74..79b93ad91b 100644 --- a/elf/dl-tls.c +++ b/elf/dl-tls.c @@ -590,7 +590,7 @@ _dl_allocate_tls_init (void *result) } total += cnt; - if (total >= GL(dl_tls_max_dtv_idx)) + if (total > GL(dl_tls_max_dtv_idx)) break; listp = listp->next;