Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > muc.lists.freebsd.emulation > #12972

[Bug 295629] Linuxlator fails to run the linux x86_64 binary: Program headers not in the first page

Path csiph.com!weretis.net!feeder8.news.weretis.net!3.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.space.net!news.muc.de!.POSTED.news.muc.de!not-for-mail
From bugzilla-noreply@freebsd.org
Newsgroups muc.lists.freebsd.emulation
Subject [Bug 295629] Linuxlator fails to run the linux x86_64 binary: Program headers not in the first page
Date Thu, 28 May 2026 05:02:28 +0000
Organization Newsgate at muc.de e.V.
Sender owner-freebsd-emulation@FreeBSD.org
Approved news-admin@muc.de
Distribution world
Message-ID <bug-295629-4077-0RNDRfLWSx@https.bugs.freebsd.org/bugzilla/> (permalink)
References <bug-295629-4077@https.bugs.freebsd.org/bugzilla/>
MIME-Version 1.0
Content-Type text/plain; charset="UTF-8"
Content-Transfer-Encoding quoted-printable
Injection-Info news.muc.de; posting-host="news.muc.de:193.149.48.2"; logging-data="30929"; mail-complaints-to="news-admin@muc.de"
X-Original-To emulation@mlmmj.nyi.freebsd.org
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1779944549; 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: in-reply-to:in-reply-to:references:references; bh=3e6LpPn/X34kiO4ueeGMGpeZiuNhLSOpzYCy6687Smg=; b=CREbpDGWenBLdpWQTBIHMqxLXKEYopPJkSdj4ozdG1iLsoK9AYEDjowcJvHU15a9FGkM0E D9tv443XzVMWj46nfzZr7D9YycsdkyWx2asLhC13hz0yBlWIVbtZkglQ0iuFkeOardI/wP YrlJzUFjpgYzyZgOhKqflVEgGHEiFJilcZ935WjXt1ByfBa8YBm3mInAssI8cXKFPgKMwu AC424YivpfcUPfkGxjVjKXc2hkl2F0qGiXmzr266lP9p/eag/OhMioTdT7n45+QTixHffi QUS2TJaGaHVP0qLuD4VfgN7T1Ag7ilNPENRwqWeaG+XVyewAiQi3sQcVQhyLTg==
X-Authentication-Warning kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f
In-Reply-To <bug-295629-4077@https.bugs.freebsd.org/bugzilla/>
Auto-Submitted auto-generated
Precedence list
X-Newsgate-Id f02c70b8849f+
X-No-Archive Yes
Xref csiph.com muc.lists.freebsd.emulation:12972

Show key headers only | View raw


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=295629

--- Comment #3 from Yuri Victorovich <yuri@freebsd.org> ---
Here is the problem analysis:

 Root Cause

  The copilot binary has an extremely non-standard ELF layout where the program
header table is placed at file offset 45,904,260 bytes (~44 MB into the file):

   Start of program headers:  45904260 (bytes into file)  # e_phoff = 0x2BC7184

  FreeBSD's ELF loader in sys/kern/imgact_elf.c enforces this check:

   static bool
   __elfN(phdr_in_zero_page)(const Elf_Ehdr *hdr)
   {
       return (hdr->e_phoff <= PAGE_SIZE &&
           (u_int)hdr->e_phentsize * hdr->e_phnum <= PAGE_SIZE - hdr->e_phoff);
   }

  This requires:

   1. e_phoff ≤ PAGE_SIZE (4096) — FAILS: 45,904,260 >> 4,096
   2. All program headers fit in the remainder of the first page

  The kernel only maps the first page of an executable into imgp->image_header
and immediately dereferences program headers from that buffer
(imgp->image_header + hdr->e_phoff). If e_phoff
  points beyond page 0, the data isn't there.

  Linux's kernel is different: load_elf_binary() uses kernel_read() to read
program headers at whatever offset e_phoff specifies, so it handles this layout
fine.

  Why is the binary like this?

  The copilot binary (a Go binary) is built with debug info embedded, and has
an unusual segment layout — its first LOAD segment covers 0x3315b0 (~3.1 MB) of
read-only data placed before
  the executable code, with the program header table appended after most of the
file content rather than near the ELF header. In a normal ELF binary, e_phoff =
64 (immediately after the
  64-byte ELF header).

  Kernel fix: Extend FreeBSD's ELF loader to use vn_rdwr to read program
headers at arbitrary offsets (like Linux does), instead of requiring them in
the first page.

-- 
You are receiving this mail because:
You are the assignee for the bug.

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de

Back to muc.lists.freebsd.emulation | Previous | Next | Find similar | Unroll thread


Thread

[Bug 295629] Linuxlator fails to run the linux x86_64 binary: Program headers not in the first page bugzilla-noreply@freebsd.org - 2026-05-28 05:02 +0000

csiph-web