[Bugs] [Bug 1383593] New: glfs_realpath() should not return malloc()' d allocated memory

bugzilla at redhat.com bugzilla at redhat.com
Tue Oct 11 07:31:48 UTC 2016


https://bugzilla.redhat.com/show_bug.cgi?id=1383593

            Bug ID: 1383593
           Summary: glfs_realpath() should not return malloc()'d allocated
                    memory
           Product: GlusterFS
           Version: 3.7.15
         Component: libgfapi
          Keywords: Triaged
          Severity: medium
          Assignee: ndevos at redhat.com
          Reporter: ndevos at redhat.com
        QA Contact: sdharane at redhat.com
                CC: bugs at gluster.org
        Depends On: 1370931



+++ This bug was initially created as a clone of Bug #1370931 +++

Description of problem:
Very similar to how upcall events are allocated by gfapi and returned to the
applications, glfs_realpath() uses malloc(). 

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

How reproducible:
Compile an application that calls glfs_realpath() and have the function
allocate the memory on behalf of the application. If the application uses a
different memory allocated (i.e. jemalloc), free() will not work correctly and
can cause segfaults.

Additional info:
See http://review.gluster.org/14701 for a more complete description.

--- Additional comment from Worker Ant on 2016-08-28 16:36:33 CEST ---

REVIEW: http://review.gluster.org/15332 (gfapi: warn when glfs_realpath()
returned malloc'd memory) posted (#1) for review on master by Niels de Vos
(ndevos at redhat.com)

--- Additional comment from Worker Ant on 2016-08-29 13:52:54 CEST ---

REVIEW: http://review.gluster.org/15332 (gfapi: warn when glfs_realpath()
returned malloc'd memory) posted (#2) for review on master by Niels de Vos
(ndevos at redhat.com)

--- Additional comment from Worker Ant on 2016-08-29 22:05:12 CEST ---

REVIEW: http://review.gluster.org/15332 (gfapi: warn when glfs_realpath()
returned malloc'd memory) posted (#3) for review on master by Niels de Vos
(ndevos at redhat.com)

--- Additional comment from Worker Ant on 2016-09-13 13:40:25 CEST ---

REVIEW: http://review.gluster.org/15332 (gfapi: warn when glfs_realpath()
returned malloc'd memory) posted (#4) for review on master by Niels de Vos
(ndevos at redhat.com)

--- Additional comment from Worker Ant on 2016-09-30 13:10:24 CEST ---

REVIEW: http://review.gluster.org/15332 (gfapi: warn when glfs_realpath()
returned malloc'd memory) posted (#5) for review on master by Niels de Vos
(ndevos at redhat.com)

--- Additional comment from Worker Ant on 2016-09-30 15:49:11 CEST ---

REVIEW: http://review.gluster.org/15332 (gfapi: warn when glfs_realpath()
returned malloc'd memory) posted (#6) for review on master by Niels de Vos
(ndevos at redhat.com)

--- Additional comment from Worker Ant on 2016-10-10 15:33:38 CEST ---

REVIEW: http://review.gluster.org/15332 (gfapi: warn when glfs_realpath()
returned malloc'd memory) posted (#7) for review on master by Niels de Vos
(ndevos at redhat.com)

--- Additional comment from Worker Ant on 2016-10-11 09:14:04 CEST ---

COMMIT: http://review.gluster.org/15332 committed in master by Niels de Vos
(ndevos at redhat.com) 
------
commit 85e959052148ec481823d55c8b91cdee36da2b43
Author: Niels de Vos <ndevos at redhat.com>
Date:   Tue Sep 13 09:03:56 2016 +0200

    gfapi: warn when glfs_realpath() returned malloc'd memory

    glfs_realpath() may return memory allocated with malloc(). Depending on
    the memory allocator that the application uses, calling free() on the
    returned string can cause segmentation faults or other problems.

    Functions that allocate memory, need to match the free'ing of the same
    memory allocator and memory accounting. glibc/malloc and jemalloc/free
    do not match together (other allocators could probably trigger these
    problems as well).

    Applications need to provide a pre-allocated buffer, or in case
    glfs_realpath() allocates the memory, glfs_free() should be used to free
    it.

    Change-Id: I5d721a7425674aa700db8a7a436cbedb95a5927f
    BUG: 1370931
    Signed-off-by: Niels de Vos <ndevos at redhat.com>
    Reviewed-on: http://review.gluster.org/15332
    CentOS-regression: Gluster Build System <jenkins at build.gluster.org>
    Smoke: Gluster Build System <jenkins at build.gluster.org>
    NetBSD-regression: NetBSD Build System <jenkins at build.gluster.org>
    Reviewed-by: Kaleb KEITHLEY <kkeithle at redhat.com>


Referenced Bugs:

https://bugzilla.redhat.com/show_bug.cgi?id=1370931
[Bug 1370931] glfs_realpath() should not return malloc()'d allocated memory
-- 
You are receiving this mail because:
You are on the CC list for the bug.
Unsubscribe from this bug https://bugzilla.redhat.com/token.cgi?t=De9w9aamK7&a=cc_unsubscribe


More information about the Bugs mailing list