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 DCECF3858037 for ; Tue, 25 Jan 2022 00:58:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DCECF3858037 Received: by mail-io1-xd31.google.com with SMTP id d188so7470119iof.7 for ; Mon, 24 Jan 2022 16:58:14 -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=+SW3FQQfSM0DpCnN38W/bZQQ+I3jy1/37y4P8brDGVg=; b=oOkn9cV+d7khYKUqFdYxhmz+52nmong/Uy1rqbexiF0ZQy7Gz84bwQ5al9PQtGOkSl 4KboLpI9lLYkMoZoeM2EqTUkf5rB1PZoxcPHCKR0n/waLBE5Cp+1CcHwETY4pWpjAV3X 4t+4LQ59i6dqucU7RruiZudNLxCE0glP3qaenqytJJNIrwbwloiUbVRFFik9/w0QXKU1 7yQ2pnXQuK9OYvznYADlyTUJnLJreV0lAuez5NA6Sa11qHnpCzpaA4G//JL67zKs097K kbHimUo/TCzf0yUNBuopnT4Ew/KAgRKIGAqR4IO3+VKpHebJLfIxni9NxDrH5wc0Eyae olWg== X-Gm-Message-State: AOAM5306OHqBwRN5X97kuoA9RUOvFbx6+kmR9Yi0ng/gRkueRpDllIBK iybT04GFsbacfVLN+LGBj/p9MuECPvM= X-Google-Smtp-Source: ABdhPJz3kinV0hQciDldmo5XJrQsTBpP9v5+A+PYvdHdZ0w3gt9ZkxaUHPeU0wlThQWlOHS//ASS1w== X-Received: by 2002:a6b:f104:: with SMTP id e4mr3377116iog.49.1643072294295; Mon, 24 Jan 2022 16:58:14 -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 o14sm8247486ilq.21.2022.01.24.16.58.13 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 24 Jan 2022 16:58:13 -0800 (PST) Content-Type: multipart/mixed; boundary="------------ha4JD6AKXVHf4xR8ke9BaEVw" Message-ID: <05e683bb-96d7-ebff-b0e1-f988e261b19b@gmail.com> Date: Mon, 24 Jan 2022 17:58:13 -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 4/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:16 -0000 This is a multi-part message in MIME format. --------------ha4JD6AKXVHf4xR8ke9BaEVw 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 stdlib/setenv.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 > --------------ha4JD6AKXVHf4xR8ke9BaEVw Content-Type: text/x-patch; charset=UTF-8; name="glibc-26779-4.diff" Content-Disposition: attachment; filename="glibc-26779-4.diff" Content-Transfer-Encoding: base64 ZGlmZiAtLWdpdCBhL3N0ZGxpYi9zZXRlbnYuYyBiL3N0ZGxpYi9zZXRlbnYuYwppbmRleCBj M2QyY2VlN2I2Li4yMTc2Y2JhYzMxIDEwMDY0NAotLS0gYS9zdGRsaWIvc2V0ZW52LmMKKysr IGIvc3RkbGliL3NldGVudi5jCkBAIC0xNTAsNyArMTUwLDkgQEAgX19hZGRfdG9fZW52aXJv biAoY29uc3QgY2hhciAqbmFtZSwgY29uc3QgY2hhciAqdmFsdWUsIGNvbnN0IGNoYXIgKmNv bWJpbmVkLAogICAgIHsKICAgICAgIGNoYXIgKipuZXdfZW52aXJvbjsKIAotICAgICAgLyog V2UgYWxsb2NhdGVkIHRoaXMgc3BhY2U7IHdlIGNhbiBleHRlbmQgaXQuICAqLworICAgICAg LyogV2UgYWxsb2NhdGVkIHRoaXMgc3BhY2U7IHdlIGNhbiBleHRlbmQgaXQuICBBdm9pZCB1 c2luZyB0aGUgcmF3CisJIHJlYWxsb2NhdGVkIHBvaW50ZXIgdG8gYXZvaWQgR0NDIC1XdXNl LWFmdGVyLWZyZWUuICAqLworICAgICAgdWludHB0cl90IGlwX2xhc3RfZW52aXJvbiA9ICh1 aW50cHRyX3QpbGFzdF9lbnZpcm9uOwogICAgICAgbmV3X2Vudmlyb24gPSAoY2hhciAqKikg cmVhbGxvYyAobGFzdF9lbnZpcm9uLAogCQkJCSAgICAgICAoc2l6ZSArIDIpICogc2l6ZW9m IChjaGFyICopKTsKICAgICAgIGlmIChuZXdfZW52aXJvbiA9PSBOVUxMKQpAQCAtMTU5LDcg KzE2MSw3IEBAIF9fYWRkX3RvX2Vudmlyb24gKGNvbnN0IGNoYXIgKm5hbWUsIGNvbnN0IGNo YXIgKnZhbHVlLCBjb25zdCBjaGFyICpjb21iaW5lZCwKIAkgIHJldHVybiAtMTsKIAl9CiAK LSAgICAgIGlmIChfX2Vudmlyb24gIT0gbGFzdF9lbnZpcm9uKQorICAgICAgaWYgKCh1aW50 cHRyX3QpX19lbnZpcm9uICE9IGlwX2xhc3RfZW52aXJvbikKIAltZW1jcHkgKChjaGFyICop IG5ld19lbnZpcm9uLCAoY2hhciAqKSBfX2Vudmlyb24sCiAJCXNpemUgKiBzaXplb2YgKGNo YXIgKikpOwogCg== --------------ha4JD6AKXVHf4xR8ke9BaEVw--