From nobody Wed Dec 15 01:55:17 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id DCD5918E5605; Wed, 15 Dec 2021 01:55:17 +0000 (UTC) (envelope-from git@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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JDJGs2qxxz4RyK; Wed, 15 Dec 2021 01:55:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 21D2C13654; Wed, 15 Dec 2021 01:55:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1BF1tHhC031757; Wed, 15 Dec 2021 01:55:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BF1tHEl031756; Wed, 15 Dec 2021 01:55:17 GMT (envelope-from git) Date: Wed, 15 Dec 2021 01:55:17 GMT Message-Id: <202112150155.1BF1tHEl031756@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 4305fd126c77 - stable/13 - Kernel linkers: add emergency sysctl to restore old behavior List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 4305fd126c77143f3f3205e201ec413ae2012a0f Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639533317; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Se9heegIe0x+Eb6RelQHsu5/YMnVmyY2ocjtT6p5tHM=; b=iX5ZuoCZIItpox89WEe+ovneYCLvGhxrJ2i8nxmlSxU3lFh78uniZ9wiHtbTgZxCUF4VNi 6BLU8JvKzW36GPCuQoTn1G0qBpWyZrVnb4FVoInRVd7rXF6ntp5oQD1hw3HsvnB40a7X6E pFpW+DAQZxKFZBtxNa2XYIuU2/wSLTJzW/rptVt5DFhK6CVTdf4URRjIjii6irio6pL7Cs Zv/sVL28GkRRQqyZrewQY+pZnhPILT4OwcSIQ5k5xuyIN1pdUt+0jOWcDyfBoPmFJPOYT/ qCMHGC3vLLAlGw950pV+4AomcIUiPekIGNzsHJUT08OxjZsaJ2j3e40GsrYUaQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639533317; a=rsa-sha256; cv=none; b=eCTrWnoPmEX1FKJyj8OKybxmYoCBnZb9e14pNhxQ2JcSMoL8532+qaJLwvKpp3RdKamflu ZU5+AqhsdW439S08S4lNhz8GsR5ikLtORZhCtZOQI3CMOczF9Iar827kjzOyTub+/vVau+ EAnMGX8mEqaNp8Pqg6nEj+TWstl8Ggr4lbfbKR6yzfC4gVSUOqreZHcRRk7oiqw0DbEt14 pVFdEaf+YogWM1bEJJrKRjRo3y2X4oqkCOsjKsVseQ+ngPSzP+pCRniBSNnyqlmB2aOjm0 eUVBLjKkqIJ0wRtFlW9YLn3ezYAbULhCJ0MXj3TGCD6SYAgdsrV4JhnRhMM1kg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=4305fd126c77143f3f3205e201ec413ae2012a0f commit 4305fd126c77143f3f3205e201ec413ae2012a0f Author: Konstantin Belousov AuthorDate: 2021-11-07 09:26:26 +0000 Commit: Konstantin Belousov CommitDate: 2021-12-15 01:41:29 +0000 Kernel linkers: add emergency sysctl to restore old behavior PR: 207898 (cherry picked from commit ecd8245e0d7784bcd78dafce233f303eee765068) --- sys/kern/link_elf.c | 9 +++++++++ sys/kern/link_elf_obj.c | 12 ++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/sys/kern/link_elf.c b/sys/kern/link_elf.c index 445260246946..245c8697cf79 100644 --- a/sys/kern/link_elf.c +++ b/sys/kern/link_elf.c @@ -194,6 +194,11 @@ static struct linker_class link_elf_class = { link_elf_methods, sizeof(struct elf_file) }; +static bool link_elf_leak_locals = true; +SYSCTL_BOOL(_debug, OID_AUTO, link_elf_leak_locals, + CTLFLAG_RWTUN, &link_elf_leak_locals, 0, + "Allow local symbols to participate in global module symbol resolution"); + typedef int (*elf_reloc_fn)(linker_file_t lf, Elf_Addr relocbase, const void *data, int type, elf_lookup_fn lookup); @@ -1552,6 +1557,8 @@ link_elf_lookup_symbol1(linker_file_t lf, const char *name, c_linker_sym_t *sym, static int link_elf_lookup_symbol(linker_file_t lf, const char *name, c_linker_sym_t *sym) { + if (link_elf_leak_locals) + return (link_elf_lookup_debug_symbol(lf, name, sym)); return (link_elf_lookup_symbol1(lf, name, sym, false)); } @@ -1612,6 +1619,8 @@ static int link_elf_symbol_values(linker_file_t lf, c_linker_sym_t sym, linker_symval_t *symval) { + if (link_elf_leak_locals) + return (link_elf_debug_symbol_values(lf, sym, symval)); return (link_elf_symbol_values1(lf, sym, symval, false)); } diff --git a/sys/kern/link_elf_obj.c b/sys/kern/link_elf_obj.c index 2c1b7713c346..689aeae86840 100644 --- a/sys/kern/link_elf_obj.c +++ b/sys/kern/link_elf_obj.c @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -183,6 +184,11 @@ static struct linker_class link_elf_class = { link_elf_methods, sizeof(struct elf_file) }; +static bool link_elf_obj_leak_locals = true; +SYSCTL_BOOL(_debug, OID_AUTO, link_elf_obj_leak_locals, + CTLFLAG_RWTUN, &link_elf_obj_leak_locals, 0, + "Allow local symbols to participate in global module symbol resolution"); + static int relocate_file(elf_file_t ef); static void elf_obj_cleanup_globals_cache(elf_file_t); @@ -1455,7 +1461,8 @@ link_elf_lookup_symbol1(linker_file_t lf, const char *name, c_linker_sym_t *sym, static int link_elf_lookup_symbol(linker_file_t lf, const char *name, c_linker_sym_t *sym) { - return (link_elf_lookup_symbol1(lf, name, sym, false)); + return (link_elf_lookup_symbol1(lf, name, sym, + link_elf_obj_leak_locals)); } static int @@ -1494,7 +1501,8 @@ static int link_elf_symbol_values(linker_file_t lf, c_linker_sym_t sym, linker_symval_t *symval) { - return (link_elf_symbol_values1(lf, sym, symval, false)); + return (link_elf_symbol_values1(lf, sym, symval, + link_elf_obj_leak_locals)); } static int