From nobody Thu Oct 06 15:50:31 2022 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 4MjwrR4w2qz4dsqB; Thu, 6 Oct 2022 15:50:31 +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 4MjwrR4Mvjz3QPX; Thu, 6 Oct 2022 15:50:31 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665071431; 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=IP/GtamZc3tD5yMxSM6F2A+OKCa+FZBvEHcTffs5GMg=; b=GORVFTgEf0jSO4emOmuOtIZs20BinmiuJIEFbvjtZj1c2JAXkNyIWtzwK+Lpmoi25gbU8b G60xvwdu5Uekmim+xv1rWAaDvgmDeEZ1p3cnKDneKblMaFTLMPv4lf2YA4IdzeAhU1juFF OfqrIEjMWaj0GMFF0RJUB7PKJR+WbNOwREoXm4lJYhzJoziqzslANAmx6P/4RoLQwUeXzi T/H0rjWMU7lFh9Uh+CXTmEzCsYDHTApp276LZOfjoWV2XOaE8CQQkaFMP6ojGc5MbT6vQE qSu0knw3wbmVHuONAT9tGwtosNJCg83/4EcH+jbVMnrP0fOkhQ85Oii2BoV/Lw== 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 4MjwrR3PvgzJ17; Thu, 6 Oct 2022 15:50:31 +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 296FoVC1088662; Thu, 6 Oct 2022 15:50:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 296FoVrm088661; Thu, 6 Oct 2022 15:50:31 GMT (envelope-from git) Date: Thu, 6 Oct 2022 15:50:31 GMT Message-Id: <202210061550.296FoVrm088661@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 9cabef3d146e - main - ldd: use direct exec mode unconditionally 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/main X-Git-Reftype: branch X-Git-Commit: 9cabef3d146e9a844813b6bc8952d6cf2e9d45e5 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665071431; 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=IP/GtamZc3tD5yMxSM6F2A+OKCa+FZBvEHcTffs5GMg=; b=o+nho5IQnje6sJrP99KeC46opQ5UmZsus3CrQ8XFQBk3Sx7JmCc3wWBQMx/NDAnszvgL8O mIF/sxCYcUCs28srnGkSFieW/BUYjD9+4+MHnxYEqen4IhVmKlJaNx3bX8YVKUNv4NFPAw DZV9v4pQ71FQcQ1DmAWC+lUQ7e8RWpAJpBIVYWU1XBAGX0uv4ZkdgZxE8K00g2H60/EKLz mfCTOV/8smYAGoJM2oEa1yBHekvmb/DHw1o6ahC+DoCWot1/XygLYLvYCNMsQlu+EjWEqN bdIprY/y0TtO1t1WaQ6EUc0K0Gjo+oEHyLxeD+17DQ1APRUh27RK98eTGcWjpg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1665071431; a=rsa-sha256; cv=none; b=XZ9aZxdP0sZ7PbGRVBSGxdHNQN3wXECXYwoFU6vndyW5Z+ARsKhyBe1waDTQqgkKoy5I7z noDWJ4r6ud8lIrjiw6PWxbazI8FtHLClBbj6WKMl17/6WrUWpD2lOwS/HJjD36YnmqT/dJ 2ze3LkpRxvdzoVFOhx7WPTPYjuyvxZqQ579ikeJN3do8Dq/ybFhDft2qiyErJpp/lkO5dp 8uej/qqaInXnZwh85Qiob4lcYdrbwicSI4u3/jnURf7KYWVetCEuRrAMe47U4ukn08o/OL GD8C/Y2A0xChgF2SbztmZA0nD145R+7zMotmsymIhCVm/ngLOQny1th8p3c7Lw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=9cabef3d146e9a844813b6bc8952d6cf2e9d45e5 commit 9cabef3d146e9a844813b6bc8952d6cf2e9d45e5 Author: Konstantin Belousov AuthorDate: 2022-09-21 13:55:44 +0000 Commit: Konstantin Belousov CommitDate: 2022-10-06 15:50:26 +0000 ldd: use direct exec mode unconditionally Trying to exec malformed or unusual binary, for instance, a non-FreeBSD ABI, or using a non-standard interpreter, might give unexpected outcome. Reported by: The UK's National Cyber Security Centre (NCSC) Reviewed by: emaste, markj, philip Discussed with: jhb Sponsored by: The FreeBSD Foundation admbug: 991 PR: 127276, 175339, 231926 MFC after: 1 week Differential revision: https://reviews.freebsd.org/D36650 --- usr.bin/ldd/ldd.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/usr.bin/ldd/ldd.c b/usr.bin/ldd/ldd.c index c16b6f5e8496..8897c8cbfbc2 100644 --- a/usr.bin/ldd/ldd.c +++ b/usr.bin/ldd/ldd.c @@ -233,18 +233,19 @@ main(int argc, char *argv[]) } break; case 0: + rtld = _PATH_RTLD; +#if __ELF_WORD_SIZE > 32 && defined(ELF32_SUPPORTED) + if (type == TYPE_ELF32) + rtld = _COMPAT32_PATH_RTLD; +#endif if (is_shlib == 0) { - execl(*argv, *argv, (char *)NULL); + execl(rtld, rtld, "--", + *argv, (char *)NULL); warn("%s", *argv); } else if (fmt1 == NULL && fmt2 == NULL && !aflag) { dlopen(*argv, RTLD_TRACE); warnx("%s: %s", *argv, dlerror()); } else { - rtld = _PATH_RTLD; -#if __ELF_WORD_SIZE > 32 && defined(ELF32_SUPPORTED) - if (type == TYPE_ELF32) - rtld = _COMPAT32_PATH_RTLD; -#endif execl(rtld, rtld, "-d", "--", *argv, (char *)NULL); }