Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libsys: Add CHERI_LIB_C18N to CFLAGS when appropriate #2217

Merged
merged 2 commits into from
Sep 9, 2024
Merged

Conversation

dpgao
Copy link
Contributor

@dpgao dpgao commented Sep 5, 2024

No description provided.

@bsdjhb
Copy link
Collaborator

bsdjhb commented Sep 5, 2024

Hmm, looks like the multi-threaded cheribsdtest binaries using c18n failed tests (or maybe crashed without running any tests?)

@jrtc27
Copy link
Member

jrtc27 commented Sep 5, 2024

Both ABIs crashed with SIGTRAP in the parent

@dpgao
Copy link
Contributor Author

dpgao commented Sep 6, 2024

Looks like the elf_aux_info stub in libsys is being called.

(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /bin/cheribsdtest-mt-c18n

Program received signal SIGTRAP, Trace/breakpoint trap.
Breakpoint.
elf_aux_info () at /Volumes/Personal/cheri/cheribsd/lib/libsys/libc_stubs.c:11
(gdb) bt
#0  elf_aux_info () at /Volumes/Personal/cheri/cheribsd/lib/libsys/libc_stubs.c:11
#1  0x000000004038bfc0 in _thr_signal_block_check_fast () at /Volumes/Personal/cheri/cheribsd/lib/libthr/thread/thr_sig.c:167
Backtrace stopped: previous frame inner to this frame (corrupt stack?)

@jrtc27
Copy link
Member

jrtc27 commented Sep 6, 2024

Why is elf_aux_info a stub? How is that ever meant to work? There's useful information in there...

@jrtc27
Copy link
Member

jrtc27 commented Sep 6, 2024

Oh I see, it's meant to be filtered such that you get the non-trapping version at run time. So why isn't libsys's definition being used here? It works for non-c18n.

@dpgao
Copy link
Contributor Author

dpgao commented Sep 8, 2024

ktrace shows

 39137 cheribsdtest-mt-c18 USER  RTLD: error: /usr/lib/c18n/libsys.so.7: Undefined symbol "sigaction_c18n"
 39137 cheribsdtest-mt-c18 USER  RTLD: error: /usr/lib/c18n/libsys.so.7: Could not find symbol sigaction_c18n

which causes the filtee to not be loaded. sigaction_c18n should probably be moved to libsys?

@dpgao
Copy link
Contributor Author

dpgao commented Sep 8, 2024

I removed sigaction_c18n altogether and makes libsys's interpose table directly refer to RTLD's hook (_rtld_sigaction).

Copy link
Collaborator

@bsdjhb bsdjhb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just drop the first commit and only have the second commit that "fixes" c18n libsys?

Previously, -DCHERI_LIB_C18N was omitted for libsys. This commit also
fixes that.
Previously, lib/c18n/libsys's sigaction calls a libc function which in
turn calls the RTLD hook. This is broken but was undetected because c18n
was accidentally always disabled in the c18n-version of libsys.
@bsdjhb bsdjhb merged commit 3c65ee7 into dev Sep 9, 2024
29 checks passed
@bsdjhb bsdjhb deleted the libsys-c18n branch September 9, 2024 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants