Bug 764012 (GLUSTER-2280) - wrong size allocated for posix_fd in posix.c:posix_opendir()
Summary: wrong size allocated for posix_fd in posix.c:posix_opendir()
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: GLUSTER-2280
Product: GlusterFS
Classification: Community
Component: posix
Version: mainline
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Amar Tumballi
QA Contact:
URL:
Whiteboard:
: GLUSTER-2453 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-01-06 12:26 UTC by Amar Tumballi
Modified: 2013-12-19 00:05 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed:
Regression: RTNR
Mount Type: ---
Documentation: DNR
CRM:
Verified Versions:


Attachments (Terms of Use)

Description Amar Tumballi 2011-01-06 12:26:10 UTC
@@ -978,7 +977,7 @@ posix_opendir (call_frame_t *frame, xlator_t *this,
                goto out;
        }
 
-        pfd = GF_CALLOC (1, sizeof (*fd), gf_posix_mt_posix_fd);
+        pfd = GF_CALLOC (1, sizeof (*pfd), gf_posix_mt_posix_fd);
 

The above patch fixes the issue. This is not very critical at the moment as sizeof of 'fd_t' is more than sizeof 'struct posix_fd', but it crashes with corruption when more members are added to posix_fd structure.

Comment 1 Harshavardhana 2011-01-06 22:09:25 UTC
(In reply to comment #0)
> @@ -978,7 +977,7 @@ posix_opendir (call_frame_t *frame, xlator_t *this,
>                 goto out;
>         }
> 
> -        pfd = GF_CALLOC (1, sizeof (*fd), gf_posix_mt_posix_fd);
> +        pfd = GF_CALLOC (1, sizeof (*pfd), gf_posix_mt_posix_fd);
> 
> 
> The above patch fixes the issue. This is not very critical at the moment as
> sizeof of 'fd_t' is more than sizeof 'struct posix_fd', but it crashes with
> corruption when more members are added to posix_fd structure.

what is the error user feels? what is the user error seen?. 

Can this lead to opendir sending "EPERM" back to application?

Comment 2 Amar Tumballi 2011-01-07 04:58:42 UTC
> 
> what is the error user feels? what is the user error seen?. 
> 
> Can this lead to opendir sending "EPERM" back to application?

Nope, this is a code internal bug, at the max, it will lead to corruption/crash internally.

in normal cases (ie, in all the codebase we have in glusterfs.git) it works fine, as gf_calloc() succeeds, just that it gives more size for fd_ctx pointer.

the error pops up only when 'posix_fd' structure's size becomes more than that of 'fd_t' structure's size. (It happened when I was doing some work on snapshot feature).

No one needs to be bothered by this, other than developers, who ideally should do more careful review of their code before submitting.

Comment 3 Anand Avati 2011-01-07 22:43:49 UTC
PATCH: http://patches.gluster.com/patch/5966 in master (storage/posix: in opendir, allocate proper size for fd ctx pointer)

Comment 4 Amar Tumballi 2011-02-23 10:25:13 UTC
*** Bug 2453 has been marked as a duplicate of this bug. ***

Comment 5 Saurabh 2011-03-03 02:52:59 UTC
this is related to change in pointer usage and earlier also it was not causing any issues to the functionality.


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