From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.2 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id ED78B1F9FD for ; Mon, 15 Feb 2021 14:27:23 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A74CF395540C; Mon, 15 Feb 2021 14:27:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A74CF395540C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1613399239; bh=PGGOAgAzvwoHLtRq43vL8buy6t29x0YBR5al7eBcwAY=; h=To:Subject:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=b1sagLJfYx3Ppycb6MB57eYBvIbQ0z/JPmSEkw2baLl+uQro5wwTZKwgdrFkkUQNp fXNMm8DniwK18E5ebq4EB4/sUEdd9PEh5nCA/WrcATumZL6pii/hmiXPhI/1XKU+e6 MUYisrNUuj7wll+qJ33A0TFzDpT879x97ksyb1Pc= 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) To: "H.J. Lu" 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-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: , From: Florian Weimer via Libc-alpha Reply-To: Florian Weimer Cc: "H.J. Lu via Libc-alpha" Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" * 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