|
| 1 | +[[executable-jna-tmpdir]] |
| 2 | +=== JNA temporary directory not mounted with `noexec` |
| 3 | + |
| 4 | +[NOTE] |
| 5 | +This is only relevant for Linux. |
| 6 | + |
| 7 | +Elasticsearch uses the Java Native Access (JNA) library for executing some |
| 8 | +platform-dependent native code. On Linux, the native code backing this library |
| 9 | +is extracted at runtime from the JNA archive. By default, this code is extracted |
| 10 | +to the Elasticsearch temporary directory which defaults to a sub-directory of |
| 11 | +`/tmp`. Alternatively, this location can be controlled with the JVM flag |
| 12 | +`-Djna.tmpdir=<path>`. As the native library is mapped into the JVM virtual |
| 13 | +address space as executable, the underlying mount point of the location that |
| 14 | +this code is extracted to must *not* be mounted with `noexec` as this prevents |
| 15 | +the JVM process from being able to map this code as executable. On some hardened |
| 16 | +Linux installations this is a default mount option for `/tmp`. One indication |
| 17 | +that the underlying mount is mounted with `noexec` is that at startup JNA will |
| 18 | +fail to load with a `java.lang.UnsatisfiedLinkerError` exception with a message |
| 19 | +along the lines of `failed to map segment from shared object`. Note that the |
| 20 | +exception message can differ amongst JVM versions. Additionally, the components |
| 21 | +of Elasticsearch that rely on execution of native code via JNA will fail with |
| 22 | +messages indicating that it is `because JNA is not available`. If you are seeing |
| 23 | +such error messages, you must remount the temporary directory used for JNA to |
| 24 | +not be mounted with `noexec`. |
0 commit comments