From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) by sourceware.org (Postfix) with ESMTPS id 243D7385DC22 for ; Mon, 7 Jun 2021 19:01:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 243D7385DC22 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=maskray.me Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-f48.google.com with SMTP id z3-20020a17090a3983b029016bc232e40bso653870pjb.4 for ; Mon, 07 Jun 2021 12:01:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=7VIwrZ7H2nw7289Ww8T6U63+QYVn6QzQPA+Ess1bdFE=; b=PysGHhSJXxrFf8NkIz0O6gYbrA3luqfCwRt/aYj1myiPkuPB1D5VrXS61EYBSf/yK3 q4mLGb/2YJokIXWFYtYAeRvdJvUnVHpLer+RtzoU5NIUJwMMCVMxRU1JZjcPj13saWTb adhTtoP8H3YOPO4NlqLGD9M5JwfxM6qhMTxjRL1wWtincgh0kkR2nqy3UpwxnvF7eQBy +wMfezNoa5EaWmxJOO9JA1wKf8Zu0gPs8H8/g7j25txFrkpR9GMlvV21d6v/MthG5er3 qUrzs6p8nyEYGlwV5aYE4FYAwCcc5nlGfkBHwcdCK6gLPOmIau7g1zY2okwCfPrxBvIk o8Uw== X-Gm-Message-State: AOAM533BKKgFB56AD/cW33sI0+RotB0mZPAs9923/MmvBn6yhjsGChP2 W77IuTZn+QI/fmxA8BYU7nQ= X-Google-Smtp-Source: ABdhPJzi4BJdtd3+WB9R0dH9D/rXKlY5wNfSx36Mx0cDxauBqC7Q2I8zUZ/ff06m5lqXHX9UB/dvIg== X-Received: by 2002:a17:902:8497:b029:103:b23b:f1c3 with SMTP id c23-20020a1709028497b0290103b23bf1c3mr19362549plo.34.1623092515161; Mon, 07 Jun 2021 12:01:55 -0700 (PDT) Received: from localhost ([2601:647:4b01:ae80:1686:1fb6:d584:4921]) by smtp.gmail.com with ESMTPSA id h12sm8952009pfh.9.2021.06.07.12.01.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Jun 2021 12:01:54 -0700 (PDT) Date: Mon, 7 Jun 2021 12:01:53 -0700 From: Fangrui Song To: Jeff Law Cc: Jakub Jelinek , Andrew Pinski , Fangrui Song , GCC Patches , Jan Hubicka Subject: Re: [PATCH] Add --enable-default-semantic-interposition to GCC configure Message-ID: <20210607190153.tkl5ga43ckk7vdke@gmail.com> References: <20210606231215.49899-1-maskray@google.com> <20210607181321.GL7746@tucnak> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20210607181321.GL7746@tucnak> X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_INFOUSMEBIZ, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Jun 2021 19:01:57 -0000 On 2021-06-07, Jakub Jelinek wrote: >On Mon, Jun 07, 2021 at 12:01:55PM -0600, Jeff Law via Gcc-patches wrote: >> > This breaks assumptions across the board. If software packages want >> > to use -fno-semantic-interposition that is one thing. But distros >> > should not be changing the default. This is just like using >> > -ffast-math :). >> Some distros already force immediate binding at link time for security >> purposes on a distro-wide basis which, IIUC, does the same thing, but >> without the benefits from a code generation standpoint. > >If you are talking about -Wl,-z,now, that is very different, semantic >interposition then still works just fine. >If you are talking about the glibc style by hand "protected" visibility, >bind calls to symbols defined in the same library through internal symbols, >then that is done only for a couple of packages and is stronger than >-fno-semantic-interposition. > > Jakub > -fno-semantic-interposition can save a PLT entry (and associated R_*_JUMP_SLOT dynamic relocation) if a default visibility STB_GLOBAL function is only called in its defining TU, not by other TUs linked into the shared object. This is a subset of the PLT-suppressing optimization if a distribution defaults to ld -Bsymbolic-non-weak-functions (https://maskray.me/blog/2021-05-16-elf-interposition-and-bsymbolic#the-last-alliance-of-elf-and-men) Binding definitions in the same component can make software securer. https://twitter.com/CarlosODonell/status/1400879768028028935 "Disable PRELOAD/AUDIT, which is what I'm going to pursue e.g. system-wide glibc hardening tunable." If such a thing is deployed, why cannot a passionate distribution default to gcc -fno-semantic-interposition and ld -Bsymbolic-non-weak-functions can bring back the lost performance (15+% for my clang; 27% for cpython; ...) Last, the "assumption" is just GCC's mapping from source code to the ELF binary format. https://maskray.me/blog/2021-05-09-fno-semantic-interposition#source-level-implication We could also argue that C++ odr rule doesn't like us doing semantic interposition. (I know it's vague https://stackoverflow.com/questions/55632222/odr-violation-when-linking-static-and-dynamic-library )