From nobody Mon Oct 17 15:40:54 2022 X-Original-To: dev-commits-src-branches@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 4Mrh6G4vykz4gDK3; Mon, 17 Oct 2022 15:40:54 +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 4Mrh6G3F26z3Nr7; Mon, 17 Oct 2022 15:40:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666021254; 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=WUnUctcqhrl9mNAzbhpkhx99L3OE6EEmDZK/s5K9Iho=; b=xpg6jT/Nv0FjEh5jny9BfHdaewDE6kjWO1WbNaVVVVGkW1dwmqf+tdxy2p2Fo2b0bzzrFt 4Qtp5HRZpS/bCy8DPRUxZPGv2BAGuzPEdVUrw1BW4HYXmIy6gK5zSw9x5PMqXVJJ+00wVw NEjq+RY4KbNra3J1SoVV+gTqVl8gSzPHFR4PpX8fukHQ4hBpTDghrZW7vU+hFBKPvYyT8E DAg87bjcVzlTPSe21XjPoFCidwmd/8yYTOxC77wSXESqFbcFvNXgNWvWg18tzWpqd0Z6Jp LdfctYTXF52AQ94rDu2BrQGOefVVq2nNtpSkRu/AFKXQgEkOxC7HAH03DEaO8Q== 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 4Mrh6G2Lshzsns; Mon, 17 Oct 2022 15:40:54 +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 29HFes0g016496; Mon, 17 Oct 2022 15:40:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 29HFesFR016495; Mon, 17 Oct 2022 15:40:54 GMT (envelope-from git) Date: Mon, 17 Oct 2022 15:40:54 GMT Message-Id: <202210171540.29HFesFR016495@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kyle Evans Subject: git: 2b31059ea701 - stable/13 - loader: fix elf lookup_symbol type filtering List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 2b31059ea701957584e68a75857206d80a230211 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666021254; 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=WUnUctcqhrl9mNAzbhpkhx99L3OE6EEmDZK/s5K9Iho=; b=jXwc1nGJ6PBb9tdnWYVq76OmS7Fr7fRWAh72OFpVzLrYYQzN5OZdLWMz5/siOK1a+CTa0j Qq9MV4unmvWB6+bcUsN+xTjGl3Kpy5K+8ZaNQn+wtamGTp3vvBFtftjVZ0pRttOSxSQb4y pEtEIF58leXVJOGpvrtFLtrVVLfDV5yo0W9RlQUkX3vewcOIloo3g11X++CfBAuDkGAFSl mm4phbAWrkhRN2rTJYGfEiWH7vv5K643Umltiwon3Ce6oO4gD+Y5aopqjxf4NMPTXizTYH MVF6ci+1GU6NhDWoELr0MRSAa+IJH6tFL8ps9lpl8VXWNc8OebnC8PJvp+Xn8w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1666021254; a=rsa-sha256; cv=none; b=XSHORfKka/k4+mQLAtS4ZEU3nKrKmNzVbOkCPxcCN6YzRgooEwaaGEE39EKGw1kJzTHd3F Cf1e23SjCtaSYyCHUCqh4MBDEA3v6vt2Ejleym5/ipN1fV8RRHkShNZvhNp21pSfnDSX7E PICSOvD0l9rlCx7IcDMD0C5UtDegVPmyu/+DQa3fbsTm4Aq5aO52/uHrIbmeJst7xJMoBm 0yl9FRiF2pq0nZ6+zKxpJM7tDR68iVlqbXVZWJMdokHc65TWRP5olOFBHiO14kwm5aZIRJ 0pXrsnU4l7ElwCA6gbyWZKjBbIylhVAJRrcuMBSEijXGtHxAqniWcNoM5w2Qxg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=2b31059ea701957584e68a75857206d80a230211 commit 2b31059ea701957584e68a75857206d80a230211 Author: Kyle Evans AuthorDate: 2022-10-14 03:06:13 +0000 Commit: Kyle Evans CommitDate: 2022-10-17 15:40:41 +0000 loader: fix elf lookup_symbol type filtering The existing logic doesn't seem to make much sense, as we won't filter on the type if st_shndx != SHN_UNDEF. In practice, this breaks booting 12.3 kernels on newer loaders, as they do have a `kernphys` symbol of the wrong type (NOTYPE, rather than OBJECT) -- we end up deriving the wrong value for copy_staging. It's unclear if this version makes any more sense, but it seems to match what rtld's matched_symbol() does. Loader doesn't need to care about STT_FUNC w/ UND shndx, because we won't encounter those; in kmods, undefined (kernel) functions are NOTYPE. Reported by: Christian McDonald Reviewed by: imp, kib, tsoome (cherry picked from commit 0701dbda94f21de8ddab3113f79262a26cc7b96c) --- stand/common/load_elf.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/stand/common/load_elf.c b/stand/common/load_elf.c index d8fad9df994b..7454c550c7f2 100644 --- a/stand/common/load_elf.c +++ b/stand/common/load_elf.c @@ -1258,9 +1258,8 @@ __elfN(lookup_symbol)(elf_file_t ef, const char* name, Elf_Sym *symp, strp = strdupout((vm_offset_t)(ef->strtab + sym.st_name)); if (strcmp(name, strp) == 0) { free(strp); - if (sym.st_shndx != SHN_UNDEF || - (sym.st_value != 0 && - ELF_ST_TYPE(sym.st_info) == type)) { + if (sym.st_shndx != SHN_UNDEF && sym.st_value != 0 && + ELF_ST_TYPE(sym.st_info) == type) { *symp = sym; return 0; }