From patchwork Wed Jun 8 16:28:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 1640805 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=QHCLzhJU; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LJCN21Xkfz9sFk for ; Thu, 9 Jun 2022 02:28:49 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6DF233850854 for ; Wed, 8 Jun 2022 16:28:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6DF233850854 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1654705724; bh=57a491ikES8XRH5FvxbGe02Xs/snPdM5cFNUKuLWZeg=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=QHCLzhJUx5VNTgpOwbgXLhx1/9DcKJhpn09Sq3m+48sOTn2H5xmsKvufMrQnoLS4v RR252JxQVQftTaCAOy2xnCUJ1X1JFN+iBAYxKq+pMp2ZJuJie2R49pDbaf0XqGY7e4 0IjrKK9voxll0nCHsxX9b6el1GAa3hkw0VpbPT+I= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80053.outbound.protection.outlook.com [40.107.8.53]) by sourceware.org (Postfix) with ESMTPS id 014393857BAF for ; Wed, 8 Jun 2022 16:28:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 014393857BAF ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=HaWW3hSfES6nwba+aiaLcGGrWJNtDd1f5FLftNE3i5w7TfzoVUqMVX/VDNEqMJMAMO4t33uC4awvkzyFmwwrCg76UpFd/bbDh+lkdTowHL3lTeU/YcajD/l97q7DR1UwVtEMpuGJat48+SDS8kwb4hIqrs1jA/rDYogEBqxSEG25pUBqE0X0UK8CgEDsvjcH+rpYjT6HsOTxGDz5proTcNNZKLVoInWUP9dhgCExdQv+6k+WXjIf4YmZkGCrUNnQu3MDGJL5IYJjaH3jUa4AZqMEKOpmhDfcp2Id1VG8MOrEgQ0HHIZ1dzBdx3ewoK+yhzwTIIBEvUiRkryFlosU2A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=57a491ikES8XRH5FvxbGe02Xs/snPdM5cFNUKuLWZeg=; b=N1SLieqS4VSvK6Mgv8u47Fw2BnjBzoRRRtIy6afmTJbNj0Atwd2t565M8ie6JdsiZwMyezdj6aDaAVI+mgP/MmtMDgGU7rILWRWiAVcZBu4DvC+KI+di10rVHDZP7vHfdP5impJ68G/BGYX4jZnYWEXXVPtoRdRvmIbpKE4J7UGknS/xccSKBLhWLQtF42GVd+PeTJOylAJuJqh9Byjfgocr7NQXujkgYA1ACE/CcsSHjcNu5S6tF1/NjvfTYzLSyPfLv/DvOfOhUKBIOcKuwDpolktEk1F+RCoKRFdHm9QcyiAhC11mhrKBkv8ukdyV+8HDBaWaCinn/v+OmduuQA== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) Received: from AS9PR05CA0022.eurprd05.prod.outlook.com (2603:10a6:20b:488::16) by DB7PR08MB3082.eurprd08.prod.outlook.com (2603:10a6:5:1d::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.14; Wed, 8 Jun 2022 16:28:23 +0000 Received: from AM5EUR03FT053.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:488:cafe::5e) by AS9PR05CA0022.outlook.office365.com (2603:10a6:20b:488::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.12 via Frontend Transport; Wed, 8 Jun 2022 16:28:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;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; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT053.mail.protection.outlook.com (10.152.16.210) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.12 via Frontend Transport; Wed, 8 Jun 2022 16:28:23 +0000 Received: ("Tessian outbound e40990bc24d7:v120"); Wed, 08 Jun 2022 16:28:22 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: fa554e05a482ea81 X-CR-MTA-TID: 64aa7808 Received: from 1ab1b1b39483.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 11AE2D4A-9AA3-42E4-829D-43086F90703D.1; Wed, 08 Jun 2022 16:28:16 +0000 Received: from EUR01-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 1ab1b1b39483.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 08 Jun 2022 16:28:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nKRH4ZjDdZSwC/UcSmQD+Vw/hbOdQTDXM7J/mth7fbO+alQ/04+fSy/alXrw5koD1P6HtAUwoOmm0sIQIgq4Hn+Dlz9CiGoP2n77iCspzqgrD1RyQ2YJ/CbTt/ORUzuMlRw+sJS1kBKyQvfHHTc4PA1lYjJsAJhlecqGDWpnM34z8jrqSEEoH3kCM0gaiIiYbwYChpy1qhwMs/77/+0OxOtMJsLeRhfrUGmpIfXJLB4Hm+/jxg34nKuhLJdCcuvsObQqqXYQ0i25gVkjfTId3+/rRUsHn1DKPvcncF4fIzc4QeabVqmeQ+Fv/SdFVpGm/qdOD1SgUtjR9uAY8jFLDA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=57a491ikES8XRH5FvxbGe02Xs/snPdM5cFNUKuLWZeg=; b=UjhFWwuN0Tkms3y6FGKM3LG5elC4PQfqDap55HrGb3ruazg3zD+ciMC5leZxN/SgAzPbDTkyu9boVYuE6QekgBU1aUPlsA4u15WlLbyY0jqqolhm5Ma7TtXLXniThfh4PFdzIx4O1SFik8F7AMAFfVwXI/A1wh3CzD0GOJq7P9guBFAMI6J8dI3QY6mSkm7MiY4J0zf2/2oae/1evsamvVDRJEqHD6SIG0WBYErJT1+XAI8YThw1e6TwbQec1xkizpIYsYTV8x6WvutXZOjIXxhsXeA0994Ez1wouIIpWYjmiNZ7+zJeK9CDwIzfa1E5yapdSoSa7ztCNNKzL4L/3Q== 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 Received: from AM5PR0801MB1668.eurprd08.prod.outlook.com (2603:10a6:203:3c::14) by DB9PR08MB7843.eurprd08.prod.outlook.com (2603:10a6:10:39e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.15; Wed, 8 Jun 2022 16:28:13 +0000 Received: from AM5PR0801MB1668.eurprd08.prod.outlook.com ([fe80::a114:fc7:45f8:421]) by AM5PR0801MB1668.eurprd08.prod.outlook.com ([fe80::a114:fc7:45f8:421%5]) with mapi id 15.20.5314.019; Wed, 8 Jun 2022 16:28:13 +0000 To: 'GNU C Library' Subject: [PATCH] Add bounds check to __libc_ifunc_impl_list Thread-Topic: [PATCH] Add bounds check to __libc_ifunc_impl_list Thread-Index: AQHYe1QpNmX6wklSWkC/hLL+b96mEQ== Date: Wed, 8 Jun 2022 16:28:13 +0000 Message-ID: Accept-Language: en-GB, en-US Content-Language: en-GB X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-MS-Office365-Filtering-Correlation-Id: 7695efe1-21be-4f33-9956-08da496be837 x-ms-traffictypediagnostic: DB9PR08MB7843:EE_|AM5EUR03FT053:EE_|DB7PR08MB3082:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: VPqPVZCQ78QHzvGiTouwmlEUM0GvjSBp/k6FuhzK/8waa2126v1GjSQiYLATwwpE5BzhExn6mr8HgnBs1RnPowxBNKRlXi97Nbo4O5El18T9mbMBqWlJl9Drd9lIRc+KafpRuTgakbhf4xHOxf/YHRTbRUi392S2WP2AbbGfomWUblA76aiRN1Yy5OD/95drgtwlkquSKzZDeNq4QC2IZmzXt2Vy4HrXZNGrsBGgsgXV76SLkze+SsH4yJX3QXKgdSYvjlYRjieuud0KcF0IiJAsDZB4E5uL9/58jbAeAF9j0xIsT7orKBeUNjcWdLZUwB5svxE8dCPKKu/AUipY6cTNp2M8wRAS6p3BNkH47CDne0z5BKOIVSs0v9XnojglKqs9ERmjFLhIytQvwECi8xlD27yMRYl5ieHULuRkJQSZuTd/bI5KCEzHdlAewtGCEQRZAvI+5ixa+GBAD+/8CWbVqfvgsp5GzfABUAvcYJqnwJ/QBGLkDm4WBj++trxm/MC0P+wu8pvxyJDVMHEX0Vb+RKrEcxzPLfxbEurDETkV2PKoCOwQfz+ckQEESoK12dkwQTPE4hFIKFbIlIBpcyY7EAp9C8o87q4Nnq17RkKqqjNDncFjRurpebxH7+Vun+DEmR15BvE7npMpWCR+KjX25rIUPs8k9shGcdco/3LVwfENcAJmbA/FjqNTS61ob++PK7PEUSSYWZP9TmqAvw== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM5PR0801MB1668.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(38100700002)(52536014)(2906002)(83380400001)(316002)(66476007)(66446008)(8676002)(66946007)(91956017)(122000001)(64756008)(66556008)(76116006)(38070700005)(6916009)(86362001)(9686003)(71200400001)(33656002)(5660300002)(8936002)(186003)(6506007)(7696005)(508600001)(55016003)(26005); DIR:OUT; SFP:1101; MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB7843 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT053.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 4fb6b9e0-295a-44ec-207a-08da496be252 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: V9Hu3Nx4AJr/Bhm1j5b0Bh9JYceA2140GC6LrvPWtoukeO4HlJdUIBG8I24Q5VvvbNTRhd0UbYsIfg+MnSDav8tCCcAraUDus7iBKxwtobn7GkZ3YRwjjjO2HVjEN4U8nR0+sOzUq+oBf2rwC4pfCa9iBqx93/fIcnpT8brPulxL6pOBDEsDlVNj+JZK5zbzlew6dcmsTZqF2mB0XITnD+tN015nB/JMgW4Y6mTqSaK9nFHTfZ11nbQigx+IGMAVHdFlojC1olBw20MBWGZWKJlKmZI/TF5983XYGLGylsqZ/Ufdn7aVudGiLQJVZCp8BnvJM0PXMoYRlozRuNeZoRmSuLe7HcATy4Wd/IpBCzLs4t8lull2SGDbdDzg1JNPE6ghdkrifNhTEnsOMqtT2y/VXSRPmFDJVOHBxjwW2J3L84yT3NtGGQOFZcdZtUvy2Q/rEJO6gfQGwwy9nliNVgZIOvIYed0+JSPZrvaMjzdaxxB+fBz4cDFPZGWAyWioXcfn6TiOJCbInxeIRf7UkePWds0FYSxW577Om/xpmh4tYLG37fVhxKxG88YdQQ+SNp+dob3QHxzKESJSOThNQ1+1EZnuoPPJM0mQMPBRkNbjUSJHRlqME+CkfxNBrNHP1Oc+Pvs8I1WQ85HiuYIjZ6Xth3bOZpAWRcwdiXynKHz0il8rrm+73A4qmDIV8JFJ 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:(13230001)(4636009)(36840700001)(46966006)(40470700004)(33656002)(81166007)(186003)(336012)(86362001)(47076005)(83380400001)(55016003)(9686003)(40460700003)(8676002)(70586007)(52536014)(8936002)(356005)(5660300002)(508600001)(2906002)(36860700001)(26005)(6916009)(70206006)(316002)(82310400005)(6506007)(7696005); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jun 2022 16:28:23.1774 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7695efe1-21be-4f33-9956-08da496be837 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: AM5EUR03FT053.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3082 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, KAM_LOTSOFHASH, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Wilco Dijkstra via Libc-alpha From: Wilco Dijkstra Reply-To: Wilco Dijkstra Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Add a proper bounds check to __libc_ifunc_impl_list. This makes MAX_IFUNC redundant and fixes several targets that will write outside the array. To avoid unnecessary large diffs, pass the maximum in the argument 'i' to IFUNC_IMPL_ADD - 'max' can be used in new ifunc definitions and existing ones can be updated if desired. OK for commit? Reviewed-by: Adhemerval Zanella diff --git a/include/ifunc-impl-list.h b/include/ifunc-impl-list.h index 78087f015ccce4172de3c537b9197cd3d6e199fd..00bf48f3f1e182dcd0862a40ac901ee954019d17 100644 --- a/include/ifunc-impl-list.h +++ b/include/ifunc-impl-list.h @@ -34,15 +34,15 @@ struct libc_ifunc_impl /* Add an IFUNC implementation, IMPL, for function FUNC, to ARRAY with USABLE at index I and advance I by one. */ -#define IFUNC_IMPL_ADD(array, i, func, usable, impl) \ +#define IFUNC_IMPL_ADD(array, max, func, usable, impl) \ extern __typeof (func) impl attribute_hidden; \ - (array)[i++] = (struct libc_ifunc_impl) { #impl, (void (*) (void)) impl, (usable) }; + if (n < max) (array)[n++] = (struct libc_ifunc_impl) { #impl, (void (*) (void)) impl, (usable) }; /* Return the number of IFUNC implementations, N, for function FUNC if string NAME matches FUNC. */ -#define IFUNC_IMPL(n, name, func, ...) \ +#define IFUNC_IMPL(max, name, func, ...) \ if (strcmp (name, #func) == 0) \ - { \ + { size_t n = 0;\ __VA_ARGS__; \ return n; \ } diff --git a/sysdeps/aarch64/multiarch/ifunc-impl-list.c b/sysdeps/aarch64/multiarch/ifunc-impl-list.c index f6c6d008da285122cf3549efa5adf05d5e098680..4144615ab2198a97c76df40cec1056ea14300f56 100644 --- a/sysdeps/aarch64/multiarch/ifunc-impl-list.c +++ b/sysdeps/aarch64/multiarch/ifunc-impl-list.c @@ -24,16 +24,11 @@ #include #include -/* Maximum number of IFUNC implementations. */ -#define MAX_IFUNC 8 - size_t __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, size_t max) { - assert (max >= MAX_IFUNC); - - size_t i = 0; + size_t i = max; INIT_ARCH (); @@ -76,5 +71,5 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, IFUNC_IMPL_ADD (array, i, strlen, !mte, __strlen_asimd) IFUNC_IMPL_ADD (array, i, strlen, 1, __strlen_mte)) - return i; + return 0; } diff --git a/sysdeps/arm/armv7/multiarch/ifunc-impl-list.c b/sysdeps/arm/armv7/multiarch/ifunc-impl-list.c index af9f7490454673c87a251969f372545a80e36ced..e92bcb27a2535a20de958e384d623f1600591157 100644 --- a/sysdeps/arm/armv7/multiarch/ifunc-impl-list.c +++ b/sysdeps/arm/armv7/multiarch/ifunc-impl-list.c @@ -29,7 +29,7 @@ size_t __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, size_t max) { - size_t i = 0; + size_t i = max; bool use_neon = true; #ifdef __ARM_NEON__ @@ -57,5 +57,5 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, IFUNC_IMPL_ADD (array, i, memchr, use_neon, __memchr_neon) IFUNC_IMPL_ADD (array, i, memchr, 1, __memchr_noneon)); - return i; + return 0; } diff --git a/sysdeps/i386/i686/multiarch/ifunc-impl-list.c b/sysdeps/i386/i686/multiarch/ifunc-impl-list.c index c014f52bf942bba8ea929c0554ac97a78af8fbe5..9237b589f51f11aded6f83c370fd4c169f5eb5be 100644 --- a/sysdeps/i386/i686/multiarch/ifunc-impl-list.c +++ b/sysdeps/i386/i686/multiarch/ifunc-impl-list.c @@ -22,9 +22,6 @@ #include #include "init-arch.h" -/* Maximum number of IFUNC implementations. */ -#define MAX_IFUNC 4 - /* Fill ARRAY of MAX elements with IFUNC implementations for function NAME and return the number of valid entries. */ @@ -32,9 +29,7 @@ size_t __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, size_t max) { - assert (max >= MAX_IFUNC); - - size_t i = 0; + size_t i = max; /* Support sysdeps/i386/i686/multiarch/memchr.S. */ IFUNC_IMPL (i, name, memchr, @@ -358,5 +353,5 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, IFUNC_IMPL_ADD (array, i, strncmp, 1, __strncmp_ia32)) #endif - return i; + return 0; } diff --git a/sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c b/sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c index 01890367a4f078ee299eb94d6f7437baf3f882dd..e6ef5e6267a85e70b2f7c6c650a831a004d8e70d 100644 --- a/sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c +++ b/sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c @@ -22,16 +22,11 @@ #include #include -/* Maximum number of IFUNC implementations. */ -#define MAX_IFUNC 6 - size_t __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, size_t max) { - assert (max >= MAX_IFUNC); - - size_t i = 0; + size_t i = max; unsigned long int hwcap = GLRO(dl_hwcap); /* hwcap contains only the latest supported ISA, the code checks which is @@ -179,5 +174,5 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, IFUNC_IMPL_ADD (array, i, strchr, 1, __strchr_ppc)) - return i; + return 0; } diff --git a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c index ac533a98860687cffca0361fcc4281fd09390e9c..5a3c7a5886d25061b6ccd8ee7972a6c901f8e78e 100644 --- a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c +++ b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c @@ -22,16 +22,11 @@ #include #include -/* Maximum number of IFUNC implementations. */ -#define MAX_IFUNC 6 - size_t __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, size_t max) { - assert (max >= MAX_IFUNC); - - size_t i = 0; + size_t i = max; unsigned long int hwcap = GLRO(dl_hwcap); unsigned long int hwcap2 = GLRO(dl_hwcap2); @@ -448,5 +443,5 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, IFUNC_IMPL_ADD (array, i, strcasestr, 1, __strcasestr_ppc)) - return i; + return 0; } diff --git a/sysdeps/s390/multiarch/ifunc-impl-list.c b/sysdeps/s390/multiarch/ifunc-impl-list.c index c1902b2c269cd4f41215a97879e947b4d1c03816..5d0c73094d127dad2bc2ba7ac1a2d339c41af948 100644 --- a/sysdeps/s390/multiarch/ifunc-impl-list.c +++ b/sysdeps/s390/multiarch/ifunc-impl-list.c @@ -66,9 +66,6 @@ #include #include -/* Maximum number of IFUNC implementations. */ -#define MAX_IFUNC 3 - /* Fill ARRAY of MAX elements with IFUNC implementations for function NAME supported on target machine and return the number of valid entries. */ @@ -76,9 +73,7 @@ size_t __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, size_t max) { - assert (max >= MAX_IFUNC); - - size_t i = 0; + size_t i = max; /* Get hardware information. */ unsigned long int dl_hwcap = GLRO (dl_hwcap); @@ -670,5 +665,5 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, ) #endif /* HAVE_WMEMCMP_IFUNC */ - return i; + return 0; } diff --git a/sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c b/sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c index 9be12f913077ddeabcb88c858ba47351fac1db7a..918eb69a032faa92a9b50889e173b6af7b3efcf3 100644 --- a/sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c +++ b/sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c @@ -30,7 +30,7 @@ size_t __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, size_t max) { - size_t i = 0; + size_t i = max; int hwcap; hwcap = GLRO(dl_hwcap); @@ -75,5 +75,5 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, __memmove_niagara7) IFUNC_IMPL_ADD (array, i, memmove, 1, __memmove_ultra1)); - return i; + return 0; } diff --git a/sysdeps/x86_64/multiarch/ifunc-impl-list.c b/sysdeps/x86_64/multiarch/ifunc-impl-list.c index 7218095430a344bc2bb9e7038f96d3f89a4b5cba..8734294045348855e3b3109db93107f85413d5a9 100644 --- a/sysdeps/x86_64/multiarch/ifunc-impl-list.c +++ b/sysdeps/x86_64/multiarch/ifunc-impl-list.c @@ -23,9 +23,6 @@ #include #include "init-arch.h" -/* Maximum number of IFUNC implementations. */ -#define MAX_IFUNC 5 - /* Fill ARRAY of MAX elements with IFUNC implementations for function NAME supported on target machine and return the number of valid entries. */ @@ -34,9 +31,7 @@ size_t __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, size_t max) { - assert (max >= MAX_IFUNC); - - size_t i = 0; + size_t i = max; /* Support sysdeps/x86_64/multiarch/memcmpeq.c. */ IFUNC_IMPL (i, name, __memcmpeq, @@ -989,5 +984,5 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, __wmemset_chk_avx512_unaligned)) #endif - return i; + return 0; }