public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: Richard Purdie <richard.purdie@linuxfoundation.org>
Cc: libc-help@sourceware.org
Subject: Re: glibc 2.34 and Yocto Project's "uninative"
Date: Mon, 30 Aug 2021 02:55:29 -0400	[thread overview]
Message-ID: <YSyA4UtVAY/Ifp+y@vapier> (raw)
In-Reply-To: <978104bdbebcd09d159f1713499cf1315edf40f2.camel@linuxfoundation.org>

[-- Attachment #1: Type: text/plain, Size: 2995 bytes --]

On 20 Aug 2021 15:37, Richard Purdie via Libc-help wrote:
> Yocto Project is a cross compiling build system used to build customised
> Linux, RTOSs, firmware and more. It has some interesting technology. One piece
> of it is "pseudo" (http://git.yoctoproject.org/cgit.cgi/pseudo/) which is an 
> LD_PRELOAD which intercepts calls to libc and fakes root privileges. One way or
> another we've managed to keep that working with multiple libc versions for the
> last decade.

this sounds like Debian's fakeroot [1] & Gentoo's sandbox [2].  these have
always been a challenge to keep working, and to be complete.  they're always
"best effort" because they require:
(1) every program being dynamic.  any staticly linked programs won't work.
(2) every interesting call having an actual interception point by interposing
    known functions that the C library provides.  any calls the C library
    makes via PLT bypass cannot be captured, and any syscalls the C library
    or the app makes cannot be captured.
(3) a superset of every symbol (versioned & unversioned) that a C library
    might expose.  this in particular is messy.

[1] https://wiki.debian.org/FakeRoot
[2] https://wiki.gentoo.org/wiki/Sandbox_(Portage)

a tool using ptrace to intercept the syscall addresses all these, but at the
cost of being slower (since every syscall is notified).  if you can require
seccomp & Linux 3.5+, then things look a lot better here as you can setup a
seccomp filter for the process tree and only get notified for the exact set
of syscalls you're interested in.  it does mean you have to handle every
syscall wart across different architectures, but that's a bit easier to do
than all the variety of C library ABI warts.
(i'll ignore instability in the ptrace framework itself that we've observed
when using the interface at scale.)

i haven't reviewed the even newer seccomp notify [3] mechanism to see if
that's useful.  maybe that would offer even more relief.

[3] https://man7.org/linux/man-pages/man2/seccomp_unotify.2.html
[3] https://brauner.github.io/2020/07/23/seccomp-notify.html

> A second piece of technology is uninative. We build a lot binary artefacts, some
> for the target, some as tools running natively on the build system. We have a
> cache of these artefacts people can share and reuse. Uninative is our way of
> allowing one binary to run on any host distro. We do that by shipping a ld+libc
> binary shim and change the interpreter in the native binary to point at our own.
> As long as the shim is the same version or later than system version, it works.

we do this in CrOS with our toolchains by largely using pax-utils's lddtree [4].
it will bundle the active C library (and any other libs), and then generate a
wrapper shell script for each program that is actually executed at runtime.
that does the ldso & ldpath dance so it's all relocatable.

[4] https://gitweb.gentoo.org/proj/pax-utils.git/tree/lddtree.py
-mike

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

      parent reply	other threads:[~2021-08-30  1:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-20 14:37 Richard Purdie
2021-08-25 15:05 ` Adhemerval Zanella
2021-08-25 20:11   ` Richard Purdie
2021-08-26 11:16     ` Adhemerval Zanella
2021-08-26 11:29       ` Richard Purdie
2021-08-30  6:55 ` Mike Frysinger [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YSyA4UtVAY/Ifp+y@vapier \
    --to=vapier@gentoo.org \
    --cc=libc-help@sourceware.org \
    --cc=richard.purdie@linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).