-# $OpenBSD: Makefile,v 1.83 2022/11/05 18:44:09 deraadt Exp $
+# $OpenBSD: Makefile,v 1.84 2023/02/18 01:22:50 deraadt Exp $
SUBDIR=ldconfig ldd
MAN= ld.so.1
SRCS+= malloc.c reallocarray.c tib.c ffs.c
syscall=close exit fstat getdents getentropy getthrid issetugid kbind \
- mimmutable mmap mprotect munmap msyscall open pledge read \
- __realpath sendsyslog __set_tcb sysctl thrkill utrace write
+ mimmutable mmap mprotect munmap msyscall open pledge pinsyscall \
+ read __realpath sendsyslog __set_tcb sysctl thrkill utrace write \
.if (${MACHINE_ARCH} == "i386")
syscall+=mquery
-/* $OpenBSD: loader.c,v 1.210 2023/01/29 20:30:56 gnezdo Exp $ */
+/* $OpenBSD: loader.c,v 1.211 2023/02/18 01:22:50 deraadt Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
#include <sys/types.h>
#include <sys/mman.h>
+#include <sys/syscall.h>
#include <sys/exec.h>
#ifdef __i386__
# include <machine/vmparam.h>
int
_dl_load_dep_libs(elf_object_t *object, int flags, int booting)
{
- elf_object_t *dynobj;
+ elf_object_t *dynobj, *obj;
Elf_Dyn *dynp;
unsigned int loop;
int libcount;
_dl_cache_grpsym_list_setup(object);
+ for (obj = _dl_objects; booting && obj != NULL; obj = obj->next) {
+ char *soname = (char *)obj->Dyn.info[DT_SONAME];
+ struct sym_res sr;
+
+ if (soname && _dl_strncmp(soname, "libc.so.", 8))
+ continue;
+ sr = _dl_find_symbol("execve",
+ SYM_SEARCH_SELF|SYM_PLT|SYM_WARNNOTFOUND, NULL, obj);
+ if (sr.sym)
+ _dl_pinsyscall(SYS_execve,
+ (void *)sr.obj->obj_base + sr.sym->st_value,
+ sr.sym->st_size);
+ _dl_memset(&sr, 0, sizeof sr);
+ break;
+ }
return(0);
}
-/* $OpenBSD: syscall.h,v 1.3 2022/11/05 18:44:09 deraadt Exp $ */
+/* $OpenBSD: syscall.h,v 1.4 2023/02/18 01:22:50 deraadt Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
int _dl_mprotect(const void *, size_t, int);
void *_dl_mquery(void *, size_t, int, int, int, off_t);
int _dl_msyscall(void *addr, size_t len);
+int _dl_pinsyscall(int, void *addr, size_t len);
int _dl_munmap(const void *, size_t);
int _dl_mimmutable(const void *, size_t);
int _dl_open(const char *, int);