Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

[Pal/lib] mbedTLS crypto adapter calls _DkRandomBitsRead() but is also linked into LibOS #2371

Open
dimakuv opened this issue May 12, 2021 · 0 comments

Comments

@dimakuv
Copy link

dimakuv commented May 12, 2021

Description of the problem

We have the "common library" that has a bunch of Standard C and utility functions. This library is a static archive called graphene-lib.a and is linked into both PAL binaries and the LibOS binary (libsysdb.so).

This "common library" includes the crypto code. In particular, it includes the minimal mbedTLS code and our Graphene convenience wrappers around it. These wrappers define and call _DkRandomBitsRead() as a callback to initialize the mbedTLS software PRNG.

But this is wrong from a design point of view: LibOS links against the common library and sees the calls to _DkRandomBitsRead(), which is an internal function of the PAL layer and should never be visible to LibOS. Fortunately, LibOS will not reference/use _DkRandomBitsRead() because this function is only called from mbedTLS wrappers. LibOS doesn't use these wrappers (in particular, the file mbedtls_adapter.o). So during the final linking step, when LibOS sources are linked against static graphene-lib.a, the linker notices that mbedTLS wrappers are not used and removes all that stuff. So in the end, the libsysdb.so library doesn't have any references to _DkRandomBitsRead().

I verified it by manually inspecting the symbols and relocations in the resulting libraries.

This is a pretty bad design decision though and should be fixed somehow.

This was found while working on #2367 .

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant