Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 14 Apr 2024 18:06:16 -0600
From:      Warner Losh <imp@bsdimp.com>
To:        Shawn Webb <shawn.webb@hardenedbsd.org>
Cc:        FreeBSD Hackers <freebsd-hackers@freebsd.org>
Subject:   Re: Question regarding crunchgen(1) binaries
Message-ID:  <CANCZdfoMaL%2B=yeAcwmVLL1fo5iRUNZJwikL5AfjvOGF1XEAtKA@mail.gmail.com>
In-Reply-To: <erhqcnky6qf4adlupgtszkmrihthbdc2tbwtbhgzyltl3pl42c@gsdzinackzhh>
References:  <erhqcnky6qf4adlupgtszkmrihthbdc2tbwtbhgzyltl3pl42c@gsdzinackzhh>

next in thread | previous in thread | raw e-mail | index | archive | help
--000000000000acb33e061617646b
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Sun, Apr 14, 2024, 5:43=E2=80=AFPM Shawn Webb <shawn.webb@hardenedbsd.or=
g> wrote:

> Hey FreeBSD Hackers,
>
> Note: I originally posted this to the HardenedBSD users mailing list.
> I'm posting to freebsd-hackers@ to hopefully learn from a wider
> audience.
>
> I wanted to ping the HardenedBSD community, asking about the
> usefulness of crunchgen(1)-built applications in 2024.
>

For FreeBSD they are quite useful still. The HardenedBSD community can make
up its own mind.

>From the crunchgen(1) manual page:
>
> > The main reason to crunch programs together is for fitting as many
> > programs as possible onto an installation or system recovery floppy.
>

Floppy is antiquated. /resur hasn't fit on a floppy since FreeBSD 3 or so.
Yet, it's still useful to have a tiny ramdisk that's either recovery or
simple servers only.

The binaries in /rescue are built with crunchgen. It seems that
> crunchgen-built applications are not (currently) compatible with a
> libc built with LTO due to the recent CSU and libc changes.
>

PR? Seems is aweful vague.

The size of the binaries in /rescue on HardenedBSD 15-CURRENT/amd64
> are 17MB in size. That application size alone makes it impossible to
> build a "system recovery floppy". Additionally, floppy drives aren't
> all too common on the amd64, arm64, and riscv64 systems HardenedBSD
> targets.
>

Don't take floppy litterally here.

Control Flow Integrity (CFI) is a compiler-based exploit mitigation
> that we apply to applications in HardenedBSD 15-CURRENT and 14-STABLE.
> In order to apply CFI to applications, application code must be built
> with Link Time Optimization (LTO).
>
> Over the past few years, I've slowly been working on applying CFI to
> shared objects (aka, Cross-DSO CFI). This requires building library
> code with LTO as well.
>
> It seems that with the recent changes to the CSU and libc, the
> crunchgen(1) built tool does not produce workable applications when
> libc is built with LTO. With libc having such a huge surface area, it
> would be prudent to apply Cross-DSO CFI to it.
>

PR?

This presents two possible solutions:
>
> 1. Enhance crunchgen(1) to support libc built with LTO.
> 2. Kick crunchgen(1) to the curb.
> 3. Other ideas from the community are possible.
>
> Does anyone find crunchgen(1) to be truly useful in 2024? If we kick
> crunchgen(1) to the curb, we need to modify the build system for
> /rescue binaries.
>
> My own preference would indeed to rid ourselves of crunchgen(1) so
> that we can progress towards applying Cross-DSO CFI and LTO to libc.
>

/rescue is still the last line of defence against botched libc updates. We
use it for rare cases where /usr isn't mounted yet and moving binaries is
too hard in rc.

Crunchgen'd binaries make the cost trivial. Plus, I have several appliances
that are a RAM disk with one crunchgen binary. It makes deployment easy,
but I know

I'm stongly opposed to kicking crunchgen to the curb. It's still quite
useful and the reasons proffered are vague and seem little more than LTO
bugs...

So I'm for (3) fixing LTO to not suck. The attack mitigation is a good
feature, but it's not worth killing resue over...

But my comments are explicitly in a FreeBSD context.

Warner



Thanks,
>
> --
> Shawn Webb
> Cofounder / Security Engineer
> HardenedBSD
>
> Tor-ified Signal: +1 303-901-1600 / shawn_webb_opsec.50
>
> https://git.hardenedbsd.org/hardenedbsd/pubkeys/-/raw/master/Shawn_Webb/0=
3A4CBEBB82EA5A67D9F3853FF2E67A277F8E1FA.pub.asc
>

--000000000000acb33e061617646b
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"auto"><div><br><br><div class=3D"gmail_quote"><div dir=3D"ltr" =
class=3D"gmail_attr">On Sun, Apr 14, 2024, 5:43=E2=80=AFPM Shawn Webb &lt;<=
a href=3D"mailto:shawn.webb@hardenedbsd.org">shawn.webb@hardenedbsd.org</a>=
&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 =
0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hey FreeBSD Hackers,<br=
>
<br>
Note: I originally posted this to the HardenedBSD users mailing list.<br>
I&#39;m posting to freebsd-hackers@ to hopefully learn from a wider<br>
audience.<br>
<br>
I wanted to ping the HardenedBSD community, asking about the<br>
usefulness of crunchgen(1)-built applications in 2024.<br></blockquote></di=
v></div><div dir=3D"auto"><br></div><div dir=3D"auto">For FreeBSD they are =
quite useful still. The HardenedBSD community can make up its own mind.</di=
v><div dir=3D"auto"><br></div><div dir=3D"auto"><div class=3D"gmail_quote">=
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">
>From the crunchgen(1) manual page:<br>
<br>
&gt; The main reason to crunch programs together is for fitting as many<br>
&gt; programs as possible onto an installation or system recovery floppy.<b=
r></blockquote></div></div><div dir=3D"auto"><br></div><div dir=3D"auto">Fl=
oppy is antiquated. /resur hasn&#39;t fit on a floppy since FreeBSD 3 or so=
. Yet, it&#39;s still useful to have a tiny ramdisk that&#39;s either recov=
ery or simple servers only.</div><div dir=3D"auto"><br></div><div dir=3D"au=
to"><div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"m=
argin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The binaries in /rescue are built with crunchgen. It seems that<br>
crunchgen-built applications are not (currently) compatible with a<br>
libc built with LTO due to the recent CSU and libc changes.<br></blockquote=
></div></div><div dir=3D"auto"><br></div><div dir=3D"auto">PR? Seems is awe=
ful vague.</div><div dir=3D"auto"><br></div><div dir=3D"auto"><div class=3D=
"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;=
border-left:1px #ccc solid;padding-left:1ex">
The size of the binaries in /rescue on HardenedBSD 15-CURRENT/amd64<br>
are 17MB in size. That application size alone makes it impossible to<br>
build a &quot;system recovery floppy&quot;. Additionally, floppy drives are=
n&#39;t<br>
all too common on the amd64, arm64, and riscv64 systems HardenedBSD<br>
targets.<br></blockquote></div></div><div dir=3D"auto"><br></div><div dir=
=3D"auto">Don&#39;t take floppy litterally here.</div><div dir=3D"auto"><br=
></div><div dir=3D"auto"><div class=3D"gmail_quote"><blockquote class=3D"gm=
ail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-le=
ft:1ex">
Control Flow Integrity (CFI) is a compiler-based exploit mitigation<br>
that we apply to applications in HardenedBSD 15-CURRENT and 14-STABLE.<br>
In order to apply CFI to applications, application code must be built<br>
with Link Time Optimization (LTO).<br>
<br>
Over the past few years, I&#39;ve slowly been working on applying CFI to<br=
>
shared objects (aka, Cross-DSO CFI). This requires building library<br>
code with LTO as well.<br>
<br>
It seems that with the recent changes to the CSU and libc, the<br>
crunchgen(1) built tool does not produce workable applications when<br>
libc is built with LTO. With libc having such a huge surface area, it<br>
would be prudent to apply Cross-DSO CFI to it.<br></blockquote></div></div>=
<div dir=3D"auto"><br></div><div dir=3D"auto">PR?</div><div dir=3D"auto"><b=
r></div><div dir=3D"auto"><div class=3D"gmail_quote"><blockquote class=3D"g=
mail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-l=
eft:1ex">
This presents two possible solutions:<br>
<br>
1. Enhance crunchgen(1) to support libc built with LTO.<br>
2. Kick crunchgen(1) to the curb.<br>
3. Other ideas from the community are possible.<br>
<br>
Does anyone find crunchgen(1) to be truly useful in 2024? If we kick<br>
crunchgen(1) to the curb, we need to modify the build system for<br>
/rescue binaries.<br>
<br>
My own preference would indeed to rid ourselves of crunchgen(1) so<br>
that we can progress towards applying Cross-DSO CFI and LTO to libc.<br></b=
lockquote></div></div><div dir=3D"auto"><br></div><div dir=3D"auto">/rescue=
 is still the last line of defence against botched libc updates. We use it =
for rare cases where /usr isn&#39;t mounted yet and moving binaries is too =
hard in rc.</div><div dir=3D"auto"><br></div><div dir=3D"auto">Crunchgen&#3=
9;d binaries make the cost trivial. Plus, I have several appliances that ar=
e a RAM disk with one crunchgen binary. It makes deployment easy, but I kno=
w=C2=A0</div><div dir=3D"auto"><br></div><div dir=3D"auto">I&#39;m stongly =
opposed to kicking crunchgen to the curb. It&#39;s still quite useful and t=
he reasons proffered are vague and seem little more than LTO bugs...</div><=
div dir=3D"auto"><br></div><div dir=3D"auto">So I&#39;m for (3) fixing LTO =
to not suck. The attack mitigation is a good feature, but it&#39;s not wort=
h killing resue over...</div><div dir=3D"auto"><br></div><div dir=3D"auto">=
But my comments are explicitly in a FreeBSD context.</div><div dir=3D"auto"=
><br></div><div dir=3D"auto">Warner</div><div dir=3D"auto"><br></div><div d=
ir=3D"auto"><br></div><div dir=3D"auto"><br></div><div dir=3D"auto"><div cl=
ass=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0=
 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Thanks,<br>
<br>
-- <br>
Shawn Webb<br>
Cofounder / Security Engineer<br>
HardenedBSD<br>
<br>
Tor-ified Signal: +1 303-901-1600 / shawn_webb_opsec.50<br>
<a href=3D"https://git.hardenedbsd.org/hardenedbsd/pubkeys/-/raw/master/Sha=
wn_Webb/03A4CBEBB82EA5A67D9F3853FF2E67A277F8E1FA.pub.asc" rel=3D"noreferrer=
 noreferrer" target=3D"_blank">https://git.hardenedbsd.org/hardenedbsd/pubk=
eys/-/raw/master/Shawn_Webb/03A4CBEBB82EA5A67D9F3853FF2E67A277F8E1FA.pub.as=
c</a><br>
</blockquote></div></div></div>

--000000000000acb33e061617646b--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CANCZdfoMaL%2B=yeAcwmVLL1fo5iRUNZJwikL5AfjvOGF1XEAtKA>