google / mundane

Mundane is a Rust cryptography library backed by BoringSSL that is difficult to misuse, ergonomic, and performant (in that order).
MIT License
1.07k stars 49 forks source link

Test BoringSSL refcounting #14

Open joshlf opened 5 years ago

joshlf commented 5 years ago

Currently, we have a few small smoke tests to make sure that we don't decrement BoringSSL refcounts too far. However, we have no tests to ensure that we decrement refcounts far enough (in other words, that we don't leak resources by leaving unused objects allocated and constructed).

We should also test the latter. The way to do this is probably to figure out how to inspect the refcount on a BoringSSL object and use that mechanism to ensure that the refcount on these objects is 1 when we only hold a single reference. That said, perhaps there's a better way to do this.

EDIT: Let's first try to see if we can enable ASan (#15), which should address this.

davidben commented 5 years ago

ASan should be able to check both of these without reaching into BoringSSL's private structures (unsupported). If you over-decrement, ASan will report a UAF. If you under-decrement, ASan will report a leak.

joshlf commented 5 years ago

OK, I've opened #15 and I'll update the first comment to reference it.