public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: "H.J. Lu via Libc-alpha" <libc-alpha@sourceware.org>
Subject: Re: [PATCH] Add an internal wrapper for clone, clone2 and clone3
Date: Mon, 15 Feb 2021 15:27:39 +0100	[thread overview]
Message-ID: <87mtw59zj8.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <CAMe9rOpHC2X6PvDixhYY1kw3-BVg93CPjbQSgLmU9aR1cyhmUg@mail.gmail.com> (H. J. Lu's message of "Mon, 15 Feb 2021 06:17:16 -0800")

* H. J. Lu:

> On Mon, Feb 15, 2021 at 2:43 AM Florian Weimer <fweimer@redhat.com> wrote:
>>
>> * H. J. Lu via Libc-alpha:
>>
>> > The clone3 system call provides a superset of the functionality of clone
>> > and clone2.  It also provides a number of API improve ments, including
>> > the ability to specify the size of the child's stack area which can be
>> > used by kernel to compute the shadow stack size when allocating the
>> > shadow stack.  Add:
>> >
>> > extern int __clone_internal (struct clone_args *cl_args, size_t size,
>> >                            int (*__fn) (void *__arg), void *__arg);
>> >
>> > to provide an abstract interface for clone, clone2 and clone3.
>> >
>> > 1. Simplify stack management for clone by passing stack base and size
>> > to __clone_internal.
>> > 2. Consolidate clone vs clone2 differences into a single file.
>> > 3. Use only __clone_internal to clone a thread.  If clone3 returns -1
>> > with ENOSYS, __clone_internal will fall back to clone or clone2.
>> > 4. Add the x86-64 clone3 wrapper.
>> > 5. Enable the public clone3 wrapper in the future after it has been
>> > added to add targets.
>>
>> What do you think about providing a clone wrapper which reuses the
>> caller's stack?  That would be useful for a (v)fork-style clone.  This
>> variant could also be exported because the callback inherits a
>> semi-valid TCB in this case.
>
> Sure.  But all new clone wrappers should support clone3.

Through a single interface?  I'm not entirely convinced that this is
possible/desirable, given the differences in behavior.  There is also
the matter of seccomp filters, which have trouble reading userspace
memory.

Thanks,
Florian
-- 
Red Hat GmbH, https://de.redhat.com/ , Registered seat: Grasbrunn,
Commercial register: Amtsgericht Muenchen, HRB 153243,
Managing Directors: Charles Cachera, Brian Klemm, Laurie Krebs, Michael O'Neill


  reply	other threads:[~2021-02-15 14:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-14 22:45 H.J. Lu
2021-02-15 10:44 ` Florian Weimer
2021-02-15 14:17   ` H.J. Lu
2021-02-15 14:27     ` Florian Weimer [this message]
2021-02-15 14:44       ` H.J. Lu
2021-02-15 14:39   ` Adhemerval Zanella
2021-03-04 18:40     ` [PATCH v2] " H.J. Lu
2021-03-04 18:50       ` H.J. Lu
2021-03-05  8:32         ` Christian Brauner
2021-03-05 16:59           ` [PATCH v3] " H.J. Lu
2021-03-18 23:18             ` PING^1 " H.J. Lu
2021-04-19 12:56             ` H.J. Lu
2021-05-10  8:17             ` Florian Weimer
2021-05-10 23:56               ` H.J. Lu

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=87mtw59zj8.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=hjl.tools@gmail.com \
    --cc=libc-alpha@sourceware.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).