From owner-svn-src-head@freebsd.org Thu Apr 12 18:23:16 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B6205F842F6; Thu, 12 Apr 2018 18:23:16 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 636A36BC35; Thu, 12 Apr 2018 18:23:16 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5E4156F01; Thu, 12 Apr 2018 18:23:16 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3CINGwt070667; Thu, 12 Apr 2018 18:23:16 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3CINEHl070653; Thu, 12 Apr 2018 18:23:14 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <201804121823.w3CINEHl070653@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Thu, 12 Apr 2018 18:23:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r332443 - in head/lib/libc: amd64 amd64/sys gen i386 i386/sys mips/sys powerpc powerpc/sys powerpc64 powerpc64/sys sparc64 sparc64/sys X-SVN-Group: head X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: in head/lib/libc: amd64 amd64/sys gen i386 i386/sys mips/sys powerpc powerpc/sys powerpc64 powerpc64/sys sparc64 sparc64/sys X-SVN-Commit-Revision: 332443 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Apr 2018 18:23:17 -0000 Author: brooks Date: Thu Apr 12 18:23:14 2018 New Revision: 332443 URL: https://svnweb.freebsd.org/changeset/base/332443 Log: Replace MD assembly exect() with a portable version. Originally, on the VAX exect() enable tracing once the new executable image was loaded. This was possible because tracing was controllable through user space code by setting the PSL_T flag. The following instruction is a system call that activated tracing (as all instructions do) by copying PSL_T to PSL_TP (trace pending). The first instruction of the new executable image would trigger a trace fault. This is not portable to all platforms and the behavior was replaced with ptrace(PT_TRACE_ME, ...) since FreeBSD forked off of the CSRG repository. Platforms either incorrectly call execve(), trigger trace faults inside the original executable, or do contain an implementation of this function. The exect() interfaces is deprecated or removed on NetBSD and OpenBSD. Submitted by: Ali Mashtizadeh Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D14989 Added: head/lib/libc/gen/exect.c (contents, props changed) Deleted: head/lib/libc/amd64/sys/exect.S head/lib/libc/i386/sys/exect.S head/lib/libc/mips/sys/exect.S head/lib/libc/powerpc/sys/exect.S head/lib/libc/powerpc64/sys/exect.S head/lib/libc/sparc64/sys/exect.S Modified: head/lib/libc/amd64/Symbol.map head/lib/libc/amd64/sys/Makefile.inc head/lib/libc/gen/Makefile.inc head/lib/libc/gen/Symbol.map head/lib/libc/i386/Symbol.map head/lib/libc/i386/sys/Makefile.inc head/lib/libc/mips/sys/Makefile.inc head/lib/libc/powerpc/Symbol.map head/lib/libc/powerpc/sys/Makefile.inc head/lib/libc/powerpc64/Symbol.map head/lib/libc/powerpc64/sys/Makefile.inc head/lib/libc/sparc64/Symbol.map head/lib/libc/sparc64/sys/Makefile.inc Modified: head/lib/libc/amd64/Symbol.map ============================================================================== --- head/lib/libc/amd64/Symbol.map Thu Apr 12 17:47:36 2018 (r332442) +++ head/lib/libc/amd64/Symbol.map Thu Apr 12 18:23:14 2018 (r332443) @@ -40,7 +40,6 @@ FBSD_1.0 { amd64_set_fsbase; amd64_set_gsbase; brk; - exect; sbrk; vfork; }; Modified: head/lib/libc/amd64/sys/Makefile.inc ============================================================================== --- head/lib/libc/amd64/sys/Makefile.inc Thu Apr 12 17:47:36 2018 (r332442) +++ head/lib/libc/amd64/sys/Makefile.inc Thu Apr 12 18:23:14 2018 (r332443) @@ -8,8 +8,7 @@ SRCS+= \ amd64_set_fsbase.c \ amd64_set_gsbase.c -MDASM= vfork.S brk.S cerror.S exect.S getcontext.S \ - sbrk.S +MDASM= vfork.S brk.S cerror.S getcontext.S sbrk.S # Don't generate default code for these syscalls: NOASM+= vfork.o Modified: head/lib/libc/gen/Makefile.inc ============================================================================== --- head/lib/libc/gen/Makefile.inc Thu Apr 12 17:47:36 2018 (r332442) +++ head/lib/libc/gen/Makefile.inc Thu Apr 12 18:23:14 2018 (r332443) @@ -41,6 +41,7 @@ SRCS+= __getosreldate.c \ errlst.c \ errno.c \ exec.c \ + exect.c \ fdevname.c \ feature_present.c \ fmtcheck.c \ Modified: head/lib/libc/gen/Symbol.map ============================================================================== --- head/lib/libc/gen/Symbol.map Thu Apr 12 17:47:36 2018 (r332442) +++ head/lib/libc/gen/Symbol.map Thu Apr 12 18:23:14 2018 (r332443) @@ -105,6 +105,7 @@ FBSD_1.0 { sys_errlist; sys_nerr; errno; + exect; execl; execle; execlp; Added: head/lib/libc/gen/exect.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/libc/gen/exect.c Thu Apr 12 18:23:14 2018 (r332443) @@ -0,0 +1,45 @@ +/*- + * Copyright (c) 2018 Ali Mashtizadeh + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +#include +#include + +int +exect(const char *path, char *const argv[], char *const envp[]) +{ + + if (ptrace(PT_TRACE_ME, 0, 0, 0) != 0) { + if (errno != EBUSY) + return (-1); + } + + return (execve(path, argv, envp)); +} Modified: head/lib/libc/i386/Symbol.map ============================================================================== --- head/lib/libc/i386/Symbol.map Thu Apr 12 17:47:36 2018 (r332442) +++ head/lib/libc/i386/Symbol.map Thu Apr 12 18:23:14 2018 (r332443) @@ -31,7 +31,6 @@ FBSD_1.0 { ntohs; vfork; brk; - exect; i386_clr_watch; i386_get_fsbase; i386_get_gsbase; Modified: head/lib/libc/i386/sys/Makefile.inc ============================================================================== --- head/lib/libc/i386/sys/Makefile.inc Thu Apr 12 17:47:36 2018 (r332442) +++ head/lib/libc/i386/sys/Makefile.inc Thu Apr 12 18:23:14 2018 (r332443) @@ -7,8 +7,7 @@ SRCS+= i386_clr_watch.c i386_set_watch.c i386_vm86.c SRCS+= i386_get_fsbase.c i386_get_gsbase.c i386_get_ioperm.c i386_get_ldt.c \ i386_set_fsbase.c i386_set_gsbase.c i386_set_ioperm.c i386_set_ldt.c -MDASM= Ovfork.S brk.S cerror.S exect.S getcontext.S \ - sbrk.S syscall.S +MDASM= Ovfork.S brk.S cerror.S getcontext.S sbrk.S syscall.S NOASM+= vfork.o Modified: head/lib/libc/mips/sys/Makefile.inc ============================================================================== --- head/lib/libc/mips/sys/Makefile.inc Thu Apr 12 17:47:36 2018 (r332442) +++ head/lib/libc/mips/sys/Makefile.inc Thu Apr 12 18:23:14 2018 (r332443) @@ -2,8 +2,7 @@ SRCS+= trivial-vdso_tc.c -MDASM= Ovfork.S brk.S cerror.S exect.S \ - sbrk.S syscall.S +MDASM= Ovfork.S brk.S cerror.S sbrk.S syscall.S # Don't generate default code for these syscalls: NOASM+= vfork.o Modified: head/lib/libc/powerpc/Symbol.map ============================================================================== --- head/lib/libc/powerpc/Symbol.map Thu Apr 12 17:47:36 2018 (r332442) +++ head/lib/libc/powerpc/Symbol.map Thu Apr 12 18:23:14 2018 (r332443) @@ -33,7 +33,6 @@ FBSD_1.0 { ntohl; ntohs; brk; - exect; sbrk; vfork; }; Modified: head/lib/libc/powerpc/sys/Makefile.inc ============================================================================== --- head/lib/libc/powerpc/sys/Makefile.inc Thu Apr 12 17:47:36 2018 (r332442) +++ head/lib/libc/powerpc/sys/Makefile.inc Thu Apr 12 18:23:14 2018 (r332443) @@ -1,3 +1,3 @@ # $FreeBSD$ -MDASM+= brk.S cerror.S exect.S sbrk.S +MDASM+= brk.S cerror.S sbrk.S Modified: head/lib/libc/powerpc64/Symbol.map ============================================================================== --- head/lib/libc/powerpc64/Symbol.map Thu Apr 12 17:47:36 2018 (r332442) +++ head/lib/libc/powerpc64/Symbol.map Thu Apr 12 18:23:14 2018 (r332443) @@ -33,7 +33,6 @@ FBSD_1.0 { ntohl; ntohs; brk; - exect; sbrk; vfork; }; Modified: head/lib/libc/powerpc64/sys/Makefile.inc ============================================================================== --- head/lib/libc/powerpc64/sys/Makefile.inc Thu Apr 12 17:47:36 2018 (r332442) +++ head/lib/libc/powerpc64/sys/Makefile.inc Thu Apr 12 18:23:14 2018 (r332443) @@ -1,3 +1,3 @@ # $FreeBSD$ -MDASM+= brk.S cerror.S exect.S sbrk.S +MDASM+= brk.S cerror.S sbrk.S Modified: head/lib/libc/sparc64/Symbol.map ============================================================================== --- head/lib/libc/sparc64/Symbol.map Thu Apr 12 17:47:36 2018 (r332442) +++ head/lib/libc/sparc64/Symbol.map Thu Apr 12 18:23:14 2018 (r332443) @@ -33,7 +33,6 @@ FBSD_1.0 { ntohl; ntohs; brk; - exect; sbrk; vfork; @@ -82,8 +81,6 @@ FBSDprivate_1.0 { __siglongjmp; __sys_brk; _brk; - __sys_exect; - _exect; _end; __sys_sbrk; _sbrk; Modified: head/lib/libc/sparc64/sys/Makefile.inc ============================================================================== --- head/lib/libc/sparc64/sys/Makefile.inc Thu Apr 12 17:47:36 2018 (r332442) +++ head/lib/libc/sparc64/sys/Makefile.inc Thu Apr 12 18:23:14 2018 (r332443) @@ -12,4 +12,4 @@ SRCS+= __sparc_sigtramp_setup.c \ CFLAGS+= -I${LIBC_SRCTOP}/sparc64/fpu -MDASM+= brk.S cerror.S exect.S sbrk.S sigaction1.S +MDASM+= brk.S cerror.S sbrk.S sigaction1.S