From owner-svn-src-stable@freebsd.org Thu Nov 21 00:40:14 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0585A1C72F3; Thu, 21 Nov 2019 00:40:14 +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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47JLLj6L75z4b1c; Thu, 21 Nov 2019 00:40:13 +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 B86B12F9D; Thu, 21 Nov 2019 00:40:13 +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 xAL0eD6B068781; Thu, 21 Nov 2019 00:40:13 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xAL0eD7P068779; Thu, 21 Nov 2019 00:40:13 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <201911210040.xAL0eD7P068779@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Thu, 21 Nov 2019 00:40:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354928 - in stable/12: lib/libc/gen sys/sys X-SVN-Group: stable-12 X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: in stable/12: lib/libc/gen sys/sys X-SVN-Commit-Revision: 354928 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Nov 2019 00:40:14 -0000 Author: brooks Date: Thu Nov 21 00:40:12 2019 New Revision: 354928 URL: https://svnweb.freebsd.org/changeset/base/354928 Log: MFC r354694, r354699 r354694: elf_aux_info: Add support for AT_EXECPATH. Reviewed by: emaste, sef Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D22353 r354699: Improve the description of AT_EXECPATH availability. Reported by: kib Sponsored by: DARPA, AFRL Modified: stable/12/lib/libc/gen/auxv.3 stable/12/lib/libc/gen/auxv.c stable/12/sys/sys/param.h Directory Properties: stable/12/ (props changed) Modified: stable/12/lib/libc/gen/auxv.3 ============================================================================== --- stable/12/lib/libc/gen/auxv.3 Thu Nov 21 00:34:39 2019 (r354927) +++ stable/12/lib/libc/gen/auxv.3 Thu Nov 21 00:40:12 2019 (r354928) @@ -49,6 +49,12 @@ can be requested (corresponding buffer sizes are speci .It AT_CANARY The canary value for SSP (arbitrary sized buffer, as many bytes are returned as it fits into it, rest is zeroed). +.It AT_EXECPATH +The path of executed program +.Dv (MAXPATHLEN). +This may not be present if the process was initialized by +.Xr fexecve 2 +and the namecache no longer contains the file's name. .It AT_HWCAP CPU / hardware feature flags .Dv (sizeof(u_long)). Modified: stable/12/lib/libc/gen/auxv.c ============================================================================== --- stable/12/lib/libc/gen/auxv.c Thu Nov 21 00:34:39 2019 (r354927) +++ stable/12/lib/libc/gen/auxv.c Thu Nov 21 00:40:12 2019 (r354928) @@ -69,7 +69,7 @@ __init_elf_aux_vector(void) static pthread_once_t aux_once = PTHREAD_ONCE_INIT; static int pagesize, osreldate, canary_len, ncpus, pagesizes_len; static int hwcap_present, hwcap2_present; -static char *canary, *pagesizes; +static char *canary, *pagesizes, *execpath; static void *timekeep; static u_long hwcap, hwcap2; @@ -88,6 +88,10 @@ init_aux(void) canary_len = aux->a_un.a_val; break; + case AT_EXECPATH: + execpath = (char *)(aux->a_un.a_ptr); + break; + case AT_HWCAP: hwcap_present = 1; hwcap = (u_long)(aux->a_un.a_val); @@ -146,6 +150,18 @@ _elf_aux_info(int aux, void *buf, int buflen) res = 0; } else res = ENOENT; + break; + case AT_EXECPATH: + if (execpath == NULL) + res = ENOENT; + else if (buf == NULL) + res = EINVAL; + else { + if (strlcpy(buf, execpath, buflen) >= buflen) + res = EINVAL; + else + res = 0; + } break; case AT_HWCAP: if (hwcap_present && buflen == sizeof(u_long)) { Modified: stable/12/sys/sys/param.h ============================================================================== --- stable/12/sys/sys/param.h Thu Nov 21 00:34:39 2019 (r354927) +++ stable/12/sys/sys/param.h Thu Nov 21 00:40:12 2019 (r354928) @@ -60,7 +60,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1201502 /* Master, propagated to newvers */ +#define __FreeBSD_version 1201503 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,