before 2.0.30 pls fix "if (grp == current->euid)"

Garst R. Reese (reese@isn.net)
Mon, 31 Mar 1997 18:41:02 -0400


This is a multi-part message in MIME format.

--------------1F67047C519407C4647E2170
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Checking kernel.org pre-patch-2.0.30, the apparent typo in
kernel/sysctl.c is still unfixed. I have attached the relevant parts of
the patch to 2.1.12 that dealt with this problem. I guess it does not
bother much, because it sat there from 2.0.0 thru 2.1.11
Thanks, Garst

-- 
I just can't tolerate intolerance :>)

--------------1F67047C519407C4647E2170 Content-Type: text/plain; charset=us-ascii; name="ptch2112.sub" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ptch2112.sub"

diff -u --recursive --new-file v2.1.11/linux/kernel/sys.c linux/kernel/sys.c --- v2.1.11/linux/kernel/sys.c Tue Nov 19 15:53:59 1996 +++ linux/kernel/sys.c Fri Nov 22 11:49:58 1996 @@ -699,20 +699,15 @@ asmlinkage int sys_getgroups(int gidsetsize, gid_t *grouplist) { int i; - int * groups; if (gidsetsize < 0) return -EINVAL; - groups = current->groups; - for (i = 0 ; i < NGROUPS ; i++) { - if (groups[i] == NOGROUP) - break; - } + i = current->ngroups; if (gidsetsize) { if (i > gidsetsize) return -EINVAL; - if (copy_to_user(grouplist, groups, sizeof(*groups)*i)) - return -EFAULT; + if (copy_to_user(grouplist, current->groups, sizeof(gid_t)*i)) + return -EFAULT; } return i; } @@ -723,32 +718,34 @@ if (!suser()) return -EPERM; - if (gidsetsize > NGROUPS) + if ((unsigned) gidsetsize > NGROUPS) return -EINVAL; err = copy_from_user(current->groups, grouplist, gidsetsize * sizeof(gid_t)); if (err) { - gidsetsize = err/sizeof(gid_t); /* +1? */ - err = -EFAULT; - } - if (gidsetsize < NGROUPS) - current->groups[gidsetsize] = NOGROUP; + gidsetsize = 0; + err = -EFAULT; + } + current->ngroups = gidsetsize; return err; } int in_group_p(gid_t grp) { - int i; - - if (grp == current->fsgid) - return 1; - - for (i = 0; i < NGROUPS; i++) { - if (current->groups[i] == NOGROUP) - break; - if (current->groups[i] == grp) - return 1; + if (grp != current->fsgid) { + int i = current->ngroups; + if (i) { + gid_t *groups = current->groups; + do { + if (*groups == grp) + goto out; + groups++; + i--; + } while (i); + } + return 0; } - return 0; +out: + return 1; } asmlinkage int sys_newuname(struct new_utsname * name) diff -u --recursive --new-file v2.1.11/linux/kernel/sysctl.c linux/kernel/sysctl.c --- v2.1.11/linux/kernel/sysctl.c Sun Nov 10 20:12:19 1996 +++ linux/kernel/sysctl.c Fri Nov 22 11:50:57 1996 @@ -229,19 +229,23 @@ /* Like in_group_p, but testing against egid, not fsgid */ static int in_egroup_p(gid_t grp) { - int i; - - if (grp == current->euid) - return 1; - - for (i = 0; i < NGROUPS; i++) { - if (current->groups[i] == NOGROUP) - break; - if (current->groups[i] == grp) - return 1; + if (grp != current->egid) { + int i = current->ngroups; + if (i) { + gid_t *groups = current->groups; + do { + if (*groups == grp) + goto out; + groups++; + i--; + } while (i); + } + return 0; } - return 0; +out: + return 1; } + /* ctl_perm does NOT grant the superuser all rights automatically, because some sysctl variables are readonly even to root. */ static int test_perm(int mode, int op)

--------------1F67047C519407C4647E2170--