Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 21 Oct 2022 14:18:04 +0200
From:      Kristof Provost <kp@FreeBSD.org>
To:        Konstantin Belousov <kib@FreeBSD.org>
Cc:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   Re: git: 9cabef3d146e - main - ldd: use direct exec mode unconditionally
Message-ID:  <7F982005-246F-4607-A17B-08C81CE65E0B@FreeBSD.org>
In-Reply-To: <202210061550.296FoVrm088661@gitrepo.freebsd.org>
References:  <202210061550.296FoVrm088661@gitrepo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--=_MailMate_88700A08-8CCC-47D7-900A-A7F6C692E0FB_=
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable

On 6 Oct 2022, at 17:50, Konstantin Belousov wrote:
> The branch main has been updated by kib:
>
> URL: =

> https://cgit.FreeBSD.org/src/commit/?id=3D9cabef3d146e9a844813b6bc8952d=
6cf2e9d45e5
>
> commit 9cabef3d146e9a844813b6bc8952d6cf2e9d45e5
> Author:     Konstantin Belousov <kib@FreeBSD.org>
> AuthorDate: 2022-09-21 13:55:44 +0000
> Commit:     Konstantin Belousov <kib@FreeBSD.org>
> 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
>
This appears to break things for armv7 (running on aarch64).

This manifests while building pfsense (for 3100 / armv7), which we do on =

an aarch64 vm (to avoid having to deal with qemu, and because it=E2=80=99=
s =

faster).

During that build a couple ports fail to build, including =

databases/sqlite3.
It fails running `/usr/bin/ldd -a =

"/wrkdirs/usr/ports/databases/sqlite3/work-default/stage/usr/local/bin/sq=
lite3" =

"/wrkdirs/usr/ports/databases/sqlite3/work-default/stage/usr/local/lib/li=
bsqlite3.so=E2=80=9D`, =

which produces:

	ld-elf.so.1: =

/wrkdirs/usr/ports/databases/sqlite3/work-default/stage/usr/local/bin/sql=
ite3: =

mmap of entire address space failed: Cannot allocate memory
	/wrkdirs/usr/ports/databases/sqlite3/work-default/stage/usr/local/bin/sq=
lite3: =

exit status 1

That fails doing the `mapbase =3D mmap(base_addr, mapsize, PROT_NONE, =

base_flags, -1, 0);` call in rtld-elf=E2=80=99s map_object():217. That ca=
ll =

does `mmap(0x10000, 0x1dc000, PROT_NONE, 0x6010, -1, 0) =3D> 0xffffffff`.=


With this patch reverted we can build successfully.

Best regards,
Kristof
--=_MailMate_88700A08-8CCC-47D7-900A-A7F6C692E0FB_=
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE html>
<html>
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/xhtml; charset=3Dutf-8"=
>
</head>
<body><div style=3D"font-family: sans-serif;"><div class=3D"markdown" sty=
le=3D"white-space: normal;">
<p dir=3D"auto">On 6 Oct 2022, at 17:50, Konstantin Belousov wrote:</p>
</div><div class=3D"plaintext" style=3D"white-space: normal;"><blockquote=
 style=3D"margin: 0 0 5px; padding-left: 5px; border-left: 2px solid #136=
BCE; color: #136BCE;"><p dir=3D"auto">The branch main has been updated by=
 kib:</p>
<p dir=3D"auto">URL: <a href=3D"https://cgit.FreeBSD.org/src/commit/?id=3D=
9cabef3d146e9a844813b6bc8952d6cf2e9d45e5">https://cgit.FreeBSD.org/src/co=
mmit/?id=3D9cabef3d146e9a844813b6bc8952d6cf2e9d45e5</a></p>
<p dir=3D"auto">commit 9cabef3d146e9a844813b6bc8952d6cf2e9d45e5
<br>
Author:     Konstantin Belousov &lt;kib@FreeBSD.org&gt;
<br>
AuthorDate: 2022-09-21 13:55:44 +0000
<br>
Commit:     Konstantin Belousov &lt;kib@FreeBSD.org&gt;
<br>
CommitDate: 2022-10-06 15:50:26 +0000</p>
<p dir=3D"auto">    ldd: use direct exec mode unconditionally</p>
<p dir=3D"auto">    Trying to exec malformed or unusual binary, for insta=
nce, a non-FreeBSD
<br>
    ABI, or using a non-standard interpreter, might give unexpected outco=
me.</p>
<p dir=3D"auto">    Reported by:    The UK's National Cyber Security Cent=
re (NCSC)
<br>
    Reviewed by:    emaste, markj, philip
<br>
    Discussed with: jhb
<br>
    Sponsored by:   The FreeBSD Foundation
<br>
    admbug: 991
<br>
    PR:     127276, 175339, 231926
<br>
    MFC after:      1 week
<br>
    Differential revision:  <a href=3D"https://reviews.freebsd.org/D36650=
">https://reviews.freebsd.org/D36650</a></p>;
<br></blockquote></div>
<div class=3D"markdown" style=3D"white-space: normal;">
<p dir=3D"auto">This appears to break things for armv7 (running on aarch6=
4).</p>
<p dir=3D"auto">This manifests while building pfsense (for 3100 / armv7),=
 which we do on an aarch64 vm (to avoid having to deal with qemu, and bec=
ause it=E2=80=99s faster).</p>
<p dir=3D"auto">During that build a couple ports fail to build, including=
 databases/sqlite3.<br>
It fails running <code style=3D"padding: 0 0.25em; background-color: #E4E=
4E4;">/usr/bin/ldd -a &quot;/wrkdirs/usr/ports/databases/sqlite3/work-def=
ault/stage/usr/local/bin/sqlite3&quot; &quot;/wrkdirs/usr/ports/databases=
/sqlite3/work-default/stage/usr/local/lib/libsqlite3.so=E2=80=9D</code>, =
which produces:</p>
<pre style=3D"margin-left: 15px; margin-right: 15px; padding: 5px; border=
: thin solid gray; overflow-x: auto; max-width: 90vw; background-color: #=
E4E4E4;"><code style=3D"padding: 0 0.25em; background-color: #E4E4E4;">ld=
-elf.so.1: /wrkdirs/usr/ports/databases/sqlite3/work-default/stage/usr/lo=
cal/bin/sqlite3: mmap of entire address space failed: Cannot allocate mem=
ory
/wrkdirs/usr/ports/databases/sqlite3/work-default/stage/usr/local/bin/sql=
ite3: exit status 1
</code></pre>
<p dir=3D"auto">That fails doing the <code style=3D"padding: 0 0.25em; ba=
ckground-color: #E4E4E4;">mapbase =3D mmap(base_addr, mapsize, PROT_NONE,=
 base_flags, -1, 0);</code> call in rtld-elf=E2=80=99s map_object():217. =
That call does <code style=3D"padding: 0 0.25em; background-color: #E4E4E=
4;">mmap(0x10000, 0x1dc000, PROT_NONE, 0x6010, -1, 0) =3D&gt; 0xffffffff<=
/code>.</p>
<p dir=3D"auto">With this patch reverted we can build successfully.</p>
<p dir=3D"auto">Best regards,<br>
Kristof</p>

</div>
</div>
</body>

</html>

--=_MailMate_88700A08-8CCC-47D7-900A-A7F6C692E0FB_=--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?7F982005-246F-4607-A17B-08C81CE65E0B>