Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8265757

stack-use-after-scope in perfMemory_posix.cpp get_user_name_slow()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 17
    • None
    • hotspot
    • None
    • b20

      Address Sanitizer detected the following when running serviceability/dcmd/framework/VMVersionTest.java:

       6339 ==3480302==ERROR: AddressSanitizer: stack-use-after-scope on address 0x7f7952e18480 at pc 0x7f795d0a141d bp 0x7f7952e18210 sp 0x7f7952e179b8
       6340 READ of size 23 at 0x7f7952e18480 thread T1
       6341 #0 0x7f795d0a141c (/lib/x86_64-linux-gnu/libasan.so.5+0x4f41c)
       6342 #1 0x7f7957687d3f in get_user_name_slow /home/jb/work/jbr-dev/src/hotspot/os/posix/perfMemory_posix.cpp:550
       6343 #2 0x7f795768cb31 in get_user_name_slow /home/jb/work/jbr-dev/src/hotspot/share/memory/resourceArea.hpp:99
       6344 #3 0x7f795768cb31 in get_user_name /home/jb/work/jbr-dev/src/hotspot/os/posix/perfMemory_posix.cpp:661
       6345 #4 0x7f795768cb31 in mmap_attach_shared /home/jb/work/jbr-dev/src/hotspot/os/posix/perfMemory_posix.cpp:1133
       6346 #5 0x7f795766c983 in Perf_Attach /home/jb/work/jbr-dev/src/hotspot/share/prims/perf.cpp:89
       6347 #6 0x7f793b111ba7 (<unknown module>)
       6348
       6349 Address 0x7f7952e18480 is located in stack of thread T1 at offset 496 in frame
       6350 #0 0x7f7957687b8f in get_user_name_slow /home/jb/work/jbr-dev/src/hotspot/os/posix/perfMemory_posix.cpp:514
       6351
       6352 This frame has 4 object(s):
       6353 [48, 56) 'remainder' (line 191)
       6354 [80, 224) 'statbuf' (line 603)
       6355 [288, 432) 'statbuf' (line 248)
       6356 [496, 4593) 'buffer' (line 540) <== Memory access at offset 496 is inside this variable


      The bug is in get_user_name_slow()(src/hotspot/os/posix/perfMemory_posix.cpp): on Linux, the 'buffer' array may be used after going out of scope.

            hseigel Harold Seigel (Inactive)
            vprovodin Vitaly Provodin
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: