From owner-svn-src-head@freebsd.org Mon Jul 6 11:58:00 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 42C2C364D43; Mon, 6 Jul 2020 11:58:00 +0000 (UTC) (envelope-from luporl@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4B0kbW61R5z3gdk; Mon, 6 Jul 2020 11:57:59 +0000 (UTC) (envelope-from luporl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B31E31DC31; Mon, 6 Jul 2020 11:57:59 +0000 (UTC) (envelope-from luporl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 066BvxLu014820; Mon, 6 Jul 2020 11:57:59 GMT (envelope-from luporl@FreeBSD.org) Received: (from luporl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 066BvxTI014819; Mon, 6 Jul 2020 11:57:59 GMT (envelope-from luporl@FreeBSD.org) Message-Id: <202007061157.066BvxTI014819@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: luporl set sender to luporl@FreeBSD.org using -f From: Leandro Lupori Date: Mon, 6 Jul 2020 11:57:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r362958 - head/libexec/rtld-elf X-SVN-Group: head X-SVN-Commit-Author: luporl X-SVN-Commit-Paths: head/libexec/rtld-elf X-SVN-Commit-Revision: 362958 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Jul 2020 11:58:00 -0000 Author: luporl Date: Mon Jul 6 11:57:59 2020 New Revision: 362958 URL: https://svnweb.freebsd.org/changeset/base/362958 Log: Handle non-PLT GNU IFUNC relocations in rtld In the last IFUNC related changes to rtld, the code that handled non-PLT GNU IFUNC relocations ended up getting lost. This could leave some relocations unhandled, causing crashes or misbehavior. This change restores the handling of these relocations, but now together with the other IFUNC relocations, allowing resolvers to reference external symbols. Reviewed by: kib MFC after: 2 weeks Sponsored by: Eldorado Research Institute (eldorado.org.br) Differential Revision: https://reviews.freebsd.org/D25550 Modified: head/libexec/rtld-elf/rtld.c Modified: head/libexec/rtld-elf/rtld.c ============================================================================== --- head/libexec/rtld-elf/rtld.c Mon Jul 6 10:05:35 2020 (r362957) +++ head/libexec/rtld-elf/rtld.c Mon Jul 6 11:57:59 2020 (r362958) @@ -3111,7 +3111,8 @@ resolve_object_ifunc(Obj_Entry *obj, bool bind_now, in return (0); obj->ifuncs_resolved = true; if (!obj->irelative && !obj->irelative_nonplt && - !((obj->bind_now || bind_now) && obj->gnu_ifunc)) + !((obj->bind_now || bind_now) && obj->gnu_ifunc) && + !obj->non_plt_gnu_ifunc) return (0); if (obj_disable_relro(obj) == -1 || (obj->irelative && reloc_iresolve(obj, lockstate) == -1) || @@ -3119,6 +3120,8 @@ resolve_object_ifunc(Obj_Entry *obj, bool bind_now, in lockstate) == -1) || ((obj->bind_now || bind_now) && obj->gnu_ifunc && reloc_gnu_ifunc(obj, flags, lockstate) == -1) || + (obj->non_plt_gnu_ifunc && reloc_non_plt(obj, &obj_rtld, + flags | SYMLOOK_IFUNC, lockstate) == -1) || obj_enforce_relro(obj) == -1) return (-1); return (0);