From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id BF7F83861010 for ; Mon, 15 Feb 2021 10:43:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BF7F83861010 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-296-mQmIUGWdM9KaDYaaTDMPfw-1; Mon, 15 Feb 2021 05:43:49 -0500 X-MC-Unique: mQmIUGWdM9KaDYaaTDMPfw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B5B63801965; Mon, 15 Feb 2021 10:43:48 +0000 (UTC) Received: from oldenburg.str.redhat.com (ovpn-113-131.ams2.redhat.com [10.36.113.131]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 066EC60C5F; Mon, 15 Feb 2021 10:43:47 +0000 (UTC) From: Florian Weimer To: "H.J. Lu via Libc-alpha" Subject: Re: [PATCH] Add an internal wrapper for clone, clone2 and clone3 References: <20210214224505.4448-1-hjl.tools@gmail.com> Date: Mon, 15 Feb 2021 11:44:15 +0100 In-Reply-To: <20210214224505.4448-1-hjl.tools@gmail.com> (H. J. Lu via Libc-alpha's message of "Sun, 14 Feb 2021 14:45:05 -0800") Message-ID: <87r1lhehkw.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-6.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_NUMSUBJECT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Feb 2021 10:43:53 -0000 * 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. 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