Such a weird flex and weird take. Tries to make C# look bad by linking to something entirely unrelated: inline assemblies which a C/C++ MSVC specific feature and only supported on x86 (which is being phased out in . NET).
Do you need to enable it for dependencies too? Like if you don't have <AllowUnsafeBlocks>true</AllowUnsafeBlocks> you know no dependencies are using unsafe code?
And yep, my bad. Replacing it with a more appropriate link.
You need it if you call directly API that are marked unsafe. Note that the new model makes it more explicit so even with dependencies you will likely need it more often.
That doesn't make C# unsafe or dangerous. Rust use a similar contract where unsafe code can be wrapped by safe code and code calling the safe version isn't considered unsafe.
Okay but there are still dependencies where the unsafe-ness is something you don't know about unless you read their code?
Like is this a new thing for "directional" safety? And yeah rust does something similar. But people do end up accepting unsafe if it "feels audited" or "feels neccesary." I didn't touch on Rust because I feel like all these -5s on my comments would be -50s if those folks get awakened, but it is a similar criticism
I mean, the way rust does "unsafe" is the right trade off for that type of language. I dont agree with that people just end up accepting unsafe as being audited
That's a lot of words to say --enable-native-access is a good security feature. OP isn't really wrong. Without it, you're vulnerable to MS07-052: Code execution leads to code execution.
Interesting that the JVM doesn't frame --enable-native-access as a security feature at all; it's an integrity feature. If you're running a malicious (or vulnerable) dependency, blocking native access isn't going to save you. See also: Java4Shell's namesake, Log4Shell.
Interesting that the JVM doesn't frame --enable-native-access as a security feature at all; it's an integrity feature.
Java has given up on achieving in-process security. Sandboxing is very hard to get right; as we have seen it is already hard enough to ensure memory safety. Thus, restricting 3rd party libraries from using FFI is not about security, but about ensuring that operations is aware that dependencies are doing something that might make code not run as initially intended by the developers, might dork up the JVM, or cause issues that are out of control of the JVM.
I think both --enable-native-access and --module-path are integrity features, but integrity features are security features. Here the issue is that native code mucks with the JVM's memory. Thats an issue for integrity that also lets people do RCE (allegedly).
The module system stuff is similar. Code in a library can't accidentally mess with the threading model since java.lang.Thread hides that stuff in the java.base module. Putting user code in modules also limits the scope of what a badly written library can do to that code.
Network and File System level security is mostly left up to Docker/OS controls though.
combined with JIT compilation can make the actual performance of a Java program competitive with C. Sometimes a Java program can even be faster. A JIT compiler knows what code paths are actually taken and can optimize around them. They can even refocus what is optimized if the workload changes. It is pretty cool!
Well, it’s so impressive that they had to write an assembly snippet by hand (at least, that’s what I gathered from the message). If the JVM is capable of such excellent optimization, why bother writing an assembly snippet?
Well, it’s so impressive that they had to write an assembly snippet by hand (at least, that’s what I gathered from the message). If the JVM is capable of such excellent optimization, why bother writing an assembly snippet?
Because the small print answer is -- everything you quoted is true, but it takes a surprisingly long time for the JIT to "get it" and spit out that "faster-than-C" answer. Long, as in it could take seconds or minutes even to get to that point.
For long running applications, this is usually fine. For short-running ones, not usually.
In the (rare) situation where the answer is obvious to humans but not the JIT, the OpenJDK team likes to hand-code assembly. That's basically what happened here.
15
u/BenchEmbarrassed7316 5h ago
What a nonsense.
tldr: A vulnerability was found in Java. Java isn't much slower than C++. So, use Java.
19
u/KryptosFR 5h ago
Such a weird flex and weird take. Tries to make C# look bad by linking to something entirely unrelated: inline assemblies which a C/C++ MSVC specific feature and only supported on x86 (which is being phased out in . NET).
The coping is hard on that one.
2
u/gredr 3h ago edited 3h ago
That's a lot of words to say
--enable-native-accessis a good security feature. OP isn't really wrong. Without it, you're vulnerable to MS07-052: Code execution leads to code execution.Interesting that the JVM doesn't frame
--enable-native-accessas a security feature at all; it's an integrity feature. If you're running a malicious (or vulnerable) dependency, blocking native access isn't going to save you. See also: Java4Shell's namesake, Log4Shell.2
u/New-Anybody-6206 5h ago
I ignore posts with a dogmatic title, because it's almost always hilariously misinformed. Tech people are IMO no exception to Dunning-Kruger.