From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-x32c.google.com (mail-ot1-x32c.google.com [IPv6:2607:f8b0:4864:20::32c]) by sourceware.org (Postfix) with ESMTPS id AF252385842B for ; Wed, 27 Apr 2022 16:15:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AF252385842B Received: by mail-ot1-x32c.google.com with SMTP id 88-20020a9d0ee1000000b005d0ae4e126fso1402173otj.5 for ; Wed, 27 Apr 2022 09:15:22 -0700 (PDT) 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:to:references:from:in-reply-to :content-transfer-encoding; bh=gt4aSYefg8YWfE3sz19BE6rs7AZyjlFsTuzJSjvJ9qo=; b=ER9Ysy/LiWyXRtB48Y1hbQSWc/SAMCw6RzuU/nglXczf6QZb5Guf5gG7bNVAbLxg4p NLpN3cn3NckCuWJuqr2cl+BCgPnfydZ0z0kpS0caSNPh+VQDQtCv7NCTtSS+18ggtndx KviFe3ymKXxEbExkWtUkBev+FsQH47PIMzpPek6v8Nv9i8UvL/rcfPDmDcWZWa1nH27m E18PKP+ELzObUJZAofts6jx1Je27cyKhRUgc9wQ9fyXvp44RPIQ/Wbskps7Bl/7GJrU+ AfhsYoLUbwQH62BeIbTYpZsIJZIU3MJh7MiKF7D+UYWzjhETro04hXoegpmAh3tt0Hoz xxrw== X-Gm-Message-State: AOAM530N5NLp7BXv2aoqtdjLDhFa9RaAezd+K1XjmoahzCIU60/36cYq KaICq/afPgVoTvOuSsOpw9AoVfAPtNe5qw== X-Google-Smtp-Source: ABdhPJx7JFItFnrdp8zi4AbIQd4tu856uCCMVcxpHsPJsPlhyh8aAni2Xp8bA7PqqTGI/0IoE4Q5RA== X-Received: by 2002:a05:6830:2810:b0:605:689d:4fd9 with SMTP id w16-20020a056830281000b00605689d4fd9mr10366943otu.212.1651076121926; Wed, 27 Apr 2022 09:15:21 -0700 (PDT) Received: from ?IPV6:2804:431:c7ca:4214:b613:182d:cdde:5f86? ([2804:431:c7ca:4214:b613:182d:cdde:5f86]) by smtp.gmail.com with ESMTPSA id t21-20020a056871055500b000e92d5a54ffsm808572oal.26.2022.04.27.09.15.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 27 Apr 2022 09:15:21 -0700 (PDT) Message-ID: Date: Wed, 27 Apr 2022 13:15:18 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Subject: Re: [PATCH v2 2/4] Consolidate stdio-lock.h Content-Language: en-US To: Florian Weimer , Adhemerval Zanella via Libc-alpha References: <20220426191523.833171-1-adhemerval.zanella@linaro.org> <20220426191523.833171-3-adhemerval.zanella@linaro.org> <87o80mhd4u.fsf@oldenburg.str.redhat.com> From: Adhemerval Zanella In-Reply-To: <87o80mhd4u.fsf@oldenburg.str.redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, 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: Wed, 27 Apr 2022 16:15:25 -0000 On 27/04/2022 10:25, Florian Weimer wrote: > * Adhemerval Zanella via Libc-alpha: > >> diff --git a/sysdeps/generic/stdio-lock.h b/sysdeps/generic/stdio-lock.h >> index 14cf458bdd..fd61f0b5b7 100644 >> --- a/sysdeps/generic/stdio-lock.h >> +++ b/sysdeps/generic/stdio-lock.h >> @@ -45,20 +45,13 @@ __libc_lock_define_recursive (typedef, _IO_lock_t) >> #define _IO_cleanup_region_end(_doit) \ >> __libc_cleanup_region_end (_doit) >> >> -#if defined _LIBC && IS_IN (libc) >> - >> -# ifdef __EXCEPTIONS >> -# define _IO_acquire_lock(_fp) \ >> +#define _IO_acquire_lock(_fp) \ >> do { \ >> - FILE *_IO_acquire_lock_file \ >> - __attribute__((cleanup (_IO_acquire_lock_fct))) \ >> - = (_fp); \ >> - _IO_flockfile (_IO_acquire_lock_file); >> -# else >> -# define _IO_acquire_lock(_fp) _IO_acquire_lock_needs_exceptions_enabled >> -# endif >> -# define _IO_release_lock(_fp) ; } while (0) >> - >> -#endif >> + _IO_cleanup_region_start((void (*) (void *)) &_IO_funlockfile, _fp); \ >> + _IO_flockfile (_fp); >> +#define _IO_release_lock(_fp) \ >> + _IO_funlockfile (_fp); \ >> + _IO_cleanup_region_end (0); \ >> + } while (0) >> >> #endif /* stdio-lock.h */ > > I think this change replaces unwind tables for -fexceptions builds. If > GCC can't turn the indirect call to the unlock function into a direct > call, this will result in a loss of hardening due to the additional > indirect function call. > > This change may also lose C++ unwinding compatibility for some > fopencookie use cases, I think. This is an internal header where if __EXCEPTIONS is not defined we will get a compiler error because of an undefined symbol (_IO_acquire_lock_needs_exceptions_enabled). So internally all _IO_acquire_lock usage already requires __EXCEPTIONS, so the fallback is just unused definitions.