Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/wrapped/generated/functions_list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@
#() cFpdp
#() wFppp
#() iFEiw
#() iFEiu
#() iFEip
#() iFEWW
#() iFEup
Expand Down Expand Up @@ -1783,6 +1784,7 @@
#() vFppppu
#() vFppppL
#() vFppppp
#() iFEiipu
#() iFEiipp
#() iFEiipV
#() iFEiipA
Expand Down Expand Up @@ -5071,6 +5073,8 @@ wrappedlibc:
- vFpA:
- vwarn
- vwarnx
- iFiu:
- pidfd_open
- iFip:
- fstat
- fstat64
Expand Down Expand Up @@ -5246,6 +5250,8 @@ wrappedlibc:
- epoll_ctl
- iFiiiN:
- semctl
- iFiipu:
- pidfd_send_signal
- iFiipV:
- __dprintf_chk
- iFiipA:
Expand Down
4 changes: 4 additions & 0 deletions src/wrapped/generated/wrappedlibctypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ typedef void (*vFpu_t)(void*, uint32_t);
typedef void (*vFpp_t)(void*, void*);
typedef void (*vFpV_t)(void*, ...);
typedef void (*vFpA_t)(void*, va_list);
typedef int32_t (*iFiu_t)(int32_t, uint32_t);
typedef int32_t (*iFip_t)(int32_t, void*);
typedef int32_t (*iFup_t)(uint32_t, void*);
typedef int32_t (*iFpi_t)(void*, int32_t);
Expand Down Expand Up @@ -76,6 +77,7 @@ typedef void (*vFppiV_t)(void*, void*, int32_t, ...);
typedef void (*vFpppp_t)(void*, void*, void*, void*);
typedef int32_t (*iFiiip_t)(int32_t, int32_t, int32_t, void*);
typedef int32_t (*iFiiiN_t)(int32_t, int32_t, int32_t, ...);
typedef int32_t (*iFiipu_t)(int32_t, int32_t, void*, uint32_t);
typedef int32_t (*iFiipV_t)(int32_t, int32_t, void*, ...);
typedef int32_t (*iFiipA_t)(int32_t, int32_t, void*, va_list);
typedef int32_t (*iFipii_t)(int32_t, void*, int32_t, int32_t);
Expand Down Expand Up @@ -163,6 +165,7 @@ typedef int32_t (*iFppipppp_t)(void*, void*, int32_t, void*, void*, void*, void*
GO(warnx, vFpV_t) \
GO(vwarn, vFpA_t) \
GO(vwarnx, vFpA_t) \
GO(pidfd_open, iFiu_t) \
GO(fstat, iFip_t) \
GO(fstat64, iFip_t) \
GO(setrlimit, iFup_t) \
Expand Down Expand Up @@ -292,6 +295,7 @@ typedef int32_t (*iFppipppp_t)(void*, void*, int32_t, void*, void*, void*, void*
GO(__libc_init, vFpppp_t) \
GO(epoll_ctl, iFiiip_t) \
GO(semctl, iFiiiN_t) \
GO(pidfd_send_signal, iFiipu_t) \
GO(__dprintf_chk, iFiipV_t) \
GO(__vdprintf_chk, iFiipA_t) \
GO(epoll_wait, iFipii_t) \
Expand Down
4 changes: 4 additions & 0 deletions src/wrapped/generated/wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ typedef void (*vFSpL_t)(void*, void*, uintptr_t);
typedef int8_t (*cFpdp_t)(void*, double, void*);
typedef int16_t (*wFppp_t)(void*, void*, void*);
typedef int32_t (*iFEiw_t)(x64emu_t*, int32_t, int16_t);
typedef int32_t (*iFEiu_t)(x64emu_t*, int32_t, uint32_t);
typedef int32_t (*iFEip_t)(x64emu_t*, int32_t, void*);
typedef int32_t (*iFEWW_t)(x64emu_t*, uint16_t, uint16_t);
typedef int32_t (*iFEup_t)(x64emu_t*, uint32_t, void*);
Expand Down Expand Up @@ -1811,6 +1812,7 @@ typedef void (*vFppppi_t)(void*, void*, void*, void*, int32_t);
typedef void (*vFppppu_t)(void*, void*, void*, void*, uint32_t);
typedef void (*vFppppL_t)(void*, void*, void*, void*, uintptr_t);
typedef void (*vFppppp_t)(void*, void*, void*, void*, void*);
typedef int32_t (*iFEiipu_t)(x64emu_t*, int32_t, int32_t, void*, uint32_t);
typedef int32_t (*iFEiipp_t)(x64emu_t*, int32_t, int32_t, void*, void*);
typedef int32_t (*iFEiipV_t)(x64emu_t*, int32_t, int32_t, void*, void*);
typedef int32_t (*iFEiipA_t)(x64emu_t*, int32_t, int32_t, void*, void*);
Expand Down Expand Up @@ -4456,6 +4458,7 @@ void vFSpL(x64emu_t *emu, uintptr_t fcn) { vFSpL_t fn = (vFSpL_t)fcn; fn(io_conv
void cFpdp(x64emu_t *emu, uintptr_t fcn) { cFpdp_t fn = (cFpdp_t)fcn; R_RAX=(uint8_t)fn((void*)R_RDI, emu->xmm[0].d[0], (void*)R_RSI); }
void wFppp(x64emu_t *emu, uintptr_t fcn) { wFppp_t fn = (wFppp_t)fcn; R_RAX=(uint16_t)fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX); }
void iFEiw(x64emu_t *emu, uintptr_t fcn) { iFEiw_t fn = (iFEiw_t)fcn; R_RAX=(uint32_t)fn(emu, (int32_t)R_RDI, (int16_t)R_RSI); }
void iFEiu(x64emu_t *emu, uintptr_t fcn) { iFEiu_t fn = (iFEiu_t)fcn; R_RAX=(uint32_t)fn(emu, (int32_t)R_RDI, (uint32_t)R_RSI); }
void iFEip(x64emu_t *emu, uintptr_t fcn) { iFEip_t fn = (iFEip_t)fcn; R_RAX=(uint32_t)fn(emu, (int32_t)R_RDI, (void*)R_RSI); }
void iFEWW(x64emu_t *emu, uintptr_t fcn) { iFEWW_t fn = (iFEWW_t)fcn; R_RAX=(uint32_t)fn(emu, (uint16_t)R_RDI, (uint16_t)R_RSI); }
void iFEup(x64emu_t *emu, uintptr_t fcn) { iFEup_t fn = (iFEup_t)fcn; R_RAX=(uint32_t)fn(emu, (uint32_t)R_RDI, (void*)R_RSI); }
Expand Down Expand Up @@ -5711,6 +5714,7 @@ void vFppppi(x64emu_t *emu, uintptr_t fcn) { vFppppi_t fn = (vFppppi_t)fcn; fn((
void vFppppu(x64emu_t *emu, uintptr_t fcn) { vFppppu_t fn = (vFppppu_t)fcn; fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (uint32_t)R_R8); }
void vFppppL(x64emu_t *emu, uintptr_t fcn) { vFppppL_t fn = (vFppppL_t)fcn; fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (uintptr_t)R_R8); }
void vFppppp(x64emu_t *emu, uintptr_t fcn) { vFppppp_t fn = (vFppppp_t)fcn; fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8); }
void iFEiipu(x64emu_t *emu, uintptr_t fcn) { iFEiipu_t fn = (iFEiipu_t)fcn; R_RAX=(uint32_t)fn(emu, (int32_t)R_RDI, (int32_t)R_RSI, (void*)R_RDX, (uint32_t)R_RCX); }
void iFEiipp(x64emu_t *emu, uintptr_t fcn) { iFEiipp_t fn = (iFEiipp_t)fcn; R_RAX=(uint32_t)fn(emu, (int32_t)R_RDI, (int32_t)R_RSI, (void*)R_RDX, (void*)R_RCX); }
void iFEiipV(x64emu_t *emu, uintptr_t fcn) { iFEiipV_t fn = (iFEiipV_t)fcn; R_RAX=(uint32_t)fn(emu, (int32_t)R_RDI, (int32_t)R_RSI, (void*)R_RDX, (void*)(R_RSP + 8)); }
void iFEiipA(x64emu_t *emu, uintptr_t fcn) { iFEiipA_t fn = (iFEiipA_t)fcn; R_RAX=(uint32_t)fn(emu, (int32_t)R_RDI, (int32_t)R_RSI, (void*)R_RDX, (void*)R_RCX); }
Expand Down
2 changes: 2 additions & 0 deletions src/wrapped/generated/wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@ void vFSpL(x64emu_t *emu, uintptr_t fnc);
void cFpdp(x64emu_t *emu, uintptr_t fnc);
void wFppp(x64emu_t *emu, uintptr_t fnc);
void iFEiw(x64emu_t *emu, uintptr_t fnc);
void iFEiu(x64emu_t *emu, uintptr_t fnc);
void iFEip(x64emu_t *emu, uintptr_t fnc);
void iFEWW(x64emu_t *emu, uintptr_t fnc);
void iFEup(x64emu_t *emu, uintptr_t fnc);
Expand Down Expand Up @@ -1820,6 +1821,7 @@ void vFppppi(x64emu_t *emu, uintptr_t fnc);
void vFppppu(x64emu_t *emu, uintptr_t fnc);
void vFppppL(x64emu_t *emu, uintptr_t fnc);
void vFppppp(x64emu_t *emu, uintptr_t fnc);
void iFEiipu(x64emu_t *emu, uintptr_t fnc);
void iFEiipp(x64emu_t *emu, uintptr_t fnc);
void iFEiipV(x64emu_t *emu, uintptr_t fnc);
void iFEiipA(x64emu_t *emu, uintptr_t fnc);
Expand Down
72 changes: 66 additions & 6 deletions src/wrapped/wrappedlibc.c
Original file line number Diff line number Diff line change
Expand Up @@ -3953,6 +3953,42 @@ EXPORT int my_prctl(x64emu_t* emu, int option, unsigned long arg2, unsigned long
return prctl(option, arg2, arg3, arg4, arg5);
}

EXPORT int my_pidfd_open(x64emu_t* emu, int pid, unsigned int flags)
{
(void)emu;
#if defined(SYS_pidfd_open)
return syscall(SYS_pidfd_open, pid, flags);
#elif defined(__NR_pidfd_open)
return syscall(__NR_pidfd_open, pid, flags);
#else
(void)pid;
(void)flags;
errno = ENOSYS;
return -1;
#endif
}

EXPORT int my_pidfd_send_signal(x64emu_t* emu, int pidfd, int sig, siginfo_t* info, unsigned int flags)
{
(void)emu;
int hsig = signal_from_x64(sig);
siginfo_t hinfo;
siginfo_t* hptr = NULL;
if(info) {
memcpy(&hinfo, info, sizeof(hinfo));
hinfo.si_signo = hsig;
hptr = &hinfo;
}
#if defined(SYS_pidfd_send_signal)
return syscall(SYS_pidfd_send_signal, pidfd, hsig, hptr, flags);
#elif defined(__NR_pidfd_send_signal)
return syscall(__NR_pidfd_send_signal, pidfd, hsig, hptr, flags);
#else
errno = ENOSYS;
return -1;
#endif
}

size_t __attribute__((weak)) strlcpy(char* dest, const char* src, size_t len)
{
size_t l = strlen(src);
Expand All @@ -3968,6 +4004,36 @@ size_t __attribute__((weak)) __strlcpy_chk(char* dest, const char* src, size_t l
return strlcpy(dest, src, len);
}

uint32_t get_random32();
__attribute__((weak)) uint32_t arc4random(void)
{
return get_random32();
}

__attribute__((weak)) const char* strerrorname_np(int errnum)
{
(void)errnum;
return NULL;
}

__attribute__((weak)) int open_tree(int dfd, const char* path, unsigned int flags)
{
#ifdef SYS_open_tree
return syscall(SYS_open_tree, dfd, path, flags);
#else
errno = ENOSYS;
return -1;
#endif
}

__attribute__((weak)) int dn_skipname(const unsigned char* ptr, const unsigned char* eom)
{
(void)ptr;
(void)eom;
errno = ENOSYS;
return -1;
}

#ifndef _SC_NPROCESSORS_ONLN
#define _SC_NPROCESSORS_ONLN 84
#endif
Expand Down Expand Up @@ -4000,12 +4066,6 @@ EXPORT char* secure_getenv(const char* name)
return getenv(name);
}

uint32_t get_random32();
__attribute__((weak)) uint32_t arc4random(void)
{
return get_random32();
}

#ifdef STATICBUILD
#include "libtools/static_libc.h"
#endif
Expand Down
7 changes: 6 additions & 1 deletion src/wrapped/wrappedlibc_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ GO(_dl_mcount_wrapper_check, vFp)
//GO(_dl_sym,
//GO(_dl_vsym,
GOW(dngettext, pFpppL)
GOW(dn_skipname, iFpp)
GOM(dprintf, iFEipV)
GOM(__dprintf_chk, iFEiipV)
GO(drand48, dFv)
Expand Down Expand Up @@ -1436,6 +1437,7 @@ GO(__openat_2, iFipO)
GOW(openat64, iFipON)
GO(__openat64_2, iFipO)
GO(open_by_handle_at, iFipi)
GOW(open_tree, iFipu)
//GO(__open_catalog,
GOW(opendir, pFp)
GO(openlog, vFpii)
Expand All @@ -1459,6 +1461,8 @@ GOW(pause, iFv)
GO(pclose, iFS)
GO(perror, vFp)
GOW(personality, iFL)
GOM(pidfd_open, iFEiu)
GOM(pidfd_send_signal, iFEiipu)
GO(__pipe, iFp)
GOW(pipe, iFp)
GO(pipe2, iFpO)
Expand Down Expand Up @@ -1963,6 +1967,7 @@ GO(strcspn, LFpp)
GO(__strdup, pFp)
GOW(strdup, pFp)
GO(strerror, pFi)
GOW(strerrorname_np, pFi)
GO(strerror_l, pFip)
GO(__strerror_r, pFipL)
GO(strerror_r, pFipL)
Expand Down Expand Up @@ -2696,4 +2701,4 @@ GO(dummy_pFpLLp, pFpLLp)
//GO(dummy_pFpLLp, pFpLLp)
#endif

GO(arc4random, uFv)
GO(arc4random, uFv)
5 changes: 5 additions & 0 deletions src/wrapped/wrappedlibssl3_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ GO(SRP_Calc_A_param, iFp)
//GO(ssl3_write_bytes,
//GO(ssl3_write_pending,
GO(SSL_accept, iFp)
GOW(SSL_CTX_load_verify_file, iFpp)
GOW(SSL_has_pending, iFp)
GOW(SSL_set0_rbio, vFpp)
GOW(SSL_set0_wbio, vFpp)
GOW(SSL_set1_host, iFpp)
//GO(ssl_add_cert_chain,
GO(SSL_add_client_CA, iFpp)
//GO(ssl_add_clienthello_renegotiate_ext,
Expand Down
5 changes: 5 additions & 0 deletions src/wrapped/wrappedlibssl_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,11 @@ GO(OPENSSL_init_ssl, iFUp)
//GO(ssl3_write_bytes,
//GO(ssl3_write_pending,
GO(SSL_accept, iFp)
GOW(SSL_CTX_load_verify_file, iFpp)
GOW(SSL_has_pending, iFp)
GOW(SSL_set0_rbio, vFpp)
GOW(SSL_set0_wbio, vFpp)
GOW(SSL_set1_host, iFpp)
//GO(ssl_add_cert_chain,
GO(SSL_add_client_CA, iFpp)
//GO(ssl_add_clienthello_renegotiate_ext,
Expand Down
4 changes: 2 additions & 2 deletions src/wrapped/wrappedselinux_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
//GO(context_user_get,
//GO(context_user_set,
//DATAB(dir_xattr_list,
//GO(fgetfilecon,
GO(fgetfilecon, iFip)
GO(fgetfilecon_raw, iFip)
//GO(fini_selinuxmnt,
GO(freecon, vFp)
Expand All @@ -56,7 +56,7 @@ GO(fsetfilecon_raw, iFip)
//GO(get_default_type,
//GO(getexeccon,
//GO(getexeccon_raw,
//GO(getfilecon,
GO(getfilecon, iFpp)
GO(getfilecon_raw, iFpp)
//GO(getfscreatecon,
//GO(getfscreatecon_raw,
Expand Down
Loading