From patchwork Wed Feb 26 15:18:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 1245142 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-110104-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha1 header.s=default header.b=j8tu2SMN; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=hm3EE8Y0; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48SKFP4M0dz9sNg for ; Thu, 27 Feb 2020 02:18:33 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id :mime-version:content-type:content-transfer-encoding; q=dns; s= default; b=SS6cx+sL1PnWJU9ADx4Srr/nMcZADqxzAioGqo4e6Jv72f9G2RGlx nsUa14Wpw1ay/WGzfXClzdUx2/CMWPU5Bxl7dgI+fk/t6splSDuUBSLmQLi/C/9s UP/mLn1g3CoojU5UKCODGI73g24D0F90Gnm0VzKJe6Jte2KHqLKXbs= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id :mime-version:content-type:content-transfer-encoding; s=default; bh=1ihoHc6znwVcp0SVt9oEKA3j/Y4=; b=j8tu2SMNLOs/FHufPOfAWDco/aVF few3oNiPKaNdzRek5vVR8dcszlOpgiZGeJkkCr/YgYI9t7ZgyBQF3PCYB/0rdsqX 1SIX3YNXR1l2K2r+T+xPSOWnGFTFXPX2foLpw3qcFp29z6NS8lfb+epKGCU/U7wS Iz6ahnMYMCp19/4= Received: (qmail 59930 invoked by alias); 26 Feb 2020 15:18:27 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 59919 invoked by uid 89); 26 Feb 2020 15:18:27 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=data.rel.ro, UD:data.rel.ro, datarelro, calloc X-HELO: us-smtp-delivery-1.mimecast.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582730294; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=OEo8ziRFkoQ0/fMuf8KkyNVVxAaJYb9I6zmNaVCs1bI=; b=hm3EE8Y0fMnDhlRpqx1lDXzeL+UyjlBTCnpYKaCdaNTnZyON1c2LE1/zvzUdoSqtjaJfj1 QdFS7VmXVNPfrehwz1I2avY9qUxDtmmgMs3Q1SPat7uKdk1AQs0X3D4cw5oWkVamfiRuwR bh7rFmtrDpPBf1mNFzoJjq/qXmbrrp0= From: Florian Weimer To: libc-alpha@sourceware.org Cc: mjw@fedoraproject.org, Patsy Griffin Subject: [PATCH] elf: Apply attribute_relro to pointers in elf/dl-minimal.c Date: Wed, 26 Feb 2020 16:18:02 +0100 Message-ID: <87tv3d2x91.fsf@oldenburg2.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com The present code leaves the function pointers unprotected, but moves some of the static functions into .data.rel.ro instead. This causes the linker to produce an allocatable, executable, writable section and eventually an RWX load segment. Not only do we really do not want that, it also breaks valgrind because valgrind does not load debuginfo from the mmap interceptor if all it sees are RX and RWX mappings. ----- elf/dl-minimal.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/elf/dl-minimal.c b/elf/dl-minimal.c index c79ce23be4..7c64e24c87 100644 --- a/elf/dl-minimal.c +++ b/elf/dl-minimal.c @@ -39,16 +39,16 @@ implementation below. Before the final relocation, __rtld_malloc_init_real is called to replace the pointers with the real implementation. */ -__typeof (calloc) *__rtld_calloc; -__typeof (free) *__rtld_free; -__typeof (malloc) *__rtld_malloc; -__typeof (realloc) *__rtld_realloc; +__typeof (calloc) *__rtld_calloc attribute_relro; +__typeof (free) *__rtld_free attribute_relro; +__typeof (malloc) *__rtld_malloc attribute_relro; +__typeof (realloc) *__rtld_realloc attribute_relro; /* Defined below. */ -static __typeof (calloc) rtld_calloc attribute_relro; -static __typeof (free) rtld_free attribute_relro; -static __typeof (malloc) rtld_malloc attribute_relro; -static __typeof (realloc) rtld_realloc attribute_relro; +static __typeof (calloc) rtld_calloc; +static __typeof (free) rtld_free; +static __typeof (malloc) rtld_malloc; +static __typeof (realloc) rtld_realloc; void __rtld_malloc_init_stubs (void)