From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by sourceware.org (Postfix) with ESMTPS id B378B396EC8D for ; Tue, 13 Jul 2021 19:06:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B378B396EC8D Received: by mail-pf1-x42f.google.com with SMTP id x16so20459197pfa.13 for ; Tue, 13 Jul 2021 12:06:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=2Z9zMcsa+iOMUesFGdu2R+tQGdDhuw0UNTb+k9ioay0=; b=iO2ogcCwuBcua9B1VYZeX15eiRlPZhqb6i8VL+UGhIAZj3H0BErrRFNpBPiH45Z8q8 dWEUxqWFhNbe1wM/POPhhlgDSBrwOAUsxDyQD0KcN6ogg5a+4zfQVa2c6WZdJdanluh9 6zVHT4BCS40HzVYVrfXAZLPWKokLAMMlD1VAS4LxR0aABqX+INgUz9cSsAo1+PXBGvNb Srir/CuwxLEGkjulzaNtTzy93/pI2E0+03Czm6p9b1t3/1uw7LGSMEPhv+SK64ZX9o9D nWrHnCUqLHwIXN2mWRnJSZhekxklPE5sbt8gw9NlK3f+DW96x79xVVyP+adDMozDKFcL KGXA== X-Gm-Message-State: AOAM531+Nno3N6zze/c1spnI2UvJlgej0rKvJAZFIUru16AOkjZcPdxT +CE7s0IownO9BvXSyyElDr0d8Q== X-Google-Smtp-Source: ABdhPJxL6cdm1UwCl14J/kZVoaZuIHgff5wE6E5DjlB+NHzsfWkltjwjvOgNk7t0ny4F5qOw2D1Zyg== X-Received: by 2002:a63:ea0e:: with SMTP id c14mr5588466pgi.117.1626203171893; Tue, 13 Jul 2021 12:06:11 -0700 (PDT) Received: from [192.168.1.108] ([177.194.59.218]) by smtp.gmail.com with ESMTPSA id m19sm3422187pjl.13.2021.07.13.12.06.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Jul 2021 12:06:11 -0700 (PDT) Subject: Re: [PATCH v8 1/3] Add an internal wrapper for clone, clone2 and clone3 From: Adhemerval Zanella To: "H.J. Lu" , libc-alpha@sourceware.org Cc: Florian Weimer , Noah Goldstein References: <20210601145516.3553627-1-hjl.tools@gmail.com> <20210601145516.3553627-2-hjl.tools@gmail.com> <19675287-dc96-6aed-392d-b9aab1504c49@linaro.org> Message-ID: Date: Tue, 13 Jul 2021 16:06:09 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <19675287-dc96-6aed-392d-b9aab1504c49@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_NUMSUBJECT, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Tue, 13 Jul 2021 19:06:14 -0000 On 13/07/2021 15:54, Adhemerval Zanella wrote: > > > On 01/06/2021 11:55, H.J. Lu wrote: >> The clone3 system call provides a superset of the functionality of clone >> and clone2. It also provides a number of API improvements, 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, >> int (*__func) (void *__arg), void *__arg); >> >> to provide an abstract interface for clone, clone2 and clone3. >> >> 1. Simplify stack management for thread creation by passing both stack >> base and size to create_thread. >> 2. Consolidate clone vs clone2 differences into a single file. >> 3. Call __clone3 if HAVE_CLONE3_WAPPER is defined. If __clone3 returns >> -1 with ENOSYS, fall back to clone or clone2. >> 4. Use only __clone_internal to clone a thread. Since the stack size >> argument for create_thread is now unconditional, always pass stack size >> to create_thread. >> 5. Enable the public clone3 wrapper in the future after it has been >> added to all targets. >> >> NB: Sandbox should return ENOSYS on clone3 if it is rejected: >> >> https://bugs.chromium.org/p/chromium/issues/detail?id=1213452#c5 > > LGTM with just an suggestion below. Also chromium also has fixed it, > so although it wouldn't be able to fully handled clone3, at least > it won't brick a 2.34 glibc. > > Reviewed-by: Adhemerval Zanella I forgot to add that I think it would be useful to reference the kernel version and commit which actually added the clone3 syscall on the commit log.