From patchwork Wed Oct 26 00:17:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nilay Vaish X-Patchwork-Id: 59422 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A9ABA386077C for ; Wed, 26 Oct 2022 00:18:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A9ABA386077C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666743512; bh=dgNXNyFvhlSF+4RgMVVHhpiAXr7JNodhnToIMBLAj0o=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=FQmlGpEWIvQqcYjUW+r6Jxfd5Q6HO+chzlwHISfqPlbuQrgytJe78sf28fGJc96Li r8enc8mKPjqT/OtxNFV9Or1NbKYw5AAjOnCtWQdbafBk1F2Srm1GQP3q5x7hMSzSWg MYtnmZHGwuWU1H9qJ2ebe6QkDpwwGo13BdAJlBh4= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by sourceware.org (Postfix) with ESMTPS id BE4483860753 for ; Wed, 26 Oct 2022 00:17:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BE4483860753 Received: by mail-ej1-x636.google.com with SMTP id d26so17031072eje.10 for ; Tue, 25 Oct 2022 17:17:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=GmWCWZKO4ICpMF1bYSIZjg7Z89NeGRvueHOc/v+wypM=; b=GdeNXA9EvzUR3xRRwxGwks+XDWJ7gEEssTwyqqFDBM7W7pZyRH16/s2S80StVzL8I1 CMl5DIWFetRzGsCoS2uL6GVzB87N7xtaC3loH3AZ2FfRGVd0zKooiHz+tNCQUjnjZXi1 bMbGSX3ScjmED9hGn66JX8GS8p2o5DlDG/yZER+W2L9aEIrmuwMYs0havQ92aw/7rItJ 4SvkYJR2jpBUsupG8lSS5+AJWNM9Jjrq+/ogEyPwE9p8sU/lsxJ9CzdVgSOVeD80Rt7v p08ng750FyrLVYvzn13CE6aMyX8hrma3Grg+P2GoV/Wc6epRaesehSQXDaMafDbiGxAZ Iy0w== X-Gm-Message-State: ACrzQf1iIPPisw0U/yh+nPygJQ2Fh8FACu2Zv1H5O5PULJOlFayI4SO+ A5CMQvxf2jf62MfJXLm7e9rzMg1mrwxlftDlhvaVjFDiYBV8Yg== X-Google-Smtp-Source: AMsMyM4AxaiSVPlRtbv4IsI/qMS6sdgkRByMoBXbi2YpHRF97xubvglQvVXCgc3FWspRRGC4Rd8q26eMPNOkY83fpio= X-Received: by 2002:a17:907:2c71:b0:79e:8603:72c6 with SMTP id ib17-20020a1709072c7100b0079e860372c6mr20512409ejc.172.1666743463703; Tue, 25 Oct 2022 17:17:43 -0700 (PDT) MIME-Version: 1.0 Date: Tue, 25 Oct 2022 17:17:07 -0700 Message-ID: Subject: [PATCH origin/google/grte/v5-2.27/master] nptl: use mmap and munmap for stack allocation To: libc-alpha@sourceware.org X-Spam-Status: No, score=-26.7 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH, GIT_PATCH_0, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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-Patchwork-Original-From: Nilay Vaish via Libc-alpha From: Nilay Vaish Reply-To: Nilay Vaish Cc: David Finkelstein Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" We made this change so that we can capture thread stack allocations. __mmap and __munmap cannot be overridden at runtime. mmap and munmap can be overidden at runtime and we are thus able to capture when either of these functions were called. From 17d684c996c880ffe1103d94a072dba8cdb52905 Mon Sep 17 00:00:00 2001 From: Nilay Vaish Date: Sat, 22 Oct 2022 15:23:22 -0700 Subject: [PATCH origin/google/grte/v5-2.27/master] nptl: use mmap and munmap for stack allocation To: libc-alpha@sourceware.org Cc: maskray@google.com, dxf@google.com We made this change so that we can capture thread stack allocations. __mmap and __munmap cannot be overridden at runtime. mmap and munmap can be overidden at runtime and we are thus able to capture when either of these functions were called. --- nptl/allocatestack.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c index 9f6a75695e..1989ca7c86 100644 --- a/nptl/allocatestack.c +++ b/nptl/allocatestack.c @@ -276,7 +276,7 @@ __free_stacks (size_t limit) /* Remove this block. This should never fail. If it does something is really wrong. */ - if (__munmap (curr->stackblock, curr->stackblock_size) != 0) + if (munmap (curr->stackblock, curr->stackblock_size) != 0) abort (); /* Maybe we have freed enough. */ @@ -558,7 +558,7 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp, /* If a guard page is required, avoid committing memory by first allocate with PROT_NONE and then reserve with required permission excluding the guard page. */ - mem = __mmap (NULL, size, (guardsize == 0) ? prot : PROT_NONE, + mem = mmap (NULL, size, (guardsize == 0) ? prot : PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_STACK, -1, 0); if (__glibc_unlikely (mem == MAP_FAILED)) @@ -585,7 +585,7 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp, pagesize_m1); if (setup_stack_prot (mem, size, guard, guardsize, prot) != 0) { - __munmap (mem, size); + munmap (mem, size); return errno; } } @@ -628,7 +628,7 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp, assert (errno == ENOMEM); /* Free the stack memory we just allocated. */ - (void) __munmap (mem, size); + (void) munmap (mem, size); return errno; } -- 2.38.0.135.g90850a2211-goog