From nobody Mon Jun 8 17:03:31 2026 X-Original-To: dev-commits-src-main@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 4gYyzl6Hkdz6gNZ0 for ; Mon, 08 Jun 2026 17:03: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 "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gYyzl5dgZz3GHJ for ; Mon, 08 Jun 2026 17:03:31 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1780938211; 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=st2N3Qc7ESjB0jQnwJ/y/YVqcqeFwL69d/byrbIoukM=; b=sdKxFKrfwm23nhJsk695E9MXYRPum3uE7QohWlfNPEiFRHlHaWOX7OtnlE1YH/0MvekdcB sw9Z6RbEzuKFqh4l2ai8nGM59BAym7L5kn94wGGXF5Y8vptIzkDCfQSb42eLyEPEAR7QAw OT/hGMOr50TffiXm/p11I9LfH9y/87HPSiU+E4h8lriEvymtQ8wjF92qnbyGy34acU3HLB xUDqtCBmfVFkSSg1ggP7BkWk9P+7CfsDa2I2MzhhF07n79jZjHjqwyPqtvOuYkK12/8P5M ANd0z2j57C8mefmt9v65GJvAwVodSTvUJvxIVLZmMA4BfkdGaeomhAwRdLa1mg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1780938211; a=rsa-sha256; cv=none; b=j3KQn7XUjyBj93dNCwO5LFHz9zucgl5omzz3PUK0uci6PEfaIixkZZw7BQy/c7ANZP871f AYL68MEIWyTEDoKhB1oKTF40vlfg3jRdxP4g/BJCUg1v3qW1+5TXy7Jp6DXdEQqNUHTrHb 79FxqYf6E4MW8MNbhydde3u8TsT8Hi55pC3DgwgBggbDB6WcuYxzjZn7vb71lRqEYS62PR X31YL67PrU93lH8hH1WEen5iZQTM+a4D8gEkd75gavZ9iuQkQ45iMwReewOSrLvDsD+W8q JkbtUmlvifd8u7sisrkuNB8pNS8+n5HTOvRpOqS2nZdROilsCswskrPn7at2IQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1780938211; 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=st2N3Qc7ESjB0jQnwJ/y/YVqcqeFwL69d/byrbIoukM=; b=OwPSyt7zK3PAhZ/xsvGEfKglyabBbPiZ70EcEhZz7RhALV1zWtbJJZ7sw0PWFs9nI6VJ51 KgxqWOEhXyhFZbp5AReWE1VqfApBYLgjfvnBF5ZnTrT9T0+Pf6u9WbQZ7arWwJk4pfy/Z3 0y4BHenW664pLyWsbU1MNRUTDvmTvsZ0XMI8VKGebVPxL4kcwO0h91u7cP0AVWQp1NpQ3D ofjjWsdj3YfXIQ7h1PWkAuDPbs97jmaWkRDQ6+IdSGs1aG0ZZsFYjjd4e+8yvaYmeMThcA mIeO5V/+psBfZwvRvJt8ZLuvctJ+SCXq/Uj2n4coq1uciAzQdAevqAJGfVGizQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gYyzl58zrzx2M for ; Mon, 08 Jun 2026 17:03:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 25edf by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 08 Jun 2026 17:03:31 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 0b269737f9ca - main - imgact_elf: handle unaligned phdrs List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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: 0b269737f9ca057826a6c9376c2474b1ae5bc91c Auto-Submitted: auto-generated Date: Mon, 08 Jun 2026 17:03:31 +0000 Message-Id: <6a26f5e3.25edf.4c6a5357@gitrepo.freebsd.org> The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=0b269737f9ca057826a6c9376c2474b1ae5bc91c commit 0b269737f9ca057826a6c9376c2474b1ae5bc91c Author: Konstantin Belousov AuthorDate: 2026-06-08 01:22:51 +0000 Commit: Konstantin Belousov CommitDate: 2026-06-08 17:02:13 +0000 imgact_elf: handle unaligned phdrs Althought non-compliant, there are binaries which have the phdrs placed unaligned in the image. Since we have the code to allocate memory for off-page phdrs, the same code path can be used to handle unaligned phdrs. Relax the requirement for both the activated image and interpreter. PR: 295629 Reviewed by: emaste, markj, olce Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D57498 --- sys/kern/imgact_elf.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index b889c4a14866..46908f01097b 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -858,12 +858,12 @@ __elfN(load_file)(struct thread *td, const char *file, u_long *addr, goto fail; } - if (!aligned(imgp->image_header + hdr->e_phoff, Elf_Addr) || - hdr->e_phnum > __elfN(phnums)) { + if (hdr->e_phnum > __elfN(phnums)) { error = ENOEXEC; goto fail; } - if (__elfN(phdr_in_zero_page)(hdr)) { + if (__elfN(phdr_in_zero_page)(hdr) && + aligned(imgp->image_header + hdr->e_phoff, Elf_Addr)) { phdr = (const Elf_Phdr *)(imgp->image_header + hdr->e_phoff); } else { VOP_UNLOCK(imgp->vp); @@ -1157,10 +1157,6 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp) free_interp = false; m_phdrs = NULL; - if (!aligned(imgp->image_header + hdr->e_phoff, Elf_Addr)) { - uprintf("Unaligned program headers\n"); - return (ENOEXEC); - } if (hdr->e_phoff + hdr->e_phnum * hdr->e_phentsize < hdr->e_phoff) { uprintf("PHDRS wrap\n"); return (ENOEXEC); @@ -1170,7 +1166,8 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp) hdr->e_phnum, __elfN(phnums)); return (ENOEXEC); } - if (__elfN(phdr_in_zero_page)(hdr)) { + if (__elfN(phdr_in_zero_page)(hdr) && + aligned(imgp->image_header + hdr->e_phoff, Elf_Addr)) { phdr = (const Elf_Phdr *)(imgp->image_header + hdr->e_phoff); } else { VOP_UNLOCK(imgp->vp);