From patchwork Tue Jan 25 00:52:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Martin Sebor X-Patchwork-Id: 50421 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 504E83857C4E for ; Tue, 25 Jan 2022 00:52:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 504E83857C4E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1643071973; bh=2fMArwMq2/VZRnhRm/fTPLygqZ5x7yBYeMRmu3Qn0ZM=; h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=oRo3fOKaYxJuyo9q5oiPnmazNJR4uoSwZd4ZTzhJRKzs3hwUke7dCaneZir0ium1/ mc7bVVpnjsiJzrGaRHayWfLOy1+VJo519mkoAxH4xlCsALKVBV5i2szo3A4DCi83Ba 5tgpLJVY+kJ3VLGzOmVPEeZVNUj5WHS4Tx/Xwj6g= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) by sourceware.org (Postfix) with ESMTPS id 3A2FF3858437 for ; Tue, 25 Jan 2022 00:52:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3A2FF3858437 Received: by mail-il1-x132.google.com with SMTP id i1so9469449ils.5 for ; Mon, 24 Jan 2022 16:52:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:from:to:references:in-reply-to :content-transfer-encoding; bh=2fMArwMq2/VZRnhRm/fTPLygqZ5x7yBYeMRmu3Qn0ZM=; b=3HmqdlKB7j4Ie4a9vf6Tup+3nbT/mHzlfEbNC/qGbbSoh9feGllG9Q47PIEOz5z11i iuj3A99tdTN/1/04g25CJy32jedmyPrPrU0QcXumSLIAD1Y7/jlBPi91xYabhGH5MJbP emp/ZTSpB8CcX7tepd1QyJi7HVnWX35CuxrgFJpeLg85tCvC/dOyMX+PhxuaOlUmRtL7 2Yr+MhwwSDgQ+p8gFTG5bOVa1fXx4gOkNSOginTROji1fma6/ySTEm1tBKGploZBpikr roUUTXb7wBOsJWN8rh29kNOj1D3kVorOtCGV5RS23pp2QKLzb/FJ19ywwrg5+jH3HHxx DUAg== X-Gm-Message-State: AOAM531w1IXCqfc6zgG3ODiUZZ3KEagZpTnRphlCIpkWHj6X+4HWYVLb rGLl+GghR2XxLMEFIbpFTuKXU0c/5ZY= X-Google-Smtp-Source: ABdhPJxD5F3Wrx28ElbtaHoL+v3LICvCRfepeXyx8Glw3q0QRs/wnoVcIkdGU6d0ikGgXou5xb5JQQ== X-Received: by 2002:a92:c242:: with SMTP id k2mr10729992ilo.198.1643071951514; Mon, 24 Jan 2022 16:52:31 -0800 (PST) Received: from [192.168.0.41] (97-118-100-142.hlrn.qwest.net. [97.118.100.142]) by smtp.gmail.com with ESMTPSA id w4sm8466600ill.29.2022.01.24.16.52.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 24 Jan 2022 16:52:30 -0800 (PST) Message-ID: <53f20975-a2c9-674d-2a43-b1b323ee545c@gmail.com> Date: Mon, 24 Jan 2022 17:52:30 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: [PATCH v2 0/5] avoid -Wuse-after-free [BZ #26779] Content-Language: en-US To: libc-alpha@sourceware.org References: In-Reply-To: X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Martin Sebor via Libc-alpha From: Martin Sebor Reply-To: Martin Sebor Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" This is a repost of the original patch but broken down by source file and with some suppression done by #pragma GCC diagnostic instead of conversion to intptr_t. It also adds fixes for the same problem in the test suite that I overlooked before. On 1/15/22 17:21, Martin Sebor wrote: > GCC 12 features a couple of new warnings designed to detect uses > of pointers made invalid by the pointees lifetimes having ended. > Building Glibc with the enhanced GCC exposes a few such uses, > mostly after successful calls to realloc.  The attached patch > avoids the new warnings by converting the pointers to uintptr_t > first and using the converted integers instead. > > The patch suppresses all instances of the warning at the strictest > setting (-Wuse-after-free=3), which includes even uses in equality > expressions.  The default setting approved for GCC 12 is > -Wuse-after-free=2, which doesn't warn on such uses to accommodate > the pointer-adjustment-after-realloc idiom.  At the default setting, > the changes to ldconfig.c and setenv are not necessary. > > Martin Reviewed-by: Carlos O'Donell Reviewed-by: Carlos O'Donell Reviewed-by: Carlos O'Donell Reviewed-by: Carlos O'Donell Reviewed-by: Carlos O'Donell Reviewed-by: Carlos O'Donell Reviewed-by: Carlos O'Donell