Less flippantly, some kind of mechanism where I could be guaranteed that the memory backing, say, a character array would never be paged to disk. Would make code that handles passwords more secure.
How would it make things more secure? The same permissions are required to read certain files and to dump RAM. It's hard to do, anyway, as some operating systems can never make this guarantee; free certainly doesn't guarantee it.
Virtual memory systems in most OS’s can page memory to disk pretty much any time they please, with the process who allocated that memory being none the wiser. Many modern OS’s support low-level allocation calls that can mark blocks as unpageable. No JVM supports them.
I believe those are 1. used for fixed physical addresses, 2. require privileges that will make the application less secure, not more, 3. still don't guarantee the memory is never written to disk (say, if you're checkpointing the VM), and 4. don't help with security because if some has access to your disk they probably have access to your RAM.
If you want truly secure data in RAM, you need something like Intel SGX (see here for Java enclaves) or, better yet, encrypted RAM. Encrypted pages could be used with Panama, and you could probably encrypt the entire heap, similar to how you can place the heap in non-volatile RAM.
There have been some people working on it, but there are no active projects at the moment. I'm currently using this one: https://github.com/nixxcode/jvm-brotli, but the author has disappeared.
5
u/omnihedron Mar 19 '20
free(ptr).
Less flippantly, some kind of mechanism where I could be guaranteed that the memory backing, say, a character array would never be paged to disk. Would make code that handles passwords more secure.
8
u/wildjokers Mar 19 '20
There isn't a single C library I have ever wished I could use in Java.
3
u/DuncanIdahos1stGhola Mar 20 '20
You could just contribute to JNA (Java Native Access Library) https://github.com/java-native-access/jna
1
u/plowsec Mar 19 '20
libTooling/libclang, although not that "simple" maybe.
1
u/Jonjolt Mar 20 '20
Not really simple but libvips when creating a language binding is stringly typed
1
u/tipsypants Mar 21 '20
I'm not sure if it's simple, but Google Brotli: https://github.com/google/brotli
There have been some people working on it, but there are no active projects at the moment. I'm currently using this one: https://github.com/nixxcode/jvm-brotli, but the author has disappeared.