immunant / IA2-Phase2

5 stars 0 forks source link

Make glibc stdio streams in main binary shared #450

Open ayrtonm opened 1 month ago

ayrtonm commented 1 month ago

When building tests that use the signal handler for CHECK_VIOLATION we call setbuf(stdout, NULL) to be able to make sense of printf output more easily when the signal handler is invoked. The problem is that the stdio streams defined by glibc show up in the main binary's .bss so this triggers a segfault when any other compartment tries to flush them (e.g. CI failures in #448).

$ nm tests/minimal/minimal | rg @GLIBC
...
0000000000083020 B stderr@GLIBC_2.2.5
0000000000083000 B stdout@GLIBC_2.2.5
                 U strchr@GLIBC_2.2.5
...

All other versioned glibc symbols show up undefined like strchr and nothing seems out of the ordinary in the stream definitions in glibc. I think the fix will be to move the streams to from the main binary's .bss to its .ia2_shared_data but I'm not sure how to best do that given that I'm missing something about how versioned symbols work.