Bug 1456686

Summary: Use after free bug in parse_imagepath is crashing tcmu-runner
Product: [Red Hat Storage] Red Hat Gluster Storage Reporter: Pranith Kumar K <pkarampu>
Component: tcmu-runnerAssignee: Pranith Kumar K <pkarampu>
Status: CLOSED ERRATA QA Contact: Sweta Anandpara <sanandpa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rhgs-3.3CC: pkarampu, prasanna.kalever, rhs-bugs, sanandpa, storage-qa-internal
Target Milestone: ---   
Target Release: RHGS 3.3.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: tcmu-runner-1.2.0-4.el7rhgs Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-09-21 04:19:33 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1417151    

Description Pranith Kumar K 2017-05-30 07:34:54 UTC
Description of problem:
    This is the asan trace:
    ==1482==ERROR: AddressSanitizer: heap-use-after-free on address 0x60300000db70 at pc 0x7ffff0bfb93f bp 0x7fffffffc830 sp 0x7fffffffc820
    READ of size 8 at 0x60300000db70 thread T0
        #0 0x7ffff0bfb93e in gluster_free_server /root/tcmu-runner/glfs.c:270
        #1 0x7ffff0bfc851 in tcmu_create_glfs_object /root/tcmu-runner/glfs.c:415
        #2 0x7ffff0bfcda3 in tcmu_glfs_open /root/tcmu-runner/glfs.c:503
        #3 0x417ced in dev_added /root/tcmu-runner/main.c:678
        #4 0x7ffff6c12662 in add_device /root/tcmu-runner/libtcmu.c:296
        #5 0x7ffff6c13503 in open_devices /root/tcmu-runner/libtcmu.c:436
        #6 0x7ffff6c13c62 in tcmulib_initialize /root/tcmu-runner/libtcmu.c:477
        #7 0x418720 in main /root/tcmu-runner/main.c:871
        #8 0x7ffff5500400 in __libc_start_main (/lib64/libc.so.6+0x20400)
        #9 0x407dd9 in _start (/root/tcmu-runner/tcmu-runner+0x407dd9)
    
    0x60300000db70 is located 0 bytes inside of 24-byte region [0x60300000db70,0x60300000db88)
    freed by thread T0 here:
        #0 0x7ffff6efbb00 in free (/lib64/libasan.so.3+0xc6b00)
        #1 0x7ffff0bfbaa8 in gluster_free_server /root/tcmu-runner/glfs.c:276
        #2 0x7ffff0bfc336 in parse_imagepath /root/tcmu-runner/glfs.c:347
        #3 0x7ffff0bfc464 in tcmu_create_glfs_object /root/tcmu-runner/glfs.c:360
        #4 0x7ffff0bfcda3 in tcmu_glfs_open /root/tcmu-runner/glfs.c:503
        #5 0x417ced in dev_added /root/tcmu-runner/main.c:678
        #6 0x7ffff6c12662 in add_device /root/tcmu-runner/libtcmu.c:296
        #7 0x7ffff6c13503 in open_devices /root/tcmu-runner/libtcmu.c:436
        #8 0x7ffff6c13c62 in tcmulib_initialize /root/tcmu-runner/libtcmu.c:477
        #9 0x418720 in main /root/tcmu-runner/main.c:871
        #10 0x7ffff5500400 in __libc_start_main (/lib64/libc.so.6+0x20400)
    
    previously allocated by thread T0 here:
        #0 0x7ffff6efc020 in calloc (/lib64/libasan.so.3+0xc7020)
        #1 0x7ffff0bfbbe5 in parse_imagepath /root/tcmu-runner/glfs.c:299
        #2 0x7ffff0bfc464 in tcmu_create_glfs_object /root/tcmu-runner/glfs.c:360
        #3 0x7ffff0bfcda3 in tcmu_glfs_open /root/tcmu-runner/glfs.c:503
        #4 0x417ced in dev_added /root/tcmu-runner/main.c:678
        #5 0x7ffff6c12662 in add_device /root/tcmu-runner/libtcmu.c:296
        #6 0x7ffff6c13503 in open_devices /root/tcmu-runner/libtcmu.c:436
        #7 0x7ffff6c13c62 in tcmulib_initialize /root/tcmu-runner/libtcmu.c:477
        #8 0x418720 in main /root/tcmu-runner/main.c:871
        #9 0x7ffff5500400 in __libc_start_main (/lib64/libc.so.6+0x20400)


Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 2 Pranith Kumar K 2017-05-30 07:37:16 UTC
https://github.com/open-iscsi/tcmu-runner/pull/167

Comment 8 Sweta Anandpara 2017-07-17 11:09:28 UTC
A round of testing has taken place on glusterfs-3.8.4-33 and gluster-block-0.2.1-6. I do not see any crashes or something unexpected in gluster-block logs. 

Based on comment7 - developer's inputs as well as release leads' agreement, moving this bug to (conditionally) verified.

Comment 11 errata-xmlrpc 2017-09-21 04:19:33 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2017:2773