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 [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 2AA691F9FE for ; Mon, 15 Feb 2021 14:17:57 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 49FB23861031; Mon, 15 Feb 2021 14:17:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 49FB23861031 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1613398675; bh=QONHc4Evm3sH1txpoO8VrxwhCxbrYPQwoHhuT336Pj4=; h=References:In-Reply-To:Date:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=b8jpP6Kv2gamh4/ftAhNkps9rKCogm5ghAepCUFdaKR4CwwlQhRnV79GPkGHKRAf1 zTJl2rkUHgzHml9EZche50cocjDUg/jaI9BPby654H3ooo+cKG0r0dPDYMoEfl6omO fAyLkuu1VfJnS8Mh1Xaejfx8ziPAbGw3LaUZqoFM= Received: from mail-ot1-x334.google.com (mail-ot1-x334.google.com [IPv6:2607:f8b0:4864:20::334]) by sourceware.org (Postfix) with ESMTPS id B234F3860C38 for ; Mon, 15 Feb 2021 14:17:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B234F3860C38 Received: by mail-ot1-x334.google.com with SMTP id 100so6172782otg.3 for ; Mon, 15 Feb 2021 06:17:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=QONHc4Evm3sH1txpoO8VrxwhCxbrYPQwoHhuT336Pj4=; b=dm+0PRmMua00IQjgluhalGrdODf2lLQRpTcUTuE4DZDjGMGZIBoCjDdkQXrFZXWLTc gWSjKrES56OcQ88dafyr8PAYfMdsNcbvxxaKWUCeJmM2c5XZZ3k4irBIn0zMtLbUKe7q WysJ/WiYj7ABHbVdvhJA2An+9Ec70uvexm+CtnONPfF3sBlfROJ98uGgPaK5ng0oVLtH YbdJwxPqErN05OHm6k+uqQ3gW+ETkhTGcUoJl+8OCO1AIOQVdecVGocKM2FBTo2NugCO HIfy1k3P56KpaFhFHZuZwg8Gptrw2u9M+XBrLqDiAZMyJJOSEDciMBcLgY14GOx3sLhS sRoA== X-Gm-Message-State: AOAM533W0AfExjRriHaRmsaLNCzp9KSC1CjV2zbzynVy7GTDB+OjCqZq 40bODWSFXscDQlI9qWEFtiyNM7JWQWCDAKhipw8= X-Google-Smtp-Source: ABdhPJxRKByjpJEKbalmI8WJvmRG2G08j6zDq+DQf8xQEb8st/SDL/h1JpsIj1j5zWSgHv7RBEIH5F638l8CBkBhaMg= X-Received: by 2002:a9d:1717:: with SMTP id i23mr11693003ota.179.1613398672214; Mon, 15 Feb 2021 06:17:52 -0800 (PST) MIME-Version: 1.0 References: <20210214224505.4448-1-hjl.tools@gmail.com> <87r1lhehkw.fsf@oldenburg.str.redhat.com> In-Reply-To: <87r1lhehkw.fsf@oldenburg.str.redhat.com> Date: Mon, 15 Feb 2021 06:17:16 -0800 Message-ID: Subject: Re: [PATCH] Add an internal wrapper for clone, clone2 and clone3 To: Florian Weimer Content-Type: text/plain; charset="UTF-8" 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: "H.J. Lu via Libc-alpha" Reply-To: "H.J. Lu" Cc: "H.J. Lu via Libc-alpha" Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" 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. -- H.J.