Skip to content

Commit

Permalink
c18n: Override libsys's sigaction to directly call RTLD hook
Browse files Browse the repository at this point in the history
Previously libsys's sigaction calls a libc function which in turn calls
the RTLD hook. This is broken but was undetected because c18n was
accidentally not enabled in the c18n-version of libsys.
  • Loading branch information
dpgao committed Sep 8, 2024
1 parent a86c9e4 commit 1c7bcdf
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 15 deletions.
2 changes: 1 addition & 1 deletion lib/libc/include/libc_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ int __strerror_rl(int errnum, char *strerrbuf, size_t buflen,

#ifdef CHERI_LIB_C18N
__pid_t __sys_rfork(int);
int sigaction_c18n(int, const struct sigaction *, struct sigaction *);
int _rtld_sigaction(int, const struct sigaction *, struct sigaction *);
#endif

#endif /* _LIBC_PRIVATE_H_ */
13 changes: 0 additions & 13 deletions lib/libc/sys/sigaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,6 @@

__weak_reference(__sys_sigaction, __sigaction);
__weak_reference(sigaction, __libc_sigaction);
#ifdef CHERI_LIB_C18N
/*
* This weak symbol will always be resolved at runtime.
*/
#pragma weak _rtld_sigaction
int _rtld_sigaction(int, const struct sigaction *, struct sigaction *);

int
sigaction_c18n(int sig, const struct sigaction *act, struct sigaction *oact)
{
return (_rtld_sigaction(sig, act, oact));
}
#endif

#pragma weak sigaction
int
Expand Down
2 changes: 1 addition & 1 deletion lib/libsys/interposing_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ static interpos_func_t __libsys_interposing[INTERPOS_MAX] = {
SLOT(sendto, __sys_sendto),
SLOT(setcontext, __sys_setcontext),
#ifdef CHERI_LIB_C18N
SLOT(sigaction, sigaction_c18n),
SLOT(sigaction, _rtld_sigaction),
#else
SLOT(sigaction, __sys_sigaction),
#endif
Expand Down

0 comments on commit 1c7bcdf

Please sign in to comment.