-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failed to allocate closure when SELinux is enabled and non-root user is used #1505
Comments
It is invalid to raise issues that are not confirmed. You think JNA is an issue here, but question should not be raised here, but on the mailinglist. I don't think, that the message in the issue template is that subtle. At least provide steps to reproduce, that can be ran without getting an AWS machine, I might then be interested in looking into this. |
I'm sorry for reporting this issue. I should have read the template more carefully. Feel free to close and I will use the mailinglist instead. Anyway, I found out that the error occurs if a non-root user doesn't have write access to his home directory. The native library was loaded sucessfully, after I granted write access to home. Can you confirm that JNA requires write access to the user's home under certain conditions? If so, what are those conditions? I would propose to add a new section to the FAQ such as Calling Native.registerMethod() causes an UnsupportedOperationException: Failed to allocate closure. I'm sorry that I can't provide steps to reproduce. The machine where the error occured has some hardened Amazon Linux 2 and I didn't gather enough details about it yet. |
Yes - this commit introduces the behavior: before that
It is required, if you don't manually install the native library somewhere accessible on the filesystem and tell JNA to use that. Be warned: the version of the native library and the JNA library must match, if that is not the case, bad things will happen.
As described above, I think it is an unlikely situation. |
I ran a few more tests and these are the results:
I still didn't get enough details about the hardening that was done on the target machine, so that I can't say what's the cause of the error. Regarding the readonly home, I think it isn't so unlikely in server environments where access is restricted for security reasons. Moreover, it seems that JNA doesn't require writeable home under certain conditions. I'm wondering what these conditions are exactly. |
If |
There are a handful of unlikely situations, including this and other access issues, app restrictions (e.g. Apple App store) that require signed binaries, and JDK bugs like #1506, all of which can be worked around by pre-extracting or locally building the native library. Of note, Loading JNA is the first section of the overview which addresses how to do this. There's probably room for a more generic hand-wavy link to that section in the FAQ with a mention of "permissions". I can try to add something if you agree. |
Yes, if java.io.tmpdir is mounted noexec loading will fail, but with a different error, for example However, I think that in my case, the native library was loaded ( |
@rqpb I'm happy to try to fix the documentation if you think it's complete, but I'd like a little more detail on where you think it should be improved. The first section of the overview seems to solve most issues associated with the "tmpdir" and I think it's reasonable to add a Q&A in the FAQ pointing there. Can you suggest what the content should say? |
JNA fails to load a native library if SELinux is enabled and I run my code as a non-root user. I tested with Lazysodium for Java, but I don't think that this issue is specific to this particular library only.
Changing the SELinux mode to the permissive doesn't help and there is no record in /var/log/audit/audit.log.
If I run my code as root, the error won't occur. If I disable SELinux and I run my code as a non-root, the error won't occur either.
OS: Amazon Linux 2
System architecture: x86_64
Java: OpenJDK Runtime Environment (build 1.8.0_352-b08)
JNA version: 5.13.0
Stacktrace
Steps to reproduce:
Dependencies:
The text was updated successfully, but these errors were encountered: