Bug 1625643 - Use CALLOC in dht_layouts_init
Summary: Use CALLOC in dht_layouts_init
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: GlusterFS
Classification: Community
Component: distribute
Version: mainline
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Nithya Balachandran
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-09-05 12:30 UTC by Nithya Balachandran
Modified: 2018-10-23 15:18 UTC (History)
1 user (show)

Fixed In Version: glusterfs-5.0
Clone Of:
Environment:
Last Closed: 2018-10-23 15:18:28 UTC
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Embargoed:


Attachments (Terms of Use)

Description Nithya Balachandran 2018-09-05 12:30:08 UTC
Description of problem:

If dht_layouts_init fails, dht_init cleans it up by calling:

                if (conf->file_layouts) {                                       
                        for (i = 0; i < conf->subvolume_cnt; i++) {             
                                GF_FREE (conf->file_layouts[i]);                
                        }                                                       
                        GF_FREE (conf->file_layouts);                           
                } 

GF_FREE checks and frees non-null values. With malloc, we could end up with random non-null values in the buffer which GF_FREE will attempt to free.


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


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 1 Worker Ant 2018-09-05 12:56:25 UTC
REVIEW: https://review.gluster.org/21094 (cluster/dht: Initialise pointers to null) posted (#1) for review on master by N Balachandran

Comment 2 Worker Ant 2018-09-06 04:52:04 UTC
COMMIT: https://review.gluster.org/21094 committed in master by "N Balachandran" <nbalacha> with a commit message- cluster/dht: Initialise pointers to null

Use calloc in dht_layouts_init so to as to
prevent dht_init from attempting to free
invalid memory in case of failure.

There are other ways to do this (set first failure
to null and break there when cleaning up) but
I prefer having all pointers initialized to null.
This is a one time operation so it should not be
too expensive.

Change-Id: Ie22246047448f1cae971d48fa5aaf2efcaeb42c0
fixes: bz#1625643
Signed-off-by: N Balachandran <nbalacha>

Comment 3 Shyamsundar 2018-10-23 15:18:28 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-5.0, please open a new bug report.

glusterfs-5.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] https://lists.gluster.org/pipermail/announce/2018-October/000115.html
[2] https://www.gluster.org/pipermail/gluster-users/


Note You need to log in before you can comment on or make changes to this bug.