From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 dcvr.yhbt.net (Postfix) with ESMTPS id 5BACE1F9E0 for ; Tue, 28 Apr 2020 14:17:33 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 29E2D394881E; Tue, 28 Apr 2020 14:17:30 +0000 (GMT) Received: from albireo.enyo.de (albireo.enyo.de [37.24.231.21]) by sourceware.org (Postfix) with ESMTPS id E97B2394880D for ; Tue, 28 Apr 2020 14:17:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E97B2394880D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=deneb.enyo.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=fw@deneb.enyo.de Received: from [172.17.203.2] (helo=deneb.enyo.de) by albireo.enyo.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) id 1jTR2y-0005T4-5b; Tue, 28 Apr 2020 14:17:16 +0000 Received: from fw by deneb.enyo.de with local (Exim 4.92) (envelope-from ) id 1jTR2y-0004Wh-2x; Tue, 28 Apr 2020 16:17:16 +0200 From: Florian Weimer To: Alexandra =?iso-8859-1?Q?H=E1jkov=E1?= via Libc-alpha Subject: Re: [PATCH] Linux: Add execveat system call wrapper References: <20200428122019.26826-1-ahajkova@redhat.com> Date: Tue, 28 Apr 2020 16:17:16 +0200 In-Reply-To: <20200428122019.26826-1-ahajkova@redhat.com> ("Alexandra =?iso-8859-1?Q?H=E1jkov=E1?= via Libc-alpha"'s message of "Tue, 28 Apr 2020 14:20:19 +0200") Message-ID: <87lfmfpudv.fsf@mid.deneb.enyo.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable 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: , Cc: Alexandra =?iso-8859-1?Q?H=E1jkov=E1?= Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" * Alexandra H=E1jkov=E1 via Libc-alpha: > diff --git a/sysdeps/mach/hurd/i386/libc.abilist b/sysdeps/mach/hurd/i386= /libc.abilist > index 60696d827f..571c281b06 100644 > --- a/sysdeps/mach/hurd/i386/libc.abilist > +++ b/sysdeps/mach/hurd/i386/libc.abilist > @@ -2182,6 +2182,7 @@ GLIBC_2.3.4 xdr_quad_t F > GLIBC_2.3.4 xdr_u_quad_t F > GLIBC_2.30 twalk_r F > GLIBC_2.32 mach_print F > +GLIBC_2.32 execveat F > GLIBC_2.32 thrd_current F > GLIBC_2.32 thrd_equal F > GLIBC_2.32 thrd_sleep F > diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/M= akefile This is not correct because you are not adding execveat for Hurd. You can just remove that change. > diff --git a/sysdeps/unix/sysv/linux/bits/unistd_ext.h b/sysdeps/unix/sys= v/linux/bits/unistd_ext.h > index c315cc5cb8..55225b5447 100644 > --- a/sysdeps/unix/sysv/linux/bits/unistd_ext.h > +++ b/sysdeps/unix/sysv/linux/bits/unistd_ext.h > @@ -17,7 +17,7 @@ > . */ >=20=20 > #ifndef _UNISTD_H > -# error "Never include directly; use inst= ead." > +#error "Never include directly; use inste= ad." > #endif Spurious change, please remove it. > diff --git a/sysdeps/unix/sysv/linux/execveat.c b/sysdeps/unix/sysv/linux= /execveat.c > new file mode 100644 > index 0000000000..7ebf397091 > --- /dev/null > +++ b/sysdeps/unix/sysv/linux/execveat.c > @@ -0,0 +1,67 @@ > +/* Copyright (C) 1994-2020 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 > + > + > +/* Execute the file FD refers to, overlaying the running program image. > + ARGV and ENVP are passed to the new program, as for `execve'. */ > +int > +execveat (int dirfd, const char *path, char *const argv[], char *const e= nvp[], > + int flags) > +{ > + /* Avoid implicit array coercion in syscall macros. */ > + INLINE_SYSCALL_CALL (execveat, dirfd, path, &argv[0], &envp[0], flags); > +#ifndef __ASSUME_EXECVEAT > + if (errno !=3D ENOSYS) > + return -1; > + > + int fd =3D openat (dirfd, path, flags | O_CLOEXEC); > + if (fd < 0) > + return -1; > + > + struct fd_to_filename fdfilename; > + const char *gfilename > + =3D path !=3D NULL ? path : __fd_to_filename (fd, &fdfilename); > + > + /* We do not need the return value. */ > + __execve (gfilename, argv, envp); > + > + int save =3D errno; > + > + /* We come here only if the 'execve' call fails. Determine whether > + /proc is mounted. If not we return ENOSYS. */ > + struct stat st; > + if (stat ("/proc/self/fd", &st) !=3D 0 && errno =3D=3D ENOENT) > + save =3D ENOSYS; > + > + close (fd); > + __set_errno (save); > +#endif > + > + return -1; > +} I think you should use __openat_nocancel and __close_nocancel (from ) to avoid introducing cancellation points. It will also fix the elf/check-localplt failures. > diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist b/sysdeps/uni= x/sysv/linux/x86_64/64/libc.abilist > index 6418ace78a..8f4388bf44 100644 > --- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist > +++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist > @@ -2061,6 +2061,7 @@ GLIBC_2.30 gettid F > GLIBC_2.30 tgkill F > GLIBC_2.30 twalk_r F > GLIBC_2.32 pthread_sigmask F > +GLIBC_2.32 execveat F > GLIBC_2.4 __confstr_chk F > GLIBC_2.4 __fgets_chk F > GLIBC_2.4 __fgets_unlocked_chk F This is quite odd. Did you update the ABI list manually? The order of pthread_sigmask and execveat is wrong. This is what causes elf/check-abi-libc failures.