From owner-svn-src-all@freebsd.org Thu Jan 17 16:50:52 2019 Return-Path: Delivered-To: svn-src-all@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 4CDAE149CF63; Thu, 17 Jan 2019 16:50:52 +0000 (UTC) (envelope-from des@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 DFFCB706E6; Thu, 17 Jan 2019 16:50:51 +0000 (UTC) (envelope-from des@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 C59731CF52; Thu, 17 Jan 2019 16:50:51 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x0HGopil026447; Thu, 17 Jan 2019 16:50:51 GMT (envelope-from des@FreeBSD.org) Received: (from des@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x0HGopPY026445; Thu, 17 Jan 2019 16:50:51 GMT (envelope-from des@FreeBSD.org) Message-Id: <201901171650.x0HGopPY026445@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: des set sender to des@FreeBSD.org using -f From: =?UTF-8?Q?Dag-Erling_Sm=c3=b8rgrav?= Date: Thu, 17 Jan 2019 16:50:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r343116 - in head: include lib/libc/gen libexec/rtld-elf X-SVN-Group: head X-SVN-Commit-Author: des X-SVN-Commit-Paths: in head: include lib/libc/gen libexec/rtld-elf X-SVN-Commit-Revision: 343116 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: DFFCB706E6 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.97)[-0.965,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-0.999,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Jan 2019 16:50:52 -0000 Author: des Date: Thu Jan 17 16:50:50 2019 New Revision: 343116 URL: https://svnweb.freebsd.org/changeset/base/343116 Log: Revert r343093 until I can address the issues raised by kib@. Modified: head/include/dlfcn.h head/lib/libc/gen/dlopen.3 head/libexec/rtld-elf/rtld.c Modified: head/include/dlfcn.h ============================================================================== --- head/include/dlfcn.h Thu Jan 17 16:26:59 2019 (r343115) +++ head/include/dlfcn.h Thu Jan 17 16:50:50 2019 (r343116) @@ -120,7 +120,6 @@ void *dlopen(const char *, int); void *dlsym(void * __restrict, const char * __restrict); #if __BSD_VISIBLE -void *dlopenat(int, const char *, int); void *fdlopen(int, int); int dladdr(const void * __restrict, Dl_info * __restrict); dlfunc_t dlfunc(void * __restrict, const char * __restrict); Modified: head/lib/libc/gen/dlopen.3 ============================================================================== --- head/lib/libc/gen/dlopen.3 Thu Jan 17 16:26:59 2019 (r343115) +++ head/lib/libc/gen/dlopen.3 Thu Jan 17 16:50:50 2019 (r343116) @@ -32,12 +32,11 @@ .\" @(#) dlopen.3 1.6 90/01/31 SMI .\" $FreeBSD$ .\" -.Dd January 15, 2019 +.Dd January 2, 2019 .Dt DLOPEN 3 .Os .Sh NAME .Nm dlopen , -.Nm dlopenat , .Nm fdlopen , .Nm dlsym , .Nm dlvsym , @@ -52,8 +51,6 @@ .Ft void * .Fn dlopen "const char *path" "int mode" .Ft void * -.Fn dlopenat "int fd" "const char *path" "int mode" -.Ft void * .Fn fdlopen "int fd" "int mode" .Ft void * .Fn dlsym "void * restrict handle" "const char * restrict symbol" @@ -172,24 +169,6 @@ If fails, it returns a null pointer, and sets an error condition which may be interrogated with .Fn dlerror . -.Pp -The -.Fn dlopenat -function is equivalent to -.Fn dlopen -except in the case where the path specifies a relative path. -In this case the file to be opened is determined relative to the -directory associated with the file descriptor fd instead of the -current working directory. -If -.Fn dlopenat -is passed the special value -.Dv AT_FDCWD -in the -.Fa fd -parameter, the current working directory is used and the behavior is -identical to a call to -.Fn dlopen . .Pp The .Fn fdlopen Modified: head/libexec/rtld-elf/rtld.c ============================================================================== --- head/libexec/rtld-elf/rtld.c Thu Jan 17 16:26:59 2019 (r343115) +++ head/libexec/rtld-elf/rtld.c Thu Jan 17 16:50:50 2019 (r343116) @@ -93,8 +93,8 @@ static void digest_dynamic(Obj_Entry *, int); static Obj_Entry *digest_phdr(const Elf_Phdr *, int, caddr_t, const char *); static Obj_Entry *dlcheck(void *); static int dlclose_locked(void *, RtldLockState *); -static Obj_Entry *dlopen_object(int, const char *name, int fd, - Obj_Entry *refobj, int lo_flags, int mode, RtldLockState *lockstate); +static Obj_Entry *dlopen_object(const char *name, int fd, Obj_Entry *refobj, + int lo_flags, int mode, RtldLockState *lockstate); static Obj_Entry *do_load_object(int, const char *, char *, struct stat *, int); static int do_search_info(const Obj_Entry *obj, int, struct dl_serinfo *); static bool donelist_check(DoneList *, const Obj_Entry *); @@ -118,7 +118,7 @@ static void load_filtees(Obj_Entry *, int flags, RtldL static void unload_filtees(Obj_Entry *, RtldLockState *); static int load_needed_objects(Obj_Entry *, int); static int load_preload_objects(void); -static Obj_Entry *load_object(int, const char *, int, const Obj_Entry *, int); +static Obj_Entry *load_object(const char *, int fd, const Obj_Entry *, int); static void map_stacks_exec(RtldLockState *); static int obj_disable_relro(Obj_Entry *); static int obj_enforce_relro(Obj_Entry *); @@ -147,7 +147,7 @@ static int relocate_objects(Obj_Entry *, bool, Obj_Ent static int resolve_object_ifunc(Obj_Entry *, bool, int, RtldLockState *); static int rtld_dirname(const char *, char *); static int rtld_dirname_abs(const char *, char *); -static void *rtld_dlopen(int, const char *name, int fd, int mode); +static void *rtld_dlopen(const char *name, int fd, int mode); static void rtld_exit(void); static char *search_library_path(const char *, const char *, const char *, int *); @@ -231,7 +231,6 @@ extern Elf_Dyn _DYNAMIC; int dlclose(void *) __exported; char *dlerror(void) __exported; void *dlopen(const char *, int) __exported; -void *dlopenat(int, const char *, int) __exported; void *fdlopen(int, int) __exported; void *dlsym(void *, const char *) __exported; dlfunc_t dlfunc(void *, const char *) __exported; @@ -2293,8 +2292,8 @@ load_filtee1(Obj_Entry *obj, Needed_Entry *needed, int { for (; needed != NULL; needed = needed->next) { - needed->obj = dlopen_object(AT_FDCWD, obj->strtab + needed->name, -1, - obj, flags, ((ld_loadfltr || obj->z_loadfltr) ? RTLD_NOW : RTLD_LAZY) | + needed->obj = dlopen_object(obj->strtab + needed->name, -1, obj, + flags, ((ld_loadfltr || obj->z_loadfltr) ? RTLD_NOW : RTLD_LAZY) | RTLD_LOCAL, lockstate); } } @@ -2317,8 +2316,8 @@ process_needed(Obj_Entry *obj, Needed_Entry *needed, i Obj_Entry *obj1; for (; needed != NULL; needed = needed->next) { - obj1 = needed->obj = load_object(AT_FDCWD, obj->strtab + needed->name, - -1, obj, flags & ~RTLD_LO_NOLOAD); + obj1 = needed->obj = load_object(obj->strtab + needed->name, -1, obj, + flags & ~RTLD_LO_NOLOAD); if (obj1 == NULL && !ld_tracing && (flags & RTLD_LO_FILTEES) == 0) return (-1); } @@ -2361,7 +2360,7 @@ load_preload_objects(void) savech = p[len]; p[len] = '\0'; - obj = load_object(AT_FDCWD, p, -1, NULL, 0); + obj = load_object(p, -1, NULL, 0); if (obj == NULL) return -1; /* XXX - cleanup */ obj->z_interpose = true; @@ -2390,8 +2389,7 @@ printable_path(const char *path) * on failure. */ static Obj_Entry * -load_object(int atfd, const char *name, int fd_u, const Obj_Entry *refobj, - int flags) +load_object(const char *name, int fd_u, const Obj_Entry *refobj, int flags) { Obj_Entry *obj; int fd; @@ -2428,7 +2426,7 @@ load_object(int atfd, const char *name, int fd_u, cons * To avoid a race, we open the file and use fstat() rather than * using stat(). */ - if ((fd = openat(atfd, path, O_RDONLY | O_CLOEXEC | O_VERIFY)) == -1) { + if ((fd = open(path, O_RDONLY | O_CLOEXEC | O_VERIFY)) == -1) { _rtld_error("Cannot open \"%s\"", path); free(path); return (NULL); @@ -3257,28 +3255,21 @@ dllockinit(void *context, } void * -dlopenat(int fd, const char *name, int mode) -{ - - return (rtld_dlopen(fd, name, -1, mode)); -} - -void * dlopen(const char *name, int mode) { - return (rtld_dlopen(AT_FDCWD, name, -1, mode)); + return (rtld_dlopen(name, -1, mode)); } void * fdlopen(int fd, int mode) { - return (rtld_dlopen(AT_FDCWD, NULL, fd, mode)); + return (rtld_dlopen(NULL, fd, mode)); } static void * -rtld_dlopen(int atfd, const char *name, int fd, int mode) +rtld_dlopen(const char *name, int fd, int mode) { RtldLockState lockstate; int lo_flags; @@ -3300,7 +3291,7 @@ rtld_dlopen(int atfd, const char *name, int fd, int mo if (ld_tracing != NULL) lo_flags |= RTLD_LO_TRACE; - return (dlopen_object(atfd, name, fd, obj_main, lo_flags, + return (dlopen_object(name, fd, obj_main, lo_flags, mode & (RTLD_MODEMASK | RTLD_GLOBAL), NULL)); } @@ -3315,8 +3306,8 @@ dlopen_cleanup(Obj_Entry *obj, RtldLockState *lockstat } static Obj_Entry * -dlopen_object(int atfd, const char *name, int fd, Obj_Entry *refobj, - int lo_flags, int mode, RtldLockState *lockstate) +dlopen_object(const char *name, int fd, Obj_Entry *refobj, int lo_flags, + int mode, RtldLockState *lockstate) { Obj_Entry *old_obj_tail; Obj_Entry *obj; @@ -3338,7 +3329,7 @@ dlopen_object(int atfd, const char *name, int fd, Obj_ obj = obj_main; obj->refcount++; } else { - obj = load_object(atfd, name, fd, refobj, lo_flags); + obj = load_object(name, fd, refobj, lo_flags); } if (obj) {