From patchwork Fri Feb 12 17:27:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 42024 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 E5547385780F; Fri, 12 Feb 2021 17:27:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E5547385780F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1613150834; bh=BLGQhEZU720Mt8rjkp+4v9/RdDCd2Pd9P+THrwapbBY=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=S8tC1YDZ/+ASv63fYFMdxfPdJYAY3D/Ej5A9fNt+Vg25s/JZpPwEQ9RFiOlYHxTP6 W/56wTxawa1mYnJ2Vbo8o248ZLRH1wNDz9BZ2xz7Xb812NH3uWtJXf3ryxqMniwHeU Tx1APPYluNRU49HKjS7QBfXI7XiX9lHxhXpfP1mU= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 44CEC385780F for ; Fri, 12 Feb 2021 17:27:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 44CEC385780F Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-413-S-hv_oe7MAy5JYQrVllMGg-1; Fri, 12 Feb 2021 12:27:08 -0500 X-MC-Unique: S-hv_oe7MAy5JYQrVllMGg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B2A2A6EE20 for ; Fri, 12 Feb 2021 17:27:07 +0000 (UTC) Received: from oldenburg.str.redhat.com (ovpn-113-131.ams2.redhat.com [10.36.113.131]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 37C6560C67 for ; Fri, 12 Feb 2021 17:27:07 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH] elf: Do not copy vDSO soname when setting up link map Date: Fri, 12 Feb 2021 18:27:29 +0100 Message-ID: <871rdli4ce.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-Patchwork-Original-From: Florian Weimer via Libc-alpha From: Florian Weimer Reply-To: Florian Weimer Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" The kernel does not put the vDSO at special addresses, so writev can write the name directly. Also remove the incorrect comment about not setting l_name. Andy Lutomirski confirmed in that this copy is not necessary. Reviewed-by: Adhemerval Zanella --- elf/setup-vdso.h | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/elf/setup-vdso.h b/elf/setup-vdso.h index ece840df38..86c491e49c 100644 --- a/elf/setup-vdso.h +++ b/elf/setup-vdso.h @@ -80,20 +80,13 @@ setup_vdso (struct link_map *main_map __attribute__ ((unused)), l->l_local_scope[0]->r_list = &l->l_real; /* Now that we have the info handy, use the DSO image's soname - so this object can be looked up by name. Note that we do not - set l_name here. That field gives the file name of the DSO, - and this DSO is not associated with any file. */ + so this object can be looked up by name. */ if (l->l_info[DT_SONAME] != NULL) { - /* Work around a kernel problem. The kernel cannot handle - addresses in the vsyscall DSO pages in writev() calls. */ - const char *dsoname = ((char *) D_PTR (l, l_info[DT_STRTAB]) - + l->l_info[DT_SONAME]->d_un.d_val); - size_t len = strlen (dsoname) + 1; - char *copy = malloc (len); - if (copy == NULL) - _dl_fatal_printf ("out of memory\n"); - l->l_libname->name = l->l_name = memcpy (copy, dsoname, len); + char *dsoname = ((char *) D_PTR (l, l_info[DT_STRTAB]) + + l->l_info[DT_SONAME]->d_un.d_val); + l->l_libname->name = dsoname; + l->l_name = dsoname; } /* Add the vDSO to the object list. */