From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qv1-xf2b.google.com (mail-qv1-xf2b.google.com [IPv6:2607:f8b0:4864:20::f2b]) by sourceware.org (Postfix) with ESMTPS id 1374B3836C63 for ; Fri, 12 Mar 2021 14:01:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 1374B3836C63 Received: by mail-qv1-xf2b.google.com with SMTP id t5so4269745qvs.5 for ; Fri, 12 Mar 2021 06:01:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=xyQXIETbsvsHwgtzqgOxEVis6041oqc2pIkzJXmridQ=; b=Jzsx49Srz9m882awjvAHzA7Vqw/oDvx2t3POfJR0FD243ccoyVWaUC6+ADT/qU9lsg QcwdJxesSDpbhv/3mDoJ+pKed31UbgbNEZCzpyLgaIRnjamLnqXCU8KbG+1JXpTGnkrV oY9l0zO3wfB7TuA5sUy23dGjSzpwJ/cATp1ZYz0cqPGFbx2IT08r4v4YVGDhgTXHdDcb D6Xs7PHG3Sf1HAvc8d956lfv6j/jzi1mDLwhiGPPUb3p6Y7+oqSXbVygj4xNqH2RVs2M AcDmqb5eFyCZisAPkEV+cTYJud0WEcCacdu1JBdyCq2Abbw3MbVQyrrz7J69QmvEhu9I k5OA== X-Gm-Message-State: AOAM533bMlAOrZ/SpemgPybZxBPXbBteJgQ1lJO1Srfr7Gaa9FjG5WXW H9qZIRSu2Qv4yyL9kVJhf2PAPTH/zircDQ6w X-Google-Smtp-Source: ABdhPJzz3wRaarVJGfxANMnvM6Y3MfhzyEOr9d/doGvNjTc8Y9adkMF9QW2CxlbLKXTbjvxSsx/MwA== X-Received: by 2002:a0c:9ac9:: with SMTP id k9mr12539097qvf.29.1615557712403; Fri, 12 Mar 2021 06:01:52 -0800 (PST) Received: from [192.168.1.4] ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id d23sm4348508qka.125.2021.03.12.06.01.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 12 Mar 2021 06:01:51 -0800 (PST) Subject: Re: [PATCH v4 1/5] support: Add support_stack_alloc To: Florian Weimer Cc: Adhemerval Zanella via Libc-alpha References: <20210310152633.3916978-1-adhemerval.zanella@linaro.org> <875z1zrnuq.fsf@oldenburg.str.redhat.com> <36d689c0-33d3-6606-115c-ece42826de10@linaro.org> <87v99w4hqo.fsf@oldenburg.str.redhat.com> From: Adhemerval Zanella Message-ID: <997f658d-f6e7-a3ad-0be0-124a2dc4e98d@linaro.org> Date: Fri, 12 Mar 2021 11:01:49 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <87v99w4hqo.fsf@oldenburg.str.redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, 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: Fri, 12 Mar 2021 14:01:54 -0000 On 12/03/2021 10:35, Florian Weimer wrote: > * Adhemerval Zanella: > >> On 10/03/2021 13:10, Florian Weimer wrote: >>> * Adhemerval Zanella via Libc-alpha: >>> >>>> + /* Use MAP_NORESERVE so that RAM will not be wasted on the guard >>>> + bands; touch all the pages of the actual stack before returning, >>>> + so we know they are allocated. */ >>>> + void *alloc_base = xmmap (0, >>>> + alloc_size, >>>> + PROT_READ|PROT_WRITE, >>>> + MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE|MAP_STACK, >>>> + -1); >>>> + xmprotect (alloc_base, guardsize, PROT_NONE); >>>> + xmprotect (alloc_base + guardsize + stacksize, guardsize, PROT_NONE); >>> >>> The usual pattern is to map with PROT_NONE and then use >>> PROT_READ|PROT_WRITE with mprotect. >>> >>> Rest looks okay, thanks. >>> >>> Florian >>> >> >> Ok, I will fix it and push upstream. > > Just to be clear, it avoids the need for MAP_NORESERVE. Right, I will fix it.