- 
    Bug 
- 
    Resolution: Fixed
- 
     P4 P4
- 
    11, 12, 13
- 
        b19
- 
        x86
- 
        linux
| Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build | 
|---|---|---|---|---|---|---|
| JDK-8228935 | 12u-cpu | Severin Gehwolf | P4 | Resolved | Fixed | master | 
| JDK-8223257 | 12.0.2 | Severin Gehwolf | P4 | Resolved | Fixed | b03 | 
| JDK-8223479 | 11.0.4 | Severin Gehwolf | P4 | Resolved | Fixed | b02 | 
                    On line 868 of src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp the code reads:
char* hint = (char*)(Linux::initial_thread_stack_bottom() -
(JavaThread::stack_guard_zone_size() + page_size));
char* codebuf = os::attempt_reserve_memory_at(page_size, hint);
This relies on Linux::initial_thread_stack_bottom() returning non-NULL (unconditionally). However Linux::initial_thread_stack_bottom() is only initialized in Linux::capture_initial_stack() when NOT being launched via a java launcher postJDK-8199717. This results in pointer arithmetic wrapping around, which is undefined behavior.
With an instrumented JVM one can notice this runtime error:
src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp:884:73: runtime error: pointer index expression with base 0x00000000 overflowed to 0xffffb000
And indeed, when running with -Xlog:os=info on x32 Linux we see this:
bin/java -Xlog:os=info -version 2>&1 | grep 'CS limit NX'
[0.002s][info][os] [CS limit NX emulation work-around, exec code at: 0xffffb000]
bin/java -Xlog:os=info -version 2>&1 | grep 'CS limit NX'
[0.002s][info][os] [CS limit NX emulation work-around, exec code at: 0xffffb000]
bin/java -Xlog:os=info -version 2>&1 | grep 'CS limit NX'
[0.002s][info][os] [CS limit NX emulation work-around, exec code at: 0xffffb000]
On JDK 8u this looks like:
$ java -XX:+PrintMiscellaneous -XX:+Verbose -version 2>&1 | grep 'CS limit NX'
[CS limit NX emulation work-around, exec code at: 0xffb21000]
$ java -XX:+PrintMiscellaneous -XX:+Verbose -version 2>&1 | grep 'CS limit NX'
[CS limit NX emulation work-around, exec code at: 0xff76d000]
$ java -XX:+PrintMiscellaneous -XX:+Verbose -version 2>&1 | grep 'CS limit NX'
[CS limit NX emulation work-around, exec code at: 0xff95e000]
char* hint = (char*)(Linux::initial_thread_stack_bottom() -
(JavaThread::stack_guard_zone_size() + page_size));
char* codebuf = os::attempt_reserve_memory_at(page_size, hint);
This relies on Linux::initial_thread_stack_bottom() returning non-NULL (unconditionally). However Linux::initial_thread_stack_bottom() is only initialized in Linux::capture_initial_stack() when NOT being launched via a java launcher post
With an instrumented JVM one can notice this runtime error:
src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp:884:73: runtime error: pointer index expression with base 0x00000000 overflowed to 0xffffb000
And indeed, when running with -Xlog:os=info on x32 Linux we see this:
bin/java -Xlog:os=info -version 2>&1 | grep 'CS limit NX'
[0.002s][info][os] [CS limit NX emulation work-around, exec code at: 0xffffb000]
bin/java -Xlog:os=info -version 2>&1 | grep 'CS limit NX'
[0.002s][info][os] [CS limit NX emulation work-around, exec code at: 0xffffb000]
bin/java -Xlog:os=info -version 2>&1 | grep 'CS limit NX'
[0.002s][info][os] [CS limit NX emulation work-around, exec code at: 0xffffb000]
On JDK 8u this looks like:
$ java -XX:+PrintMiscellaneous -XX:+Verbose -version 2>&1 | grep 'CS limit NX'
[CS limit NX emulation work-around, exec code at: 0xffb21000]
$ java -XX:+PrintMiscellaneous -XX:+Verbose -version 2>&1 | grep 'CS limit NX'
[CS limit NX emulation work-around, exec code at: 0xff76d000]
$ java -XX:+PrintMiscellaneous -XX:+Verbose -version 2>&1 | grep 'CS limit NX'
[CS limit NX emulation work-around, exec code at: 0xff95e000]
- backported by
- 
                    JDK-8223257 [i386] expand_exec_shield_cs_limit workaround is undefined code after JDK-8199717 -           
- Resolved
 
-         
- 
                    JDK-8223479 [i386] expand_exec_shield_cs_limit workaround is undefined code after JDK-8199717 -           
- Resolved
 
-         
- 
                    JDK-8228935 [i386] expand_exec_shield_cs_limit workaround is undefined code after JDK-8199717 -           
- Resolved
 
-         
- relates to
- 
                    JDK-8199717 Avoid calculating primordial thread stack bounds on VM startup -           
- Resolved
 
-