From patchwork Wed Jun 23 18:51:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 1496265 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=VW4nI5Tq; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (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 ozlabs.org (Postfix) with ESMTPS id 4G9C8v0XK1z9sTD for ; Thu, 24 Jun 2021 04:53:51 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A9782398B877 for ; Wed, 23 Jun 2021 18:53:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A9782398B877 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1624474428; bh=8mrE4ZY0kxnx584SbUGsg3lruLwh46I74nD7CHaRDuI=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=VW4nI5Tq8mvNlkebYbvxdqAVTauQ3Kc/YAdMfrKXdnUF7jD9ScqHDKsCSxd23pbAZ Hd3gZeFFNw9+lI+nOaF2XykoR5S0hdWWlFkP46A6QvBzg+vu2aWg67cB9xwcWXKb1W TfQ5E/X9BmyPHH/uRF0J+sj7TzLhn+kWuTBgxIAI= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [IPv6:2607:f8b0:4864:20::72b]) by sourceware.org (Postfix) with ESMTPS id 75946393F827 for ; Wed, 23 Jun 2021 18:51:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 75946393F827 Received: by mail-qk1-x72b.google.com with SMTP id bl4so7812366qkb.8 for ; Wed, 23 Jun 2021 11:51:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8mrE4ZY0kxnx584SbUGsg3lruLwh46I74nD7CHaRDuI=; b=HdWk5jOfaVcy7hRqCcoeyRz3xFDxh2/E4kGS3eCu6bY5JwaMA65KD2Tl4WFNW+ZmpN pKMGttzkwgylyzQ1s5Zke8LLUacNPWd+xrLvkymYeQAZ1zoVExu1HqDh/xwNqgiyhvBx aoZcKq+cbEekKd4+W8OKWtWf51jQA9ACRaEqYOieVDPeOQksOgRY75Dw+nPZ0vDisd8n bw25tP+XcaSeqUUiRE5f+T3lO1CmRNxK44TvBeiFvyIWyEscdWOEJaGrww5qAG7b/prt GmO0GGWyIbbaDfv7LMjzq9D5s1FZbdPzAfBBwpb/bvP9HyqhzvNgS0vwGnPtE9RJQnP+ AElg== X-Gm-Message-State: AOAM530zDhILe1+Kd1zzMTjmf9DIiQVAJZG2gLn8h2lOSD30yN9GyQuQ Su7IUVptu8ziT6oEDjDCe/49jTz8ruP7Kw== X-Google-Smtp-Source: ABdhPJwj14Fn1aqiEeohP85cV5fKr/wLo2147Bo0k6wf9YSTpYhYLDIlKcyDjHa7wWC+NZBfANwZmA== X-Received: by 2002:a05:620a:307:: with SMTP id s7mr1456513qkm.213.1624474283479; Wed, 23 Jun 2021 11:51:23 -0700 (PDT) Received: from birita.. ([177.194.59.218]) by smtp.gmail.com with ESMTPSA id c11sm492293qth.29.2021.06.23.11.51.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Jun 2021 11:51:23 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v6 3/5] linux: Add close_range Date: Wed, 23 Jun 2021 15:51:13 -0300 Message-Id: <20210623185115.395812-4-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210623185115.395812-1-adhemerval.zanella@linaro.org> References: <20210623185115.395812-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.4 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 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-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" It was added on Linux 5.9 (278a5fbaed89) with CLOSE_RANGE_CLOEXEC added on 5.11 (582f1fb6b721f). Although FreeBSD has added the same syscall, this only adds the symbol on Linux ports. This syscall is required to provided a fail-safe way to implement the closefrom symbol (BZ #10353). Checked on x86_64-linux-gnu on kernel v5.9 and v5.4. --- NEWS | 3 + include/bits/unistd_ext.h | 6 + manual/llio.texi | 45 +++ sysdeps/unix/sysv/linux/Makefile | 3 +- sysdeps/unix/sysv/linux/Versions | 1 + sysdeps/unix/sysv/linux/aarch64/libc.abilist | 1 + sysdeps/unix/sysv/linux/alpha/libc.abilist | 1 + sysdeps/unix/sysv/linux/arc/libc.abilist | 1 + sysdeps/unix/sysv/linux/arm/be/libc.abilist | 1 + sysdeps/unix/sysv/linux/arm/le/libc.abilist | 1 + sysdeps/unix/sysv/linux/bits/unistd_ext.h | 22 ++ sysdeps/unix/sysv/linux/csky/libc.abilist | 1 + sysdeps/unix/sysv/linux/hppa/libc.abilist | 1 + sysdeps/unix/sysv/linux/i386/libc.abilist | 1 + sysdeps/unix/sysv/linux/ia64/libc.abilist | 1 + .../sysv/linux/m68k/coldfire/libc.abilist | 1 + .../unix/sysv/linux/m68k/m680x0/libc.abilist | 1 + .../sysv/linux/microblaze/be/libc.abilist | 1 + .../sysv/linux/microblaze/le/libc.abilist | 1 + .../sysv/linux/mips/mips32/fpu/libc.abilist | 1 + .../sysv/linux/mips/mips32/nofpu/libc.abilist | 1 + .../sysv/linux/mips/mips64/n32/libc.abilist | 1 + .../sysv/linux/mips/mips64/n64/libc.abilist | 1 + sysdeps/unix/sysv/linux/nios2/libc.abilist | 1 + .../linux/powerpc/powerpc32/fpu/libc.abilist | 1 + .../powerpc/powerpc32/nofpu/libc.abilist | 1 + .../linux/powerpc/powerpc64/be/libc.abilist | 1 + .../linux/powerpc/powerpc64/le/libc.abilist | 1 + .../unix/sysv/linux/riscv/rv32/libc.abilist | 1 + .../unix/sysv/linux/riscv/rv64/libc.abilist | 1 + .../unix/sysv/linux/s390/s390-32/libc.abilist | 1 + .../unix/sysv/linux/s390/s390-64/libc.abilist | 1 + sysdeps/unix/sysv/linux/sh/be/libc.abilist | 1 + sysdeps/unix/sysv/linux/sh/le/libc.abilist | 1 + .../sysv/linux/sparc/sparc32/libc.abilist | 1 + .../sysv/linux/sparc/sparc64/libc.abilist | 1 + sysdeps/unix/sysv/linux/syscalls.list | 1 + sysdeps/unix/sysv/linux/tst-close_range.c | 303 ++++++++++++++++++ .../unix/sysv/linux/x86_64/64/libc.abilist | 1 + .../unix/sysv/linux/x86_64/x32/libc.abilist | 1 + 40 files changed, 415 insertions(+), 1 deletion(-) create mode 100644 include/bits/unistd_ext.h create mode 100644 sysdeps/unix/sysv/linux/tst-close_range.c diff --git a/NEWS b/NEWS index 48d77d706f..a654694e01 100644 --- a/NEWS +++ b/NEWS @@ -47,6 +47,9 @@ Major new features: with names ending with .conf to logically classify the converter modules in that directory. +* On Linux, the close_range function has been added. It allows efficiently + closing a range of file descriptors on recent kernels (version 5.9). + Deprecated and removed features, and other changes affecting compatibility: * The function pthread_mutex_consistent_np has been deprecated; programs diff --git a/include/bits/unistd_ext.h b/include/bits/unistd_ext.h new file mode 100644 index 0000000000..277be05746 --- /dev/null +++ b/include/bits/unistd_ext.h @@ -0,0 +1,6 @@ +#include_next + +#ifndef _ISOMAC +extern int __close_range (unsigned int lowfd, unsigned int highfd, int flags); +libc_hidden_proto (__close_range); +#endif diff --git a/manual/llio.texi b/manual/llio.texi index cbc4909fd5..3613ead72c 100644 --- a/manual/llio.texi +++ b/manual/llio.texi @@ -284,6 +284,51 @@ of trying to close its underlying file descriptor with @code{close}. This flushes any buffered output and updates the stream object to indicate that it is closed. +@deftypefun int close_range (unsigned int @var{lowfd}, unsigned int @var{maxfd}, int @var{flags}) +@standards{Linux, unistd.h} +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{@acsfd{}}} +@c This is a syscall for Linux v5.9. There is no fallback emulation for +@c older kernels. + +The function @code{close_range} closes the file descriptor from @var{lowfd} +to @var{maxfd} (inclusive). This function is similar to call @code{close} in +specified file descriptor range depending on the @var{flags}. + +This is function is only supported on recent Linux versions and @theglibc{} +does not provide any fallback (the application will need to handle possible +@code{ENOSYS}). + +The @var{flags} add options on how the files are closes. Linux currently +supports: + +@vtable @code +@item CLOSE_RANGE_UNSHARE +Unshare the file descriptor table before closing file descriptors. + +@item CLOSE_RANGE_CLOEXEC +Set the @code{FD_CLOEXEC} bit instead of closing the file descriptor. +@end vtable + +The normal return value from @code{close_range} is @math{0}; a value +of @math{-1} is returned in case of failure. The following @code{errno} error +conditions are defined for this function: + +@table @code +@item EINVAL +The @var{lowfd} value is larger than @var{maxfd} or an unsupported @var{flags} +is used. + +@item ENOMEM +Either there is not enough memory for the operation, or the process is +out of address space. + +@item EMFILE +The process has too many files open. +The maximum number of file descriptors is controlled by the +@end table +@end deftypefun + + @node I/O Primitives @section Input and Output Primitives diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile index 88d7cd7c1b..35a90fd082 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -116,7 +116,8 @@ tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \ tst-tgkill tst-sysvsem-linux tst-sysvmsg-linux tst-sysvshm-linux \ tst-timerfd tst-ppoll \ tst-clock_adjtime tst-adjtimex tst-ntp_adjtime tst-ntp_gettime \ - tst-ntp_gettimex tst-sigtimedwait tst-misalign-clone + tst-ntp_gettimex tst-sigtimedwait tst-misalign-clone \ + tst-close_range # Test for the symbol version of fcntl that was replaced in glibc 2.28. ifeq ($(have-GLIBC_2.27)$(build-shared),yesyes) diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions index ea0b22d7af..c16c8f5acb 100644 --- a/sysdeps/unix/sysv/linux/Versions +++ b/sysdeps/unix/sysv/linux/Versions @@ -270,6 +270,7 @@ libc { __wait3_time64; __wait4_time64; %endif + close_range; } GLIBC_PRIVATE { # functions used in other libraries diff --git a/sysdeps/unix/sysv/linux/aarch64/libc.abilist b/sysdeps/unix/sysv/linux/aarch64/libc.abilist index 42e240e284..b4fe47f106 100644 --- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist +++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist @@ -2349,6 +2349,7 @@ GLIBC_2.34 __pthread_unwind_next F GLIBC_2.34 _pthread_cleanup_pop F GLIBC_2.34 _pthread_cleanup_push F GLIBC_2.34 call_once F +GLIBC_2.34 close_range F GLIBC_2.34 cnd_broadcast F GLIBC_2.34 cnd_destroy F GLIBC_2.34 cnd_init F diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist index fad54555dc..7f2efdb4b2 100644 --- a/sysdeps/unix/sysv/linux/alpha/libc.abilist +++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist @@ -2442,6 +2442,7 @@ GLIBC_2.34 __pthread_unwind_next F GLIBC_2.34 _pthread_cleanup_pop F GLIBC_2.34 _pthread_cleanup_push F GLIBC_2.34 call_once F +GLIBC_2.34 close_range F GLIBC_2.34 cnd_broadcast F GLIBC_2.34 cnd_destroy F GLIBC_2.34 cnd_init F diff --git a/sysdeps/unix/sysv/linux/arc/libc.abilist b/sysdeps/unix/sysv/linux/arc/libc.abilist index 907716ec39..1dc13bbc63 100644 --- a/sysdeps/unix/sysv/linux/arc/libc.abilist +++ b/sysdeps/unix/sysv/linux/arc/libc.abilist @@ -2108,6 +2108,7 @@ GLIBC_2.34 __pthread_unwind_next F GLIBC_2.34 _pthread_cleanup_pop F GLIBC_2.34 _pthread_cleanup_push F GLIBC_2.34 call_once F +GLIBC_2.34 close_range F GLIBC_2.34 cnd_broadcast F GLIBC_2.34 cnd_destroy F GLIBC_2.34 cnd_init F diff --git a/sysdeps/unix/sysv/linux/arm/be/libc.abilist b/sysdeps/unix/sysv/linux/arm/be/libc.abilist index 50f987a429..7ed5f95b0a 100644 --- a/sysdeps/unix/sysv/linux/arm/be/libc.abilist +++ b/sysdeps/unix/sysv/linux/arm/be/libc.abilist @@ -279,6 +279,7 @@ GLIBC_2.34 __wait4_time64 F GLIBC_2.34 _pthread_cleanup_pop F GLIBC_2.34 _pthread_cleanup_push F GLIBC_2.34 call_once F +GLIBC_2.34 close_range F GLIBC_2.34 cnd_broadcast F GLIBC_2.34 cnd_destroy F GLIBC_2.34 cnd_init F diff --git a/sysdeps/unix/sysv/linux/arm/le/libc.abilist b/sysdeps/unix/sysv/linux/arm/le/libc.abilist index bf9038af84..3b2e38f2d5 100644 --- a/sysdeps/unix/sysv/linux/arm/le/libc.abilist +++ b/sysdeps/unix/sysv/linux/arm/le/libc.abilist @@ -276,6 +276,7 @@ GLIBC_2.34 __wait4_time64 F GLIBC_2.34 _pthread_cleanup_pop F GLIBC_2.34 _pthread_cleanup_push F GLIBC_2.34 call_once F +GLIBC_2.34 close_range F GLIBC_2.34 cnd_broadcast F GLIBC_2.34 cnd_destroy F GLIBC_2.34 cnd_init F diff --git a/sysdeps/unix/sysv/linux/bits/unistd_ext.h b/sysdeps/unix/sysv/linux/bits/unistd_ext.h index 2e529be577..bf313e8af8 100644 --- a/sysdeps/unix/sysv/linux/bits/unistd_ext.h +++ b/sysdeps/unix/sysv/linux/bits/unistd_ext.h @@ -33,4 +33,26 @@ not detached and has not been joined. */ extern __pid_t gettid (void) __THROW; +#ifdef __has_include +# if __has_include ("linux/close_range.h") +# include "linux/close_range.h" +# endif #endif +/* Unshare the file descriptor table before closing file descriptors. */ +#ifndef CLOSE_RANGE_UNSHARE +# define CLOSE_RANGE_UNSHARE (1U << 1) +#endif +/* Set the FD_CLOEXEC bit instead of closing the file descriptor. */ +#ifndef CLOSE_RANGE_CLOEXEC +# define CLOSE_RANGE_CLOEXEC (1U << 2) +#endif + +/* Close all file descriptors in the range FD up to MAX_FD. The flag FLAGS + are define by the CLOSE_RANGE prefix. This function behaves like close + on the range, but in a fail-safe where it will either fail and not close + any file descriptor or close all of them. Returns 0 on successor or -1 + for failure (and sets errno accordingly). */ +extern int close_range (unsigned int __fd, unsigned int __max_fd, + int __flags) __THROW; + +#endif /* __USE_GNU */ diff --git a/sysdeps/unix/sysv/linux/csky/libc.abilist b/sysdeps/unix/sysv/linux/csky/libc.abilist index afb91f6f43..c67320e0a3 100644 --- a/sysdeps/unix/sysv/linux/csky/libc.abilist +++ b/sysdeps/unix/sysv/linux/csky/libc.abilist @@ -2368,6 +2368,7 @@ GLIBC_2.34 __wait4_time64 F GLIBC_2.34 _pthread_cleanup_pop F GLIBC_2.34 _pthread_cleanup_push F GLIBC_2.34 call_once F +GLIBC_2.34 close_range F GLIBC_2.34 cnd_broadcast F GLIBC_2.34 cnd_destroy F GLIBC_2.34 cnd_init F diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist index 125f8a269a..4d49b632b3 100644 --- a/sysdeps/unix/sysv/linux/hppa/libc.abilist +++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist @@ -2322,6 +2322,7 @@ GLIBC_2.34 __wait4_time64 F GLIBC_2.34 _pthread_cleanup_pop F GLIBC_2.34 _pthread_cleanup_push F GLIBC_2.34 call_once F +GLIBC_2.34 close_range F GLIBC_2.34 cnd_broadcast F GLIBC_2.34 cnd_destroy F GLIBC_2.34 cnd_init F diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist index 517753bdd1..7fdd181a8d 100644 --- a/sysdeps/unix/sysv/linux/i386/libc.abilist +++ b/sysdeps/unix/sysv/linux/i386/libc.abilist @@ -2506,6 +2506,7 @@ GLIBC_2.34 __wait4_time64 F GLIBC_2.34 _pthread_cleanup_pop F GLIBC_2.34 _pthread_cleanup_push F GLIBC_2.34 call_once F +GLIBC_2.34 close_range F GLIBC_2.34 cnd_broadcast F GLIBC_2.34 cnd_destroy F GLIBC_2.34 cnd_init F diff --git a/sysdeps/unix/sysv/linux/ia64/libc.abilist b/sysdeps/unix/sysv/linux/ia64/libc.abilist index 23d0928360..f719aa9ee4 100644 --- a/sysdeps/unix/sysv/linux/ia64/libc.abilist +++ b/sysdeps/unix/sysv/linux/ia64/libc.abilist @@ -2282,6 +2282,7 @@ GLIBC_2.34 __pthread_unwind_next F GLIBC_2.34 _pthread_cleanup_pop F GLIBC_2.34 _pthread_cleanup_push F GLIBC_2.34 call_once F +GLIBC_2.34 close_range F GLIBC_2.34 cnd_broadcast F GLIBC_2.34 cnd_destroy F GLIBC_2.34 cnd_init F diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist index dd5fb50b18..3616c567e3 100644 --- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist +++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist @@ -280,6 +280,7 @@ GLIBC_2.34 __wait4_time64 F GLIBC_2.34 _pthread_cleanup_pop F GLIBC_2.34 _pthread_cleanup_push F GLIBC_2.34 call_once F +GLIBC_2.34 close_range F GLIBC_2.34 cnd_broadcast F GLIBC_2.34 cnd_destroy F GLIBC_2.34 cnd_init F diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist index cb1d553361..4180cdf07d 100644 --- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist +++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist @@ -2449,6 +2449,7 @@ GLIBC_2.34 __wait4_time64 F GLIBC_2.34 _pthread_cleanup_pop F GLIBC_2.34 _pthread_cleanup_push F GLIBC_2.34 call_once F +GLIBC_2.34 close_range F GLIBC_2.34 cnd_broadcast F GLIBC_2.34 cnd_destroy F GLIBC_2.34 cnd_init F diff --git a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist index 6a20a6fdf2..82f5959756 100644 --- a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist +++ b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist @@ -2419,6 +2419,7 @@ GLIBC_2.34 __wait4_time64 F GLIBC_2.34 _pthread_cleanup_pop F GLIBC_2.34 _pthread_cleanup_push F GLIBC_2.34 call_once F +GLIBC_2.34 close_range F GLIBC_2.34 cnd_broadcast F GLIBC_2.34 cnd_destroy F GLIBC_2.34 cnd_init F diff --git a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist index 4c21cbb64d..53fb9ffaf8 100644 --- a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist +++ b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist @@ -2416,6 +2416,7 @@ GLIBC_2.34 __wait4_time64 F GLIBC_2.34 _pthread_cleanup_pop F GLIBC_2.34 _pthread_cleanup_push F GLIBC_2.34 call_once F +GLIBC_2.34 close_range F GLIBC_2.34 cnd_broadcast F GLIBC_2.34 cnd_destroy F GLIBC_2.34 cnd_init F diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist index f83ba2f780..76f8f675ea 100644 --- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist @@ -2414,6 +2414,7 @@ GLIBC_2.34 __wait4_time64 F GLIBC_2.34 _pthread_cleanup_pop F GLIBC_2.34 _pthread_cleanup_push F GLIBC_2.34 call_once F +GLIBC_2.34 close_range F GLIBC_2.34 cnd_broadcast F GLIBC_2.34 cnd_destroy F GLIBC_2.34 cnd_init F diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist index 347bbddb94..9d294bfcf9 100644 --- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist @@ -2412,6 +2412,7 @@ GLIBC_2.34 __wait4_time64 F GLIBC_2.34 _pthread_cleanup_pop F GLIBC_2.34 _pthread_cleanup_push F GLIBC_2.34 call_once F +GLIBC_2.34 close_range F GLIBC_2.34 cnd_broadcast F GLIBC_2.34 cnd_destroy F GLIBC_2.34 cnd_init F diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist index 26b7ab529b..44fb849bc9 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist @@ -2420,6 +2420,7 @@ GLIBC_2.34 __wait4_time64 F GLIBC_2.34 _pthread_cleanup_pop F GLIBC_2.34 _pthread_cleanup_push F GLIBC_2.34 call_once F +GLIBC_2.34 close_range F GLIBC_2.34 cnd_broadcast F GLIBC_2.34 cnd_destroy F GLIBC_2.34 cnd_init F diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist index e667b0e553..102ec2a2f9 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist @@ -2338,6 +2338,7 @@ GLIBC_2.34 __pthread_unwind_next F GLIBC_2.34 _pthread_cleanup_pop F GLIBC_2.34 _pthread_cleanup_push F GLIBC_2.34 call_once F +GLIBC_2.34 close_range F GLIBC_2.34 cnd_broadcast F GLIBC_2.34 cnd_destroy F GLIBC_2.34 cnd_init F diff --git a/sysdeps/unix/sysv/linux/nios2/libc.abilist b/sysdeps/unix/sysv/linux/nios2/libc.abilist index 89a1cc7da6..c5c6844a01 100644 --- a/sysdeps/unix/sysv/linux/nios2/libc.abilist +++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist @@ -2458,6 +2458,7 @@ GLIBC_2.34 __wait4_time64 F GLIBC_2.34 _pthread_cleanup_pop F GLIBC_2.34 _pthread_cleanup_push F GLIBC_2.34 call_once F +GLIBC_2.34 close_range F GLIBC_2.34 cnd_broadcast F GLIBC_2.34 cnd_destroy F GLIBC_2.34 cnd_init F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist index f364c5219e..8111a6d886 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist @@ -2476,6 +2476,7 @@ GLIBC_2.34 __wait4_time64 F GLIBC_2.34 _pthread_cleanup_pop F GLIBC_2.34 _pthread_cleanup_push F GLIBC_2.34 call_once F +GLIBC_2.34 close_range F GLIBC_2.34 cnd_broadcast F GLIBC_2.34 cnd_destroy F GLIBC_2.34 cnd_init F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist index f5bcc78afe..f65efa3c54 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist @@ -2509,6 +2509,7 @@ GLIBC_2.34 __wait4_time64 F GLIBC_2.34 _pthread_cleanup_pop F GLIBC_2.34 _pthread_cleanup_push F GLIBC_2.34 call_once F +GLIBC_2.34 close_range F GLIBC_2.34 cnd_broadcast F GLIBC_2.34 cnd_destroy F GLIBC_2.34 cnd_init F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist index 6032716053..7cce3dca8c 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist @@ -2246,6 +2246,7 @@ GLIBC_2.34 __pthread_unwind_next F GLIBC_2.34 _pthread_cleanup_pop F GLIBC_2.34 _pthread_cleanup_push F GLIBC_2.34 call_once F +GLIBC_2.34 close_range F GLIBC_2.34 cnd_broadcast F GLIBC_2.34 cnd_destroy F GLIBC_2.34 cnd_init F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist index 8c5494e1dc..65ccafb1d9 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist @@ -2545,6 +2545,7 @@ GLIBC_2.34 __pthread_unwind_next F GLIBC_2.34 _pthread_cleanup_pop F GLIBC_2.34 _pthread_cleanup_push F GLIBC_2.34 call_once F +GLIBC_2.34 close_range F GLIBC_2.34 cnd_broadcast F GLIBC_2.34 cnd_destroy F GLIBC_2.34 cnd_init F diff --git a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist index d7db279c1e..a34c8c30fc 100644 --- a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist +++ b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist @@ -2110,6 +2110,7 @@ GLIBC_2.34 __pthread_unwind_next F GLIBC_2.34 _pthread_cleanup_pop F GLIBC_2.34 _pthread_cleanup_push F GLIBC_2.34 call_once F +GLIBC_2.34 close_range F GLIBC_2.34 cnd_broadcast F GLIBC_2.34 cnd_destroy F GLIBC_2.34 cnd_init F diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist index ef03dc0f9e..85a5815d7b 100644 --- a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist +++ b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist @@ -2310,6 +2310,7 @@ GLIBC_2.34 __pthread_unwind_next F GLIBC_2.34 _pthread_cleanup_pop F GLIBC_2.34 _pthread_cleanup_push F GLIBC_2.34 call_once F +GLIBC_2.34 close_range F GLIBC_2.34 cnd_broadcast F GLIBC_2.34 cnd_destroy F GLIBC_2.34 cnd_init F diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist index 9118cb68ec..b63b3a5f0e 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist +++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist @@ -2474,6 +2474,7 @@ GLIBC_2.34 __wait4_time64 F GLIBC_2.34 _pthread_cleanup_pop F GLIBC_2.34 _pthread_cleanup_push F GLIBC_2.34 call_once F +GLIBC_2.34 close_range F GLIBC_2.34 cnd_broadcast F GLIBC_2.34 cnd_destroy F GLIBC_2.34 cnd_init F diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist index 66c01bd7e7..b874e3d48f 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist +++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist @@ -2283,6 +2283,7 @@ GLIBC_2.34 __pthread_unwind_next F GLIBC_2.34 _pthread_cleanup_pop F GLIBC_2.34 _pthread_cleanup_push F GLIBC_2.34 call_once F +GLIBC_2.34 close_range F GLIBC_2.34 cnd_broadcast F GLIBC_2.34 cnd_destroy F GLIBC_2.34 cnd_init F diff --git a/sysdeps/unix/sysv/linux/sh/be/libc.abilist b/sysdeps/unix/sysv/linux/sh/be/libc.abilist index c40eb412c2..4eabae900d 100644 --- a/sysdeps/unix/sysv/linux/sh/be/libc.abilist +++ b/sysdeps/unix/sysv/linux/sh/be/libc.abilist @@ -2329,6 +2329,7 @@ GLIBC_2.34 __wait4_time64 F GLIBC_2.34 _pthread_cleanup_pop F GLIBC_2.34 _pthread_cleanup_push F GLIBC_2.34 call_once F +GLIBC_2.34 close_range F GLIBC_2.34 cnd_broadcast F GLIBC_2.34 cnd_destroy F GLIBC_2.34 cnd_init F diff --git a/sysdeps/unix/sysv/linux/sh/le/libc.abilist b/sysdeps/unix/sysv/linux/sh/le/libc.abilist index 1412d33835..ad302d997f 100644 --- a/sysdeps/unix/sysv/linux/sh/le/libc.abilist +++ b/sysdeps/unix/sysv/linux/sh/le/libc.abilist @@ -2326,6 +2326,7 @@ GLIBC_2.34 __wait4_time64 F GLIBC_2.34 _pthread_cleanup_pop F GLIBC_2.34 _pthread_cleanup_push F GLIBC_2.34 call_once F +GLIBC_2.34 close_range F GLIBC_2.34 cnd_broadcast F GLIBC_2.34 cnd_destroy F GLIBC_2.34 cnd_init F diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist index 7b55d34753..7c3f29d8b4 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist @@ -2467,6 +2467,7 @@ GLIBC_2.34 __wait4_time64 F GLIBC_2.34 _pthread_cleanup_pop F GLIBC_2.34 _pthread_cleanup_push F GLIBC_2.34 call_once F +GLIBC_2.34 close_range F GLIBC_2.34 cnd_broadcast F GLIBC_2.34 cnd_destroy F GLIBC_2.34 cnd_init F diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist index cfd5f38864..d1442eac11 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist @@ -2303,6 +2303,7 @@ GLIBC_2.34 __pthread_unwind_next F GLIBC_2.34 _pthread_cleanup_pop F GLIBC_2.34 _pthread_cleanup_push F GLIBC_2.34 call_once F +GLIBC_2.34 close_range F GLIBC_2.34 cnd_broadcast F GLIBC_2.34 cnd_destroy F GLIBC_2.34 cnd_init F diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list index 01ec2bfa95..53575669c7 100644 --- a/sysdeps/unix/sysv/linux/syscalls.list +++ b/sysdeps/unix/sysv/linux/syscalls.list @@ -101,3 +101,4 @@ pkey_alloc EXTRA pkey_alloc i:ii pkey_alloc pkey_free EXTRA pkey_free i:i pkey_free gettid EXTRA gettid Ei: __gettid gettid tgkill EXTRA tgkill i:iii __tgkill tgkill +close_range EXTRA close_range i:iii __close_range close_range diff --git a/sysdeps/unix/sysv/linux/tst-close_range.c b/sysdeps/unix/sysv/linux/tst-close_range.c new file mode 100644 index 0000000000..86c9f08845 --- /dev/null +++ b/sysdeps/unix/sysv/linux/tst-close_range.c @@ -0,0 +1,303 @@ +/* Test for the close_range system call. + Copyright (C) 2021 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 +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#define NFDS 100 + +static int +open_multiple_temp_files (void) +{ + /* Check if the temporary file descriptor has no no gaps. */ + int lowfd = xopen ("/dev/null", O_RDONLY, 0600); + for (int i = 1; i <= NFDS; i++) + TEST_COMPARE (xopen ("/dev/null", O_RDONLY, 0600), + lowfd + i); + return lowfd; +} + +static void +close_range_test_max_upper_limit (void) +{ + struct support_descriptors *descrs = support_descriptors_list (); + + int lowfd = open_multiple_temp_files (); + + { + int r = close_range (lowfd, ~0U, 0); + if (r == -1 && errno == ENOSYS) + FAIL_UNSUPPORTED ("close_range not supported"); + TEST_COMPARE (r, 0); + } + + support_descriptors_check (descrs); + support_descriptors_free (descrs); +} + +static void +close_range_test_common (int lowfd, unsigned int flags) +{ + const int maximum_fd = lowfd + NFDS; + const int half_fd = lowfd + NFDS / 2; + const int gap_1 = maximum_fd - 8; + + /* Close half of the descriptors and check result. */ + TEST_COMPARE (close_range (lowfd, half_fd, flags), 0); + for (int i = lowfd; i <= half_fd; i++) + { + TEST_COMPARE (fcntl (i, F_GETFL), -1); + TEST_COMPARE (errno, EBADF); + } + for (int i = half_fd + 1; i < maximum_fd; i++) + TEST_VERIFY (fcntl (i, F_GETFL) > -1); + + /* Create some gaps, close up to a threshold, and check result. */ + xclose (lowfd + 57); + xclose (lowfd + 78); + xclose (lowfd + 81); + xclose (lowfd + 82); + xclose (lowfd + 84); + xclose (lowfd + 90); + + TEST_COMPARE (close_range (half_fd + 1, gap_1, flags), 0); + for (int i = half_fd + 1; i < gap_1; i++) + { + TEST_COMPARE (fcntl (i, F_GETFL), -1); + TEST_COMPARE (errno, EBADF); + } + for (int i = gap_1 + 1; i < maximum_fd; i++) + TEST_VERIFY (fcntl (i, F_GETFL) > -1); + + /* Close the remaining but the last one. */ + TEST_COMPARE (close_range (gap_1 + 1, maximum_fd - 1, flags), 0); + for (int i = gap_1 + 1; i < maximum_fd - 1; i++) + { + TEST_COMPARE (fcntl (i, F_GETFL), -1); + TEST_COMPARE (errno, EBADF); + } + TEST_VERIFY (fcntl (maximum_fd, F_GETFL) > -1); + + /* Close the last one. */ + TEST_COMPARE (close_range (maximum_fd, maximum_fd, flags), 0); + TEST_COMPARE (fcntl (maximum_fd, F_GETFL), -1); + TEST_COMPARE (errno, EBADF); +} + +/* Basic tests: check if the syscall close ranges with and without gaps. */ +static void +close_range_test (void) +{ + struct support_descriptors *descrs = support_descriptors_list (); + + /* Check if the temporary file descriptor has no no gaps. */ + int lowfd = open_multiple_temp_files (); + + close_range_test_common (lowfd, 0); + + /* Double check by check the /proc. */ + support_descriptors_check (descrs); + support_descriptors_free (descrs); +} + +_Noreturn static int +close_range_test_fn (void *arg) +{ + int lowfd = (int) ((uintptr_t) arg); + close_range_test_common (lowfd, 0); + exit (EXIT_SUCCESS); +} + +/* Check if a clone_range on a subprocess created with CLONE_FILES close + the shared file descriptor table entries in the parent. */ +static void +close_range_test_subprocess (void) +{ + struct support_descriptors *descrs = support_descriptors_list (); + + /* Check if the temporary file descriptor has no no gaps. */ + int lowfd = open_multiple_temp_files (); + + struct support_stack stack = support_stack_alloc (4096); + + pid_t pid = xclone (close_range_test_fn, (void*) (uintptr_t) lowfd, + stack.stack, stack.size, CLONE_FILES | SIGCHLD); + TEST_VERIFY_EXIT (pid > 0); + int status; + xwaitpid (pid, &status, 0); + TEST_VERIFY (WIFEXITED (status)); + TEST_COMPARE (WEXITSTATUS(status), 0); + + support_stack_free (&stack); + + for (int i = lowfd; i < NFDS; i++) + TEST_VERIFY (fcntl (i, F_GETFL) < 0); + + support_descriptors_check (descrs); + support_descriptors_free (descrs); +} + + +_Noreturn static int +close_range_unshare_test_fn (void *arg) +{ + int lowfd = (int) ((uintptr_t) arg); + close_range_test_common (lowfd, CLOSE_RANGE_UNSHARE); + exit (EXIT_SUCCESS); +} + +/* Check if a close_range with CLOSE_RANGE_UNSHARE issued from a subprocess + created with CLONE_FILES does not close the parent file descriptor list. */ +static void +close_range_unshare_test (void) +{ + struct support_descriptors *descrs1 = support_descriptors_list (); + + /* Check if the temporary file descriptor has no no gaps. */ + int lowfd = open_multiple_temp_files (); + + struct support_descriptors *descrs2 = support_descriptors_list (); + + struct support_stack stack = support_stack_alloc (4096); + + pid_t pid = xclone (close_range_unshare_test_fn, (void*) (uintptr_t) lowfd, + stack.stack, stack.size, CLONE_FILES | SIGCHLD); + TEST_VERIFY_EXIT (pid > 0); + int status; + xwaitpid (pid, &status, 0); + TEST_VERIFY (WIFEXITED (status)); + TEST_COMPARE (WEXITSTATUS(status), 0); + + support_stack_free (&stack); + + for (int i = 0; i < NFDS; i++) + TEST_VERIFY (fcntl (i, F_GETFL) > -1); + + support_descriptors_check (descrs2); + support_descriptors_free (descrs2); + + TEST_COMPARE (close_range (lowfd, lowfd + NFDS, 0), 0); + + support_descriptors_check (descrs1); + support_descriptors_free (descrs1); +} + +static bool +is_in_array (int *arr, size_t len, int fd) +{ + bool r = false; + for (int i = 0; i < len; i++) + if (arr[i] == fd) + return true; + return r; +} + +static void +close_range_cloexec_test (void) +{ + /* Check if the temporary file descriptor has no no gaps. */ + const int lowfd = open_multiple_temp_files (); + + const int maximum_fd = lowfd + NFDS; + const int half_fd = lowfd + NFDS / 2; + const int gap_1 = maximum_fd - 8; + + /* Close half of the descriptors and check result. */ + int r = close_range (lowfd, half_fd, CLOSE_RANGE_CLOEXEC); + if (r == -1 && errno == EINVAL) + { + printf ("%s: CLOSE_RANGE_CLOEXEC not supported\n", __func__); + return; + } + for (int i = lowfd; i <= half_fd; i++) + { + int flags = fcntl (i, F_GETFD); + TEST_VERIFY (flags > -1); + TEST_COMPARE (flags & FD_CLOEXEC, FD_CLOEXEC); + } + for (int i = half_fd + 1; i < maximum_fd; i++) + TEST_VERIFY (fcntl (i, F_GETFL) > -1); + + /* Create some gaps, close up to a threshold, and check result. */ + static int gap_close[] = { 57, 78, 81, 82, 84, 90 }; + for (int i = 0; i < array_length (gap_close); i++) + xclose (gap_close[i]); + + TEST_COMPARE (close_range (half_fd + 1, gap_1, CLOSE_RANGE_CLOEXEC), 0); + for (int i = half_fd + 1; i < gap_1; i++) + { + int flags = fcntl (i, F_GETFD); + if (is_in_array (gap_close, array_length (gap_close), i)) + TEST_COMPARE (flags, -1); + else + { + TEST_VERIFY (flags > -1); + TEST_COMPARE (flags & FD_CLOEXEC, FD_CLOEXEC); + } + } + for (int i = gap_1 + 1; i < maximum_fd; i++) + TEST_VERIFY (fcntl (i, F_GETFL) > -1); + + /* Close the remaining but the last one. */ + TEST_COMPARE (close_range (gap_1 + 1, maximum_fd - 1, CLOSE_RANGE_CLOEXEC), + 0); + for (int i = gap_1 + 1; i < maximum_fd - 1; i++) + { + int flags = fcntl (i, F_GETFD); + TEST_VERIFY (flags > -1); + TEST_COMPARE (flags & FD_CLOEXEC, FD_CLOEXEC); + } + TEST_VERIFY (fcntl (maximum_fd, F_GETFL) > -1); + + /* Close the last one. */ + TEST_COMPARE (close_range (maximum_fd, maximum_fd, CLOSE_RANGE_CLOEXEC), 0); + { + int flags = fcntl (maximum_fd, F_GETFD); + TEST_VERIFY (flags > -1); + TEST_COMPARE (flags & FD_CLOEXEC, FD_CLOEXEC); + } +} + +static int +do_test (void) +{ + close_range_test_max_upper_limit (); + close_range_test (); + close_range_test_subprocess (); + close_range_unshare_test (); + close_range_cloexec_test (); + + return 0; +} + +#include diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist index 17be05f14f..06274a69e8 100644 --- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist +++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist @@ -2261,6 +2261,7 @@ GLIBC_2.34 __pthread_unwind_next F GLIBC_2.34 _pthread_cleanup_pop F GLIBC_2.34 _pthread_cleanup_push F GLIBC_2.34 call_once F +GLIBC_2.34 close_range F GLIBC_2.34 cnd_broadcast F GLIBC_2.34 cnd_destroy F GLIBC_2.34 cnd_init F diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist index a9db18906b..98e05351a8 100644 --- a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist +++ b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist @@ -2364,6 +2364,7 @@ GLIBC_2.34 __pthread_unwind_next F GLIBC_2.34 _pthread_cleanup_pop F GLIBC_2.34 _pthread_cleanup_push F GLIBC_2.34 call_once F +GLIBC_2.34 close_range F GLIBC_2.34 cnd_broadcast F GLIBC_2.34 cnd_destroy F GLIBC_2.34 cnd_init F