From patchwork Mon Oct 18 13:14:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 46346 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 682C93858402 for ; Mon, 18 Oct 2021 13:14:36 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from butterfly.birch.relay.mailchannels.net (butterfly.birch.relay.mailchannels.net [23.83.209.27]) by sourceware.org (Postfix) with ESMTPS id 4674C3858400 for ; Mon, 18 Oct 2021 13:14:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4674C3858400 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gotplt.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gotplt.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 0E404123758 for ; Mon, 18 Oct 2021 13:14:18 +0000 (UTC) Received: from pdx1-sub0-mail-a76.g.dreamhost.com (100-96-133-192.trex.outbound.svc.cluster.local [100.96.133.192]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 91D16123737 for ; Mon, 18 Oct 2021 13:14:17 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a76.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384) by 100.96.133.192 (trex/6.4.3); Mon, 18 Oct 2021 13:14:17 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Suffer-Stretch: 67b10e691ca6e16b_1634562857833_2067014953 X-MC-Loop-Signature: 1634562857833:418075172 X-MC-Ingress-Time: 1634562857833 Received: from pdx1-sub0-mail-a76.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a76.g.dreamhost.com (Postfix) with ESMTP id 45D298710B for ; Mon, 18 Oct 2021 06:14:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gotplt.org; h=message-id :date:mime-version:subject:to:references:from:in-reply-to :content-type:content-transfer-encoding; s=gotplt.org; bh=VXdur5 e6LPqC0mGAgsjoKdJnIMw=; b=i7/OtA0x/mADdO0n2ocFwHlWd/g2el2ClGTAhh MmnUU5i0CionsdPnnUt71yMG5+RCoIXRN/ww5U8Tq651R49EL8eUH8q9xgvfkBbm Mg4eg6MpHhYxBOm6CN0WgT4MjFCSHSy6pS9lp6UhIsDTF32hoovU9B9J/+4fKPTh YSKZs= Received: from [192.168.1.174] (unknown [1.186.123.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a76.g.dreamhost.com (Postfix) with ESMTPSA id A259087101 for ; Mon, 18 Oct 2021 06:14:15 -0700 (PDT) Message-ID: <71028ec7-ccb4-ac67-8581-a74ff245832f@gotplt.org> Date: Mon, 18 Oct 2021 18:44:11 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.0 Subject: [PING][PATCH 0/3] _FORTIFY_SOURCE=3 improvements Content-Language: en-US To: libc-alpha@sourceware.org References: <20211012161629.302696-1-siddhesh@sourceware.org> X-DH-BACKEND: pdx1-sub0-mail-a76 From: Siddhesh Poyarekar In-Reply-To: <20211012161629.302696-1-siddhesh@sourceware.org> X-Spam-Status: No, score=-3029.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_SBL, RCVD_IN_SORBS_WEB, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no 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: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Ping! On 10/12/21 21:46, Siddhesh Poyarekar via Libc-alpha wrote: > This patchset changes the layout of fortified functions to make them > _FORTIFY_SOURCE=3 friendly and at the same time, continue working the > same for _FORTIFY_SOURCE=2 and lower. At a high level it makes sure > that no branches are emitted at compile time and only one of either the > regular or _chk version of the function is called. The conditions are > also reworked to make them more readable and foldable even in cases > where the compiler doesn't know the exact values of the operation length > and size, but can make decisions based on ranges of their values. > > The changeset also adds some _FORTIFY_SOURCE=3 testing coverage on > compilers that are able to set that fortification level. > > Siddhesh Poyarekar (3): > Don't add access size hints to fortifiable functions > Make sure that the fortified function conditionals are constant > debug: Add tests for _FORTIFY_SOURCE=3 > > debug/Makefile | 13 +- > debug/tst-chk1.c | 102 ++++++++------- > debug/tst-chk7.c | 2 + > debug/tst-chk8.cc | 2 + > io/bits/poll2.h | 31 ++--- > io/sys/poll.h | 6 +- > libio/bits/stdio2.h | 110 +++++++---------- > libio/stdio.h | 4 +- > misc/sys/cdefs.h | 71 +++++++++++ > posix/bits/unistd.h | 174 ++++++-------------------- > posix/unistd.h | 28 +++-- > socket/bits/socket2.h | 34 ++--- > stdlib/bits/stdlib.h | 57 +++------ > stdlib/stdlib.h | 5 +- > string/bits/string_fortified.h | 5 +- > string/string.h | 2 +- > wcsmbs/bits/wchar2.h | 219 +++++++++------------------------ > 17 files changed, 351 insertions(+), 514 deletions(-) > create mode 100644 debug/tst-chk7.c > create mode 100644 debug/tst-chk8.cc >