From patchwork Wed Nov 1 12:56:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 740060 Delivered-To: patch@linaro.org Received: by 2002:a5d:538f:0:b0:32d:baff:b0ca with SMTP id d15csp267356wrv; Wed, 1 Nov 2023 05:56:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGP6HqvaR75L0HJyLPLKaDSrtLXyLjvfos2966kcjnSI3ZAXrZgXXqNmDkb5Xj3DuYrrqO6 X-Received: by 2002:a05:622a:82:b0:41c:c066:9c0 with SMTP id o2-20020a05622a008200b0041cc06609c0mr19802091qtw.5.1698843396220; Wed, 01 Nov 2023 05:56:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1698843396; cv=pass; d=google.com; s=arc-20160816; b=hM/e/+GnuzOl/qn1n7QcG37/B9DDaeFRY1LqROTRI8g/ACVu975Pmv+3+nrtBCsIM5 VT29IkhF2Mqy/ZMM8JgpPmxABiqMyXstO4f4SE717nUojE94Aar5S8uun82uFijLEi0f 1B+SCskJJmfxj7VFlPCikvRGHCuARtbYI9uKaMWaprx8cg0lBOC5zBJEim6/RzVGKqQn yWC6YmstkBd3yhNM8xO9T303sh1othSg1mca4WCFmoxsPM2Yl+ymdwTM/GYP+WwpRD2Z FIAva3AK4Xmbriv10HJxGaliwpR2KBs8gNCgWcWpdo7G4x3DzOWPI9OkBBDOPWOA+McE Bzaw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=3a7I+lue/0gnA5BTyHrSEIRxoZIlLTWh+LPA0Yf1gsg=; fh=wOialSeEyZrL0Zmx/XQW8gMhKHOwjxYz8NEgiPSksGI=; b=ODPrP3B2N+vna9gN7FssIygR8OgsEyzwytKdyUN6V0ec86HSouI7CBrJgpU3Bq+hu3 99FtKea7HgnJbkBsK8kgh/t8MSXIwnkbj8i2OSbmeLK6beIX3xVP7rB7T8K5WydtbHZ5 g9Fc6L1kypVXPQ4upCRqGUXPmBoQW8No2PTpKbsnO67SDlBArASq8/fDE6iADz+jhpX0 BPvdKRiaI2+u7rN2caS9XavvAhX0kdVbpOkzJaJTHI54E/CqbmnBnLJ5uxizmoFVMlxb eW5oVBunpp8XIamy1hn4SOyva8V8CW0qYW9R29/QGskZdg9yUdIxaJ2yYzuGn+XncbUe luxQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="B8w5a/px"; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id s1-20020ac85cc1000000b00417af0ea0c6si2709792qta.358.2023.11.01.05.56.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 05:56:36 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="B8w5a/px"; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CEFE93857342 for ; Wed, 1 Nov 2023 12:56:35 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-yb1-xb36.google.com (mail-yb1-xb36.google.com [IPv6:2607:f8b0:4864:20::b36]) by sourceware.org (Postfix) with ESMTPS id F02F3385840F for ; Wed, 1 Nov 2023 12:56:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F02F3385840F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org F02F3385840F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::b36 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698843391; cv=none; b=tKcNHSYq0F+ugpNtR7CSQlXJ3ZayWi87ZhI0pbtcFcC6LsMgMhBDQtzxJkj9XJZ/UOyE1YIhv3DQocQR6OTURzCP6+wulne1xEjS+cahd0Vi99xT/B/UAgSdBvhc8xbOXKRAejiyBPotL995PqjvVZkVLE5UbH8L9q2NlY9M/Rw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698843391; c=relaxed/simple; bh=WG53seEKpuXvBhS6R/4bsY7sK1gYeZpD7QzufqQ+Lj4=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=fiv5oEBfEsNiW/oimwxp/bG3nKpdasrDBE4PoGoLSLg6aBME9MBsTn3dh2JpDM05lLnxIGs+KfiJA7lvZeyHCUWB+0bwKmaOdJmUkLNDh8Em+W558GEpLfDlX4WbOyOzCJJJe20POPkj4hrJO5p4AurwAnuLCLVeop1BW4NZENI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yb1-xb36.google.com with SMTP id 3f1490d57ef6-d865854ef96so6198113276.2 for ; Wed, 01 Nov 2023 05:56:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698843382; x=1699448182; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=3a7I+lue/0gnA5BTyHrSEIRxoZIlLTWh+LPA0Yf1gsg=; b=B8w5a/pxfWiwRwDRo0lCr0Z8IEPhBksQdOvDlwY1uCPBiQOWmXMzSM0hAGiUl6I5ps /VZdFgsweXyGdbc7O2C8e81anybGvCzHeJ6nrPsP35Xl0hGZtXMS0WguDO7fqg2lK7q3 OHprOq8vXizm8KxDShjjTgo8Txnd90pfrzhJaR62wVPKswxbcl9MAq4hCdNisKUpFUf9 DTNZSFMz5DZkHr2Tei/rb4ZraLiej4BWtsQGdjzHxzM3CDv/cbJPu5ehdcm3vwuyxjuj Thwvrnzg+asjiYtqpo8iXQXY5pRXG4cHsCnwpLT4CRWlysJqPuNx9U6veGh8vOlfFwqd ALKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698843382; x=1699448182; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3a7I+lue/0gnA5BTyHrSEIRxoZIlLTWh+LPA0Yf1gsg=; b=TgibRKO8EjEJEz3jArOKjW5uK5XZ4kbJ1W0UXJm0y6Bskol87u8OrUHgsDrvMcbb8R xDmgMUzyMKSgxxf9f5Sgww4b0hHzhuFnanoELKecQIw9xBLwIQMMBKvGq9GcVvkVPyr3 afxTQ5Z4X34VG69VRPfwhGYr35eZYJpK4QURbIOvZ7dm/8pmnsaoJRiGpMf0gebrfBeR b7LeeCIoqXOIi0fvRDLeeKKKfspskTmnAATH6Pcvor8PckaLrBrw3Gb8kO6JXrxADskk z0N30edK0ht/OK7ODPuv9kulL0pDfVVT6KQnOqZkeqjKM4WdpAcXa9f2jF8MFHrRRPaF rHKQ== X-Gm-Message-State: AOJu0YyZWsThItoWqw6IBH2VP2BTAc/LsXMkJDlYVSKZVdWgmcZ1sw+D 06NkFvRmXDeuIOtmdnvjdN4oRg92kQYBDa8cgPp9Tw== X-Received: by 2002:a25:804f:0:b0:d9a:3d70:db36 with SMTP id a15-20020a25804f000000b00d9a3d70db36mr13380088ybn.42.1698843381801; Wed, 01 Nov 2023 05:56:21 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c0:a715:15ac:c4b6:7a0e:f5c5]) by smtp.gmail.com with ESMTPSA id w11-20020a5b08cb000000b00da034601e2esm1888100ybq.52.2023.11.01.05.56.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 05:56:21 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org, DJ Delorie , Ian Rogers , Francesco Nigro , Carlos O'Donell Subject: [PATCH v3 2/7] support: Add support_set_vma_name Date: Wed, 1 Nov 2023 09:56:06 -0300 Message-Id: <20231101125611.208544-3-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231101125611.208544-1-adhemerval.zanella@linaro.org> References: <20231101125611.208544-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patch=linaro.org@sourceware.org Check if kernel supports prctl (PR_SET_VMA, PR_SET_VMA_ANON_NAME, ...). Reviewed-by: DJ Delorie --- support/Makefile | 1 + support/support.h | 4 ++ support/support_set_vma_name_supported.c | 49 ++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 support/support_set_vma_name_supported.c diff --git a/support/Makefile b/support/Makefile index 917a858bd1..9aa7f23a6e 100644 --- a/support/Makefile +++ b/support/Makefile @@ -80,6 +80,7 @@ libsupport-routines = \ support_select_modifies_timeout \ support_select_normalizes_timeout \ support_set_small_thread_stack_size \ + support_set_vma_name_supported \ support_shared_allocate \ support_small_stack_thread_attribute \ support_socket_so_timestamp_time64 \ diff --git a/support/support.h b/support/support.h index b7f76bf080..4a068d3aee 100644 --- a/support/support.h +++ b/support/support.h @@ -235,6 +235,10 @@ void support_stack_free (struct support_stack *stack); The returned value is the lowest file descriptor number. */ int support_open_dev_null_range (int num, int flags, mode_t mode); + +/* Check if kernel supports set VMA range name. */ +extern bool support_set_vma_name_supported (void); + __END_DECLS #endif /* SUPPORT_H */ diff --git a/support/support_set_vma_name_supported.c b/support/support_set_vma_name_supported.c new file mode 100644 index 0000000000..712caa9b9b --- /dev/null +++ b/support/support_set_vma_name_supported.c @@ -0,0 +1,49 @@ +/* Check if kernel supports set VMA range name. + Copyright (C) 2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include +#ifdef __linux__ +# include +#endif + +bool +support_set_vma_name_supported (void) +{ +#ifdef __linux__ + size_t size = sysconf (_SC_PAGESIZE); + if (size == -1) + FAIL_EXIT1 ("sysconf (_SC_PAGESIZE): %m\n"); + + void *vma = xmmap (0, + size, + PROT_NONE, + MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, + -1); + + int r = prctl (PR_SET_VMA, PR_SET_VMA_ANON_NAME, vma, size, "vmaname"); + + xmunmap (vma, size); + + return r == 0; +#else + return false; +#endif +}