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

cleanup rework of trustme leftovers #520

Merged
merged 8 commits into from
Jan 31, 2025
Merged

cleanup rework of trustme leftovers #520

merged 8 commits into from
Jan 31, 2025

Conversation

quitschbo
Copy link
Member

Current rework of gyroidos reositries replaced all legacy variable nameing thus we have to take this into account here, too. We replace the build variable TRUSTME_SCHSM by SCHSM.

While destroying a container, a use-after-free occurred, since
the used observer callback in cmld.c frees the container and
therefore also the compartment before all other registered observers
where called.

Similarly to the container reload, we now use the observer finish
callback to do a delayed free after all compartments observer
callbacks have been run.

This fixes asan error:

=================================================================
==203==ERROR: AddressSanitizer: heap-use-after-free on address \
 0x511000000838 at pc 0x557253082656 bp 0x7ffe4cfee190 sp 0x7ffe4cfee180
READ of size 8 at 0x511000000838 thread T0
    #0 0x557253082655 in compartment_notify_observers daemon/compartment.c:1681
    gyroidos#1 0x557253088149 in compartment_sigchld_handle_helpers daemon/compartment.c:705
    gyroidos#2 0x5572530886c9 in compartment_sigchld_cb daemon/compartment.c:787
    gyroidos#3 0x55725312e759 in event_signal_handler common/event.c:780
    gyroidos#4 0x55725312e759 in event_loop common/event.c:851
    gyroidos#5 0x5572530666ac in main daemon/main.c:146
    gyroidos#6 0x7ff708bd5863 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    gyroidos#7 0x7ff708bd590a in __libc_start_main_impl ../csu/libc-start.c:389
    gyroidos#8 0x5572530689d4 in _start (/usr/sbin/cmld+0x13e9d4)

Signed-off-by: Michael Weiß <[email protected]>
Move event_remove_inoftify of watching dev dir from stop to cleanup hook.
This avoids following use-after-free:

=================================================================
==202==ERROR: AddressSanitizer: heap-use-after-free on address \
 0x504000001fec at pc 0x5577ecae15da bp 0x7ffec417cda0 sp 0x7ffec417cd90
READ of size 4 at 0x504000001fec thread T0
    #0 0x5577ecae15d9 in event_remove_inotify common/event.c:658
    gyroidos#1 0x5577ecad2ba6 in c_automount_stop daemon/c_automount.c:251
    gyroidos#2 0x5577eca4442e in compartment_stop daemon/compartment.c:1573
    gyroidos#3 0x5577eca1d1b5 in cmld_container_stop daemon/cmld.c:1695
    gyroidos#4 0x5577eca49771 in control_handle_message daemon/control.c:1170
    gyroidos#5 0x5577eca50fb9 in control_cb_recv_message_local daemon/control.c:1679
    gyroidos#6 0x5577ecaddc3d in event_epoll common/event.c:437
    gyroidos#7 0x5577ecae2e13 in event_loop common/event.c:854
    gyroidos#8 0x5577eca1a6ac in main daemon/main.c:146
    gyroidos#9 0x7f2cab14f863 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    gyroidos#10 0x7f2cab14f90a in __libc_start_main_impl ../csu/libc-start.c:389
    gyroidos#11 0x5577eca1c9d4 in _start (/usr/sbin/cmld+0x13e9d4)

Signed-off-by: Michael Weiß <[email protected]>
Current rework of gyroidos reositries replaced all legacy
variable nameing thus we have to take this into account here, too.
We replace the build variable TRUSTME_SCHSM by SCHSM.

Signed-off-by: Michael Weiß <[email protected]>
Removed all code blocks in 'ifdef ANDROID' blocks.

Signed-off-by: Michael Weiß <[email protected]>
@quitschbo quitschbo marked this pull request as ready for review January 31, 2025 08:16
Renamed the corresponding string which is used for logging update
messages to print GyroidOS instead of Trustme.

Signed-off-by: Michael Weiß <[email protected]>
Instead of TrustmeService reference the generic service in comments
and log messages.

Signed-off-by: Michael Weiß <[email protected]>
This TRUSTME_DEBUG flag is only used to prevent reboot on cmld exit
in debug builds. So just call it NO_REBOOT_ON_EXIT to make things
clear.

Signed-off-by: Michael Weiß <[email protected]>
@quitschbo quitschbo changed the title scd/Makefile: Renamed build variable TRUSTME_SCHSM to SCHSM cleanup rework of trustme leftovers Jan 31, 2025
We generate a test PKI for unittests. Thus also use 'unittest' as
commonName for those certificates to identify that these are used
in unittests.

Signed-off-by: Michael Weiß <[email protected]>
@k0ch4lo k0ch4lo merged commit de8f572 into gyroidos:main Jan 31, 2025
2 checks passed
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.

2 participants