From patchwork Mon Jul 19 15:28:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 44398 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 84EC639551CC for ; Mon, 19 Jul 2021 15:32:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 84EC639551CC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1626708775; bh=blF2OcL1yMrtEzxiIaSIloq3a5KuQzKzFT3NNId+ZLM=; h=To:Subject:In-Reply-To:References:Date:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=DX+X+B/6AEe/GGZaA/HNkeq5peEQqfBnS+3FGdz3ogqsxIvxu8gSHXSZhxtToYJPC dF750xIYskR4THjlbPa7uPckwul9U5o6rlK5YjQaB4j2s26reef7Sg2jRkLLInHgMK 5Ibtj9IBCDPH2GfgQqeNCYndMEtlIB07nzWTJfKA= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 745B03953C17 for ; Mon, 19 Jul 2021 15:28:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 745B03953C17 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-363-aRBqUx1TNh27Nv8GT08VDw-1; Mon, 19 Jul 2021 11:28:55 -0400 X-MC-Unique: aRBqUx1TNh27Nv8GT08VDw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6F39D100C661 for ; Mon, 19 Jul 2021 15:28:54 +0000 (UTC) Received: from oldenburg.str.redhat.com (ovpn-112-73.phx2.redhat.com [10.3.112.73]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6078A19C44 for ; Mon, 19 Jul 2021 15:28:53 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH 4/8] socket: Add time64 alias for sendmmsg In-Reply-To: References: X-From-Line: edf40823209004edcb09d8010bb90707246be9d5 Mon Sep 17 00:00:00 2001 Message-Id: Date: Mon, 19 Jul 2021 17:28:51 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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-Patchwork-Original-From: Florian Weimer via Libc-alpha From: Florian Weimer Reply-To: Florian Weimer Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" --- socket/sys/socket.h | 14 +- sysdeps/unix/sysv/linux/Makefile | 2 + sysdeps/unix/sysv/linux/Versions | 1 + sysdeps/unix/sysv/linux/arm/be/libc.abilist | 1 + sysdeps/unix/sysv/linux/arm/le/libc.abilist | 1 + sysdeps/unix/sysv/linux/csky/libc.abilist | 1 + sysdeps/unix/sysv/linux/hppa/libc.abilist | 1 + sysdeps/unix/sysv/linux/i386/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 + sysdeps/unix/sysv/linux/nios2/libc.abilist | 1 + .../linux/powerpc/powerpc32/fpu/libc.abilist | 1 + .../powerpc/powerpc32/nofpu/libc.abilist | 1 + .../unix/sysv/linux/s390/s390-32/libc.abilist | 1 + sysdeps/unix/sysv/linux/sendmmsg.c | 3 + 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 + .../unix/sysv/linux/tst-scm_rights-time64.c | 1 + sysdeps/unix/sysv/linux/tst-scm_rights.c | 186 ++++++++++++++++++ 25 files changed, 225 insertions(+), 1 deletion(-) create mode 100644 sysdeps/unix/sysv/linux/tst-scm_rights-time64.c create mode 100644 sysdeps/unix/sysv/linux/tst-scm_rights.c diff --git a/socket/sys/socket.h b/socket/sys/socket.h index 5577e75b80..d02d976bb5 100644 --- a/socket/sys/socket.h +++ b/socket/sys/socket.h @@ -179,9 +179,21 @@ extern ssize_t sendmsg (int __fd, const struct msghdr *__message, This function is a cancellation point and therefore not marked with __THROW. */ +# ifndef __USE_TIME_BITS64 extern int sendmmsg (int __fd, struct mmsghdr *__vmessages, unsigned int __vlen, int __flags); -#endif +# else +# ifdef __REDIRECT +extern int __REDIRECT (sendmmsg, (int __fd, struct mmsghdr *__vmessages, + unsigned int __vlen, int __flags), + __sendmmsg64); +# else +extern int __sendmmsg64 (int __fd, struct mmsghdr *__vmessages, + unsigned int __vlen, int __flags); +# define sendmmsg __sendmmsg64 +# endif +# endif /* __USE_TIME_BITS64 */ +#endif /* __USE_GNU */ /* Receive a message as described by MESSAGE from socket FD. Returns the number of bytes read or -1 for errors. diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile index 123f15c2e3..76ad06361c 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -122,6 +122,7 @@ tests += tst-clone tst-clone2 tst-clone3 tst-fanotify tst-personality \ tst-ntp_gettimex tst-sigtimedwait tst-misalign-clone \ tst-close_range \ tst-prctl \ + tst-scm_rights \ # tests # Test for the symbol version of fcntl that was replaced in glibc 2.28. @@ -141,6 +142,7 @@ tests-time64 += \ tst-sigtimedwait-time64 \ tst-timerfd-time64 \ tst-prctl-time64 \ + tst-scm_rights-time64 \ # tests-time64 tests-clone-internal = \ diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions index cff3d476da..a8ec041371 100644 --- a/sysdeps/unix/sysv/linux/Versions +++ b/sysdeps/unix/sysv/linux/Versions @@ -265,6 +265,7 @@ libc { __semctl64; __semtimedop64; __sem_timedwait64; + __sendmmsg64; __setitimer64; __settimeofday64; __shmctl64; diff --git a/sysdeps/unix/sysv/linux/arm/be/libc.abilist b/sysdeps/unix/sysv/linux/arm/be/libc.abilist index a108dccfe9..740081f235 100644 --- a/sysdeps/unix/sysv/linux/arm/be/libc.abilist +++ b/sysdeps/unix/sysv/linux/arm/be/libc.abilist @@ -266,6 +266,7 @@ GLIBC_2.34 __sem_clockwait64 F GLIBC_2.34 __sem_timedwait64 F GLIBC_2.34 __semctl64 F GLIBC_2.34 __semtimedop64 F +GLIBC_2.34 __sendmmsg64 F GLIBC_2.34 __setitimer64 F GLIBC_2.34 __settimeofday64 F GLIBC_2.34 __shmctl64 F diff --git a/sysdeps/unix/sysv/linux/arm/le/libc.abilist b/sysdeps/unix/sysv/linux/arm/le/libc.abilist index 3511d35f5e..55f17e1ee3 100644 --- a/sysdeps/unix/sysv/linux/arm/le/libc.abilist +++ b/sysdeps/unix/sysv/linux/arm/le/libc.abilist @@ -263,6 +263,7 @@ GLIBC_2.34 __sem_clockwait64 F GLIBC_2.34 __sem_timedwait64 F GLIBC_2.34 __semctl64 F GLIBC_2.34 __semtimedop64 F +GLIBC_2.34 __sendmmsg64 F GLIBC_2.34 __setitimer64 F GLIBC_2.34 __settimeofday64 F GLIBC_2.34 __shmctl64 F diff --git a/sysdeps/unix/sysv/linux/csky/libc.abilist b/sysdeps/unix/sysv/linux/csky/libc.abilist index 40342891a5..610f59aad7 100644 --- a/sysdeps/unix/sysv/linux/csky/libc.abilist +++ b/sysdeps/unix/sysv/linux/csky/libc.abilist @@ -2422,6 +2422,7 @@ GLIBC_2.34 __sem_clockwait64 F GLIBC_2.34 __sem_timedwait64 F GLIBC_2.34 __semctl64 F GLIBC_2.34 __semtimedop64 F +GLIBC_2.34 __sendmmsg64 F GLIBC_2.34 __setitimer64 F GLIBC_2.34 __settimeofday64 F GLIBC_2.34 __shmctl64 F diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist index 1502aaddd4..3c6ce135e2 100644 --- a/sysdeps/unix/sysv/linux/hppa/libc.abilist +++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist @@ -2373,6 +2373,7 @@ GLIBC_2.34 __sem_clockwait64 F GLIBC_2.34 __sem_timedwait64 F GLIBC_2.34 __semctl64 F GLIBC_2.34 __semtimedop64 F +GLIBC_2.34 __sendmmsg64 F GLIBC_2.34 __setitimer64 F GLIBC_2.34 __settimeofday64 F GLIBC_2.34 __shmctl64 F diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist index 70a0f7f1c3..2fae97c00c 100644 --- a/sysdeps/unix/sysv/linux/i386/libc.abilist +++ b/sysdeps/unix/sysv/linux/i386/libc.abilist @@ -2557,6 +2557,7 @@ GLIBC_2.34 __sem_clockwait64 F GLIBC_2.34 __sem_timedwait64 F GLIBC_2.34 __semctl64 F GLIBC_2.34 __semtimedop64 F +GLIBC_2.34 __sendmmsg64 F GLIBC_2.34 __setitimer64 F GLIBC_2.34 __settimeofday64 F GLIBC_2.34 __shmctl64 F diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist index 13ac607c49..c146c01b62 100644 --- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist +++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist @@ -267,6 +267,7 @@ GLIBC_2.34 __sem_clockwait64 F GLIBC_2.34 __sem_timedwait64 F GLIBC_2.34 __semctl64 F GLIBC_2.34 __semtimedop64 F +GLIBC_2.34 __sendmmsg64 F GLIBC_2.34 __setitimer64 F GLIBC_2.34 __settimeofday64 F GLIBC_2.34 __shmctl64 F diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist index 662a519095..dc23970913 100644 --- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist +++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist @@ -2500,6 +2500,7 @@ GLIBC_2.34 __sem_clockwait64 F GLIBC_2.34 __sem_timedwait64 F GLIBC_2.34 __semctl64 F GLIBC_2.34 __semtimedop64 F +GLIBC_2.34 __sendmmsg64 F GLIBC_2.34 __setitimer64 F GLIBC_2.34 __settimeofday64 F GLIBC_2.34 __shmctl64 F diff --git a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist index fc0c6b6acc..63b86f4613 100644 --- a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist +++ b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist @@ -2473,6 +2473,7 @@ GLIBC_2.34 __sem_clockwait64 F GLIBC_2.34 __sem_timedwait64 F GLIBC_2.34 __semctl64 F GLIBC_2.34 __semtimedop64 F +GLIBC_2.34 __sendmmsg64 F GLIBC_2.34 __setitimer64 F GLIBC_2.34 __settimeofday64 F GLIBC_2.34 __shmctl64 F diff --git a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist index 56a52de049..4f2811c869 100644 --- a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist +++ b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist @@ -2470,6 +2470,7 @@ GLIBC_2.34 __sem_clockwait64 F GLIBC_2.34 __sem_timedwait64 F GLIBC_2.34 __semctl64 F GLIBC_2.34 __semtimedop64 F +GLIBC_2.34 __sendmmsg64 F GLIBC_2.34 __setitimer64 F GLIBC_2.34 __settimeofday64 F GLIBC_2.34 __shmctl64 F diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist index 4aa9e33b7d..b3491fd1db 100644 --- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist @@ -2465,6 +2465,7 @@ GLIBC_2.34 __sem_clockwait64 F GLIBC_2.34 __sem_timedwait64 F GLIBC_2.34 __semctl64 F GLIBC_2.34 __semtimedop64 F +GLIBC_2.34 __sendmmsg64 F GLIBC_2.34 __setitimer64 F GLIBC_2.34 __settimeofday64 F GLIBC_2.34 __shmctl64 F diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist index 1c1227301b..7d56039df5 100644 --- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist @@ -2463,6 +2463,7 @@ GLIBC_2.34 __sem_clockwait64 F GLIBC_2.34 __sem_timedwait64 F GLIBC_2.34 __semctl64 F GLIBC_2.34 __semtimedop64 F +GLIBC_2.34 __sendmmsg64 F GLIBC_2.34 __setitimer64 F GLIBC_2.34 __settimeofday64 F GLIBC_2.34 __shmctl64 F diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist index 876893455e..0898b26a90 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist @@ -2471,6 +2471,7 @@ GLIBC_2.34 __sem_clockwait64 F GLIBC_2.34 __sem_timedwait64 F GLIBC_2.34 __semctl64 F GLIBC_2.34 __semtimedop64 F +GLIBC_2.34 __sendmmsg64 F GLIBC_2.34 __setitimer64 F GLIBC_2.34 __settimeofday64 F GLIBC_2.34 __shmctl64 F diff --git a/sysdeps/unix/sysv/linux/nios2/libc.abilist b/sysdeps/unix/sysv/linux/nios2/libc.abilist index dc41e17487..19b42df933 100644 --- a/sysdeps/unix/sysv/linux/nios2/libc.abilist +++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist @@ -2512,6 +2512,7 @@ GLIBC_2.34 __sem_clockwait64 F GLIBC_2.34 __sem_timedwait64 F GLIBC_2.34 __semctl64 F GLIBC_2.34 __semtimedop64 F +GLIBC_2.34 __sendmmsg64 F GLIBC_2.34 __setitimer64 F GLIBC_2.34 __settimeofday64 F GLIBC_2.34 __shmctl64 F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist index 9e3311a978..09179d2a48 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist @@ -2527,6 +2527,7 @@ GLIBC_2.34 __sem_clockwait64 F GLIBC_2.34 __sem_timedwait64 F GLIBC_2.34 __semctl64 F GLIBC_2.34 __semtimedop64 F +GLIBC_2.34 __sendmmsg64 F GLIBC_2.34 __setitimer64 F GLIBC_2.34 __settimeofday64 F GLIBC_2.34 __shmctl64 F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist index 2ac6aa068f..d45be8ab9e 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist @@ -2560,6 +2560,7 @@ GLIBC_2.34 __sem_clockwait64 F GLIBC_2.34 __sem_timedwait64 F GLIBC_2.34 __semctl64 F GLIBC_2.34 __semtimedop64 F +GLIBC_2.34 __sendmmsg64 F GLIBC_2.34 __setitimer64 F GLIBC_2.34 __settimeofday64 F GLIBC_2.34 __shmctl64 F diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist index 644f6b734c..c290ae4948 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist +++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist @@ -2525,6 +2525,7 @@ GLIBC_2.34 __sem_clockwait64 F GLIBC_2.34 __sem_timedwait64 F GLIBC_2.34 __semctl64 F GLIBC_2.34 __semtimedop64 F +GLIBC_2.34 __sendmmsg64 F GLIBC_2.34 __setitimer64 F GLIBC_2.34 __settimeofday64 F GLIBC_2.34 __shmctl64 F diff --git a/sysdeps/unix/sysv/linux/sendmmsg.c b/sysdeps/unix/sysv/linux/sendmmsg.c index 6093e9ed70..10aaff4d1f 100644 --- a/sysdeps/unix/sysv/linux/sendmmsg.c +++ b/sysdeps/unix/sysv/linux/sendmmsg.c @@ -35,3 +35,6 @@ __sendmmsg (int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags) } libc_hidden_def (__sendmmsg) weak_alias (__sendmmsg, sendmmsg) +#if __TIMESIZE != 64 +weak_alias (__sendmmsg, __sendmmsg64) +#endif diff --git a/sysdeps/unix/sysv/linux/sh/be/libc.abilist b/sysdeps/unix/sysv/linux/sh/be/libc.abilist index 369dccc4af..714f7d4f55 100644 --- a/sysdeps/unix/sysv/linux/sh/be/libc.abilist +++ b/sysdeps/unix/sysv/linux/sh/be/libc.abilist @@ -2380,6 +2380,7 @@ GLIBC_2.34 __sem_clockwait64 F GLIBC_2.34 __sem_timedwait64 F GLIBC_2.34 __semctl64 F GLIBC_2.34 __semtimedop64 F +GLIBC_2.34 __sendmmsg64 F GLIBC_2.34 __setitimer64 F GLIBC_2.34 __settimeofday64 F GLIBC_2.34 __shmctl64 F diff --git a/sysdeps/unix/sysv/linux/sh/le/libc.abilist b/sysdeps/unix/sysv/linux/sh/le/libc.abilist index 4254360898..9f858a4f68 100644 --- a/sysdeps/unix/sysv/linux/sh/le/libc.abilist +++ b/sysdeps/unix/sysv/linux/sh/le/libc.abilist @@ -2377,6 +2377,7 @@ GLIBC_2.34 __sem_clockwait64 F GLIBC_2.34 __sem_timedwait64 F GLIBC_2.34 __semctl64 F GLIBC_2.34 __semtimedop64 F +GLIBC_2.34 __sendmmsg64 F GLIBC_2.34 __setitimer64 F GLIBC_2.34 __settimeofday64 F GLIBC_2.34 __shmctl64 F diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist index 31f43ed414..2420775e21 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist @@ -2520,6 +2520,7 @@ GLIBC_2.34 __sem_clockwait64 F GLIBC_2.34 __sem_timedwait64 F GLIBC_2.34 __semctl64 F GLIBC_2.34 __semtimedop64 F +GLIBC_2.34 __sendmmsg64 F GLIBC_2.34 __setitimer64 F GLIBC_2.34 __settimeofday64 F GLIBC_2.34 __shmctl64 F diff --git a/sysdeps/unix/sysv/linux/tst-scm_rights-time64.c b/sysdeps/unix/sysv/linux/tst-scm_rights-time64.c new file mode 100644 index 0000000000..302613cbfa --- /dev/null +++ b/sysdeps/unix/sysv/linux/tst-scm_rights-time64.c @@ -0,0 +1 @@ +#include "tst-scm_rights.c" diff --git a/sysdeps/unix/sysv/linux/tst-scm_rights.c b/sysdeps/unix/sysv/linux/tst-scm_rights.c new file mode 100644 index 0000000000..c85b873125 --- /dev/null +++ b/sysdeps/unix/sysv/linux/tst-scm_rights.c @@ -0,0 +1,186 @@ +/* Smoke test for SCM_RIGHTS. + 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 + . */ + +/* This test passes a file descriptor from a subprocess to the parent + process, using recvmsg/sendmsg or recvmmsg/sendmmsg. */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* String sent over the socket. */ +static char DATA[] = "descriptor"; + +/* Path that is to be opened and sent over the socket. */ +#define PATH "/etc" + +/* True if sendmmsg/recvmmsg is to be used. */ +static bool use_multi_call; + +/* The pair of sockets used for coordination. The subprocess uses + sockets[1]. */ +static int sockets[2]; + +/* Subprocess side of one send/receive test. */ +_Noreturn static void +subprocess (void) +{ + /* The file descriptor to send. */ + int fd = xopen (PATH, O_RDONLY, 0); + + struct iovec iov = { .iov_base = DATA, .iov_len = sizeof (DATA) }; + union + { + struct cmsghdr header; + char bytes[CMSG_SPACE (sizeof (int))]; + } cmsg_storage; + struct mmsghdr mmhdr = + { + .msg_hdr = + { + .msg_iov = &iov, + .msg_iovlen = 1, + .msg_control = cmsg_storage.bytes, + .msg_controllen = sizeof (cmsg_storage), + }, + }; + + /* Configure the file descriptor for sending. */ + struct cmsghdr *cmsg = CMSG_FIRSTHDR (&mmhdr.msg_hdr); + cmsg->cmsg_level = SOL_SOCKET; + cmsg->cmsg_type = SCM_RIGHTS; + cmsg->cmsg_len = CMSG_LEN (sizeof (int)); + memcpy (CMSG_DATA (cmsg), &fd, sizeof (fd)); + mmhdr.msg_hdr.msg_controllen = cmsg->cmsg_len; + + /* Perform the send operation. */ + int ret; + if (use_multi_call) + { + ret = sendmmsg (sockets[1], &mmhdr, 1, 0); + if (ret >= 0) + ret = mmhdr.msg_len; + } + else + ret = sendmsg (sockets[1], &mmhdr.msg_hdr, 0); + TEST_COMPARE (ret, sizeof (DATA)); + + xclose (fd); + + /* Stop the process from exiting. */ + while (true) + pause (); +} + +/* Performs one send/receive test. */ +static void +one_test (void) +{ + TEST_COMPARE (socketpair (AF_UNIX, SOCK_STREAM, 0, sockets), 0); + + pid_t pid = xfork (); + if (pid == 0) + subprocess (); + + char data_storage[sizeof (DATA) + 1]; + struct iovec iov = + { + .iov_base = data_storage, + .iov_len = sizeof (data_storage) + }; + union + { + struct cmsghdr header; + char bytes[CMSG_SPACE (sizeof (int))]; + } cmsg_storage; + struct mmsghdr mmhdr = + { + .msg_hdr = + { + .msg_iov = &iov, + .msg_iovlen = 1, + .msg_control = cmsg_storage.bytes, + .msg_controllen = sizeof (cmsg_storage), + }, + }; + + /* Set up the space for receiving the file descriptor. */ + struct cmsghdr *cmsg = CMSG_FIRSTHDR (&mmhdr.msg_hdr); + cmsg->cmsg_level = SOL_SOCKET; + cmsg->cmsg_type = SCM_RIGHTS; + cmsg->cmsg_len = CMSG_LEN (sizeof (int)); + mmhdr.msg_hdr.msg_controllen = cmsg->cmsg_len; + + /* Perform the receive operation. */ + int ret; + if (use_multi_call) + { + ret = recvmmsg (sockets[0], &mmhdr, 1, 0, NULL); + if (ret >= 0) + ret = mmhdr.msg_len; + } + else + ret = recvmsg (sockets[0], &mmhdr.msg_hdr, 0); + TEST_COMPARE (ret, sizeof (DATA)); + TEST_COMPARE_BLOB (data_storage, sizeof (DATA), DATA, sizeof (DATA)); + + /* Extract the file descriptor. */ + TEST_VERIFY (CMSG_FIRSTHDR (&mmhdr.msg_hdr) != NULL); + TEST_COMPARE (CMSG_FIRSTHDR (&mmhdr.msg_hdr)->cmsg_len, + CMSG_LEN (sizeof (int))); + TEST_VERIFY (&cmsg_storage.header == CMSG_FIRSTHDR (&mmhdr.msg_hdr)); + int fd; + memcpy (&fd, CMSG_DATA (CMSG_FIRSTHDR (&mmhdr.msg_hdr)), sizeof (fd)); + + /* Verify the received file descriptor. */ + TEST_VERIFY (fd > 2); + struct stat64 st_fd; + TEST_COMPARE (fstat64 (fd, &st_fd), 0); + struct stat64 st_path; + TEST_COMPARE (stat64 (PATH, &st_path), 0); + TEST_COMPARE (st_fd.st_ino, st_path.st_ino); + TEST_COMPARE (st_fd.st_dev, st_path.st_dev); + xclose (fd); + + /* Terminate the subprocess. */ + TEST_COMPARE (kill (pid, SIGUSR1), 0); + int status; + TEST_COMPARE (xwaitpid (pid, &status, 0), pid); + TEST_VERIFY (WIFSIGNALED (status)); + TEST_COMPARE (WTERMSIG (status), SIGUSR1); + + xclose (sockets[0]); + xclose (sockets[1]); +} + +static int +do_test (void) +{ + one_test (); + use_multi_call = true; + one_test (); + return 0; +} + +#include