From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by sourceware.org (Postfix) with ESMTPS id 700623857C44 for ; Tue, 25 Jan 2022 00:58:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 700623857C44 Received: by mail-io1-xd31.google.com with SMTP id h23so21717370iol.11 for ; Mon, 24 Jan 2022 16:58:09 -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; bh=+/zNVX/l0WrtIENW+h9sG53/ev7KDxFoIOvrCqKr4jM=; b=KXr66aa9DQSQNQaWMZRoymkkp4H1BfuVSfq3UPkrIQX9cjpLutzjmCR/sI/2ltAcKq EqETJcKA/ZWzBLCMkx+L4NpRpiXyDM+2mOJmWJ/9dntpbXA7VVCXw7uv9yhWOjUs5XXy CrodhdmLrtWrwGAQCfH9iSCdwwVGGCyvQyHYjKYbZIgkeP44b7Q+eM1ONZSJl1fbeegj VVFyAXF8zhwT4dF6wANdjxiSZBZhQ+D9TUjA35plTyoWUJsNgv7EgwtYv6f014YgVbkQ L0K8HTTE0ODDyflDkVCL/tMOh46mpmhLooaXx1i09YR2iqTBSYzHaCZXYoa3jb/x71to gD4Q== X-Gm-Message-State: AOAM531BA4ZZ0Cy8TmwnhPM73TAbmn8ZN+OdbVNWOH805F/CxXazzBnm S+i9syuE0xjiNHMEWD23mKguK/6i+Fk= X-Google-Smtp-Source: ABdhPJx6xmWYeKBdoMINcm3PmF/Yx4hB3SSHzThVJLxfSepfXTeOTvJcLLvZkTFVfnwJOuOhT2f+mQ== X-Received: by 2002:a6b:710a:: with SMTP id q10mr3129587iog.50.1643072288855; Mon, 24 Jan 2022 16:58:08 -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 s12sm8718559ilu.84.2022.01.24.16.58.08 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 24 Jan 2022 16:58:08 -0800 (PST) Content-Type: multipart/mixed; boundary="------------0cs6jTUhMbokNsrGcEAWkOsN" Message-ID: <73343f8d-74b8-74a8-6097-c2c786c5423a@gmail.com> Date: Mon, 24 Jan 2022 17:58:07 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: [PATCH v2 3/5] avoid -Wuse-after-free [BZ #26779] Content-Language: en-US From: Martin Sebor To: libc-alpha@sourceware.org References: <53f20975-a2c9-674d-2a43-b1b323ee545c@gmail.com> In-Reply-To: <53f20975-a2c9-674d-2a43-b1b323ee545c@gmail.com> X-Spam-Status: No, score=-10.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, NICE_REPLY_A, 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-List-Received-Date: Tue, 25 Jan 2022 00:58:10 -0000 This is a multi-part message in MIME format. --------------0cs6jTUhMbokNsrGcEAWkOsN Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 1/24/22 17:52, Martin Sebor wrote: > 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. The attached patch suppresses the -Wuse-after-free instance in io/ftw.c. > > 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 > --------------0cs6jTUhMbokNsrGcEAWkOsN Content-Type: text/x-patch; charset=UTF-8; name="glibc-26779-3.diff" Content-Disposition: attachment; filename="glibc-26779-3.diff" Content-Transfer-Encoding: base64 ZGlmZiAtLWdpdCBhL2lvL2Z0dy5jIGIvaW8vZnR3LmMKaW5kZXggMjc0MjU0MWYzNi4uMDhj Y2JkZDUyMyAxMDA2NDQKLS0tIGEvaW8vZnR3LmMKKysrIGIvaW8vZnR3LmMKQEAgLTMyMyw4 ICszMjMsOCBAQCBvcGVuX2Rpcl9zdHJlYW0gKGludCAqZGZkcCwgc3RydWN0IGZ0d19kYXRh ICpkYXRhLCBzdHJ1Y3QgZGlyX2RhdGEgKmRpcnApCiAJICBidWZbYWN0c2l6ZSsrXSA9ICdc MCc7CiAKIAkgIC8qIFNocmluayB0aGUgYnVmZmVyIHRvIHdoYXQgd2UgYWN0dWFsbHkgbmVl ZC4gICovCi0JICBkYXRhLT5kaXJzdHJlYW1zW2RhdGEtPmFjdGRpcl0tPmNvbnRlbnQgPSBy ZWFsbG9jIChidWYsIGFjdHNpemUpOwotCSAgaWYgKGRhdGEtPmRpcnN0cmVhbXNbZGF0YS0+ YWN0ZGlyXS0+Y29udGVudCA9PSBOVUxMKQorCSAgdm9pZCAqY29udGVudCA9IHJlYWxsb2Mg KGJ1ZiwgYWN0c2l6ZSk7CisJICBpZiAoY29udGVudCA9PSBOVUxMKQ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