Bug 457519 - groups_search() cannot handle large gid correctly
groups_search() cannot handle large gid correctly
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: kernel (Show other bugs)
i686 Linux
medium Severity medium
: rc
: ---
Assigned To: Jerome Marchand
Petr Beňas
Depends On:
Blocks: 629626 629629
  Show dependency treegraph
Reported: 2008-08-01 06:27 EDT by masaya.hasegawa.hp
Modified: 2015-01-04 17:58 EST (History)
8 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 629626 629629 (view as bug list)
Last Closed: 2011-02-16 11:00:17 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
patch (675 bytes, patch)
2008-08-01 06:27 EDT, masaya.hasegawa.hp
no flags Details | Diff

  None (edit)
Description masaya.hasegawa.hp 2008-08-01 06:27:10 EDT
Description of problem:
RHEL 4.7(X86)

If user account over 0x7fffffff gid, groups_search(kernel/sys.c) does not work 

$ whoami
$ id
uid=502(was) gid=502(was) groups=502(was),600(oninstall),2151678465

$ ls -l /tmp
drwxrwx---  2 root     oninstall   4096 Jul 29 13:56 aaa

user "was" have "oninstall" gid and  should be able to access /tmp/aaa
But "was" cannot access /tmp/aaa

$ ls -l /tmp/aaa
ls: /tmp/aaa: Permission denied

As a result of investigation, I think  groups_search() function has a bug.
The argument gid_t grp is unsigned int. However cmp is int. If gid is 
over 0x7fffffff(2147483647), value of cmp will become incorrect value.
As a result, return value will be incorrect(0) also. 

/* a simple bsearch */
int groups_search(struct group_info *group_info, gid_t grp)
        int left, right;

        if (!group_info)
                return 0;

        left = 0;
        right = group_info->ngroups;
        while (left < right) {
                int mid = (left+right)/2;
                int cmp = grp - GROUP_AT(group_info, mid);
                if (cmp > 0)
                        left = mid + 1;
                else if (cmp < 0)
                        right = mid;
                        return 1;
        return 0;

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

How reproducible:

Steps to Reproduce:

1.  create account and set data to /etc/group so that it have the below gids.


$ id was
uid=502(was) gid=502(was) groups=502(was),600(oninstall),2151678465

2. #mkdir /tmp/aaa
    #chgrp oninstall /tmp/aaa

3.  # su - was
    [was]$ ls -l /tmp/aaa
    ls: /tmp/aaa: Permission denied
Actual results:

ls fail with "Permission denied error"

Expected results:

ls success

Additional info:

I think this can be fixed by attachment way.
Comment 1 masaya.hasegawa.hp 2008-08-01 06:27:10 EDT
Created attachment 313181 [details]
Comment 10 RHEL Product and Program Management 2009-03-12 14:52:13 EDT
Since RHEL 4.8 External Beta has begun, and this bugzilla remains 
unresolved, it has been rejected as it is not proposed as exception or 
Comment 13 RHEL Product and Program Management 2010-10-12 13:10:58 EDT
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux maintenance release.  Product Management has requested
further review of this request by Red Hat Engineering, for potential
inclusion in a Red Hat Enterprise Linux Update release for currently deployed
products.  This request is not yet committed for inclusion in an Update
Comment 15 Vivek Goyal 2010-10-15 09:26:45 EDT
Committed in 89.44.EL . RPMS are available at http://people.redhat.com/vgoyal/rhel4/
Comment 19 Petr Beňas 2010-12-22 09:31:15 EST
Reproduced in 2.6.9-89.43.EL and verified in 2.6.9-89.44.EL.
Comment 21 errata-xmlrpc 2011-02-16 11:00:17 EST
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.


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