From patchwork Tue Sep 9 21:05:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 119940 Return-Path: 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 9C2CB3858C55 for ; Tue, 9 Sep 2025 21:06:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9C2CB3858C55 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from sonata.ens-lyon.org (domu-toccata.ens-lyon.fr [140.77.166.138]) by sourceware.org (Postfix) with ESMTPS id 7FF0D3858D35 for ; Tue, 9 Sep 2025 21:05:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7FF0D3858D35 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=bounce.ens-lyon.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 7FF0D3858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=140.77.166.138 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757451931; cv=none; b=RXdMAS7xLdgHP/89EAMi3Dzn2UOQzpiVFzva43uVfptLL1FpMPzVQeItzggbaK7ZvNZX7ZHFaU1XcnHKrBiYDAlcDMYu3oOOjk6iE2jC0PrIohBxwJ6xOpFIHGfK2pIcZhnUzkSKA7tgNBrTvZzT3ppXjWSCI+SoOwRee0r1QBk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757451931; c=relaxed/simple; bh=l6OPCQc5YXyH0AH8a/EZ3wBYjAfu1jFH94rGmzDlJ2Q=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=YmlsJEWduTCRkVn3IeRgVm36vTeFfUsJ0R8V31X0iRpYlNSb9432uVwtsPGHccx+gcD9mVNAy9eqUEdKV2XWmY9WXYf0ZCzXoJvsQOhlcuCcs0hiNHVR4yGcCFqU85Mf3VqkywB5TBZzPKCpNirUFlY1FJ7lptOK2Z42RzdOOjg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7FF0D3858D35 Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id 1E55DA1C15; Tue, 9 Sep 2025 23:05:30 +0200 (CEST) Received: from sonata.ens-lyon.org ([127.0.0.1]) by localhost (sonata.ens-lyon.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ma5LPuvb3eIi; Tue, 9 Sep 2025 23:05:30 +0200 (CEST) Received: from begin.home (aamiens-653-1-40-48.w83-192.abo.wanadoo.fr [83.192.199.48]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by sonata.ens-lyon.org (Postfix) with ESMTPSA id F1FCEA1B30; Tue, 9 Sep 2025 23:05:29 +0200 (CEST) Received: from samy by begin.home with local (Exim 4.98.2) (envelope-from ) id 1uw5Wr-0000000AAAA-29US; Tue, 09 Sep 2025 23:05:29 +0200 From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Samuel Thibault , commit-hurd@gnu.org Subject: [commited] malloc: check "negative" tcache_key values by hand Date: Tue, 9 Sep 2025 23:05:29 +0200 Message-ID: <20250909210529.2422339-1-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.51.0 MIME-Version: 1.0 X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS, 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 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org instead of undefined cases from casting uintptr_t into intptr_t. --- malloc/malloc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/malloc/malloc.c b/malloc/malloc.c index 444dc61825..18ef6b5cb8 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -3150,7 +3150,8 @@ tcache_key_initialize (void) int minimum_bits = __WORDSIZE / 4; int maximum_bits = __WORDSIZE - minimum_bits; - while (labs ((intptr_t) tcache_key) <= 0x1000000 + while (tcache_key <= 0x1000000 + || tcache_key >= ((uintptr_t) ULONG_MAX) - 0x1000000 || stdc_count_ones (tcache_key) < minimum_bits || stdc_count_ones (tcache_key) > maximum_bits) {