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 [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 899F0394D8FE for ; Mon, 15 Feb 2021 14:27:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 899F0394D8FE 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-535-Bsx5VyYaN8a05opMkTBLLQ-1; Mon, 15 Feb 2021 09:27:14 -0500 X-MC-Unique: Bsx5VyYaN8a05opMkTBLLQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 580E61966320; Mon, 15 Feb 2021 14:27:13 +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 7F32060875; Mon, 15 Feb 2021 14:27:12 +0000 (UTC) From: Florian Weimer To: "H.J. Lu" Cc: "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> <87r1lhehkw.fsf@oldenburg.str.redhat.com> Date: Mon, 15 Feb 2021 15:27:39 +0100 In-Reply-To: (H. J. Lu's message of "Mon, 15 Feb 2021 06:17:16 -0800") Message-ID: <87mtw59zj8.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.13 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_H3, 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 14:27:18 -0000 * H. J. Lu: > On Mon, Feb 15, 2021 at 2:43 AM Florian Weimer 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