Bug 1505325

Summary: Potential use of NULL `this` variable before it gets initialized
Product: [Community] GlusterFS Reporter: Kotresh HR <khiremat>
Component: changelogAssignee: Kotresh HR <khiremat>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: low Docs Contact:
Priority: unspecified    
Version: mainlineCC: alexc, avishwan, bugs
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: glusterfs-3.13.0 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1503405
: 1505856 (view as bug list) Environment:
Last Closed: 2017-12-08 17:44:30 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: 1503405    
Bug Blocks: 1505856    

Description Kotresh HR 2017-10-23 10:50:15 UTC
+++ This bug was initially created as a clone of Bug #1503405 +++

Description of problem:

Our code scanner has reported a potential null pointer dereference at xlators/features/changelog/lib/src/gf-history-changelog.c

        xlator_t                       *this                    = NULL;
    ........

        pthread_attr_t attr;

        ret = pthread_attr_init (&attr);
        if (ret != 0) {
                gf_msg (this->name, GF_LOG_ERROR, errno,    // <== `this` variable is still NULL at this time. 
                        CHANGELOG_LIB_MSG_PTHREAD_ERROR,
                        "Pthread init failed");
                return -1;
        }

        this = THIS;  // `this` variable gets assignment here, it was NULL before that
        if (!this) {
                ret = -1;
                goto out;
        }

according to the documentation of pthread_attr_init, the chance of its invocation failure is low, but once happened, the process will crash (the GEO replication syncdaemon seems using this function).

Regards,
Alex, SourceBrella Inc.

Comment 1 Worker Ant 2017-10-23 10:52:33 UTC
REVIEW: https://review.gluster.org/18553 (libgfchangelog: Fix possible null pointer dereference) posted (#1) for review on master by Kotresh HR (khiremat)

Comment 2 Worker Ant 2017-10-24 05:25:01 UTC
COMMIT: https://review.gluster.org/18553 committed in master by Aravinda VK (avishwan) 
------
commit 738c38f0efa7b4d4dab0cf23d00589d68e4eb88d
Author: Kotresh HR <khiremat>
Date:   Mon Oct 23 06:46:49 2017 -0400

    libgfchangelog: Fix possible null pointer dereference
    
    If pthread_attr_init fails, gf_msg uses this->name
    where 'this' is not initialized yet. This patch fixes
    the same.
    
    Change-Id: Ie004cbe1015a0d62fc3b5512e8954c5606eeeb5f
    Signed-off-by: Kotresh HR <khiremat>
    BUG: 1505325

Comment 3 Shyamsundar 2017-12-08 17:44:30 UTC
This bug is getting closed because a release has been made available that should address the reported issue. In case the problem is still not fixed with glusterfs-3.13.0, please open a new bug report.

glusterfs-3.13.0 has been announced on the Gluster mailinglists [1], packages for several distributions should become available in the near future. Keep an eye on the Gluster Users mailinglist [2] and the update infrastructure for your distribution.

[1] http://lists.gluster.org/pipermail/announce/2017-December/000087.html
[2] https://www.gluster.org/pipermail/gluster-users/