From: Aniruddha M M. <ani...@wi...> - 2003-04-09 13:25:09
|
Please consider this file instead of the previous one.=20 Thanks Aniruddha. |-----Original Message----- |From: Aniruddha M Marathe=20 |Sent: Wednesday, April 09, 2003 5:31 PM |To: Dan Kegel |Cc: Robert Williamson; ltp...@li... |Subject: RE: [LTP] [PATCH] new testcase setegid01 | | |Right now, Madhu is busy with some other work. However, I had=20 |discussion with him on this issue. |He studied the issue and agreed with Dan's comment. |We should fix getresgid02. |I have attached the modified file. Please check the same. | |Thanks, |Aniruddha |--------------------------------------------------------------- |Mr. Aniruddha Marathe |Systems Engineer, |WIPRO technologies, |53/1, Hosur road, |Madivala, |Bangalore - 560068 |Karnataka, India |Phone: +91-80-5502001 extension 5092 |E-mail: ani...@wi... |--------------------------------------------------------------- | | ||-----Original Message----- ||From: Dan Kegel [mailto:da...@ke...]=20 ||Sent: Tuesday, April 08, 2003 10:32 PM ||To: Robert Williamson ||Cc: 'ltp...@li...'; mck...@co...;=20 ||sf...@ca...; madhu tarikere lakshminaryan ||Subject: Re: [LTP] [PATCH] new testcase setegid01 || || ||Robert Williamson wrote: ||> I added this new testcase to the LTP and the runtest/syscall=20 ||script. I was ||> actually made aware of this bug by someone working on ppc=20 ||testing here, but ||> forgot about it.....thanks for reminding me. How do you=20 ||think we should go ||> about fixing setresgid02? || ||First off, let's ask Madhu, he wrote the test. ||But here's my guess: || ||Notice the comment in setresgid02.setup(): || || /* Set effective group id by setregid, since root, sets=20 ||saved gid also */ || if (setregid(-1,nobody_gid) =3D=3D -1) { || ||My first impression is that line should change to be ||more like the one in setresgid03.setup(), i.e. || || /* Set real/effective/saved gid to root/nobody/nobody */ || if (setresgid(root_gid, nobody_gid, nobody_gid) =3D=3D -1) { || ||but I really want to know whether Madhu still believes that ||commment about "since root, sets saved gid also" after ||reading the Posix spec for setregid(). ||- Dan || ||>=20 ||> - Robbie ||>=20 ||> Robert V. Williamson <ro...@us...> ||> Linux Test Project ||> IBM Linux Technology Center ||> Phone: (512) 838-9295 T/L: 678-9295 ||> Fax: (512) 838-4603 ||> Web: http://ltp.sourceforge.net ||> IRC: #ltp on freenode.irc.net ||> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ||> "Only two things are infinite, the universe and human=20 ||stupidity, and I'm ||> not sure about the former." -Albert Einstein ||>=20 ||>=20 ||> =20 || =20 || =20 ||> Dan Kegel =20 || =20 || =20 ||> <da...@ke...> To: =20 || "'ltp...@li...'"=20 ||<ltp...@li...> =20 ||> Sent by: cc: =20 || sf...@ca..., mck...@co... =20 || =20 ||> ltp...@li...ur =20 ||Subject: [LTP] [PATCH] new testcase setegid01 (was:=20 ||Bug#182386: libc6: setegid on =20 ||> ceforge.net i386=20 ||uses setregid and therefore sets saved gid) =20 || =20 ||> =20 || =20 || =20 ||> =20 || =20 || =20 ||> 04/06/2003 10:33 PM =20 || =20 || =20 ||> =20 || =20 || =20 ||>=20 ||>=20 ||>=20 ||>=20 ||> On 24 Feb 2003, Stephen Rothwell (sf...@ca...)=20 ||wrote in newsgroup ||> linux.debian.maint.glibc: ||>=20 ||>>One of the LTP tests (setresgid02) was failing on PPC64 and=20 ||succeeding on ||>>I386 and it turns out that the test makes the assumption=20 ||that setegid() ||>>sets the saved gid as well as the effective gid. According to the ||>=20 ||> POSIX.1 ||>=20 ||>>2001 (SUSv3) setegid should not change the saved gid. On=20 ||i386 setegid() ||>>is currently using setregid32() at the system call level=20 ||while on ppc64 ||>>it uses setresgid(). In the glibc sources, it appears that=20 |setegid() ||>>should be using setresgid() on i386, but strace/ltrace shows=20 ||otherwise. ||>> ||>>The setegid manual page actually says: ||>> ||>> Under libc4, libc5 and glibc2.0 seteuid(euid) =20 ||is equivalent ||>> to setreuid(-1, euid) and hence may change the=20 ||saved user ||>> ID. Under glibc2.1 it is equivalent to=20 |setresuid(-1, euid,-1) ||>> and hence does not change the saved user ID. =20 |Similar remarks ||>> hold for setegid. ||>> ||>>I am not sure if this is just a bug in the way glibc is=20 ||built for i386, ||>>or some strange interaction with the headre files. ||>=20 ||>=20 ||> I am also seeing setresgid02 failing on ppc32 and sh4 with glibc. ||> Here's the output on ppc32 with a couple added prints: ||>=20 ||> # ./setresgid02 ||> Calling setegid(99) ||> calling setresgid(-1, -1, -1) ||> getresgid reports rgid 0, egid 99, sgid 0 ||> Expected rgid 0, egid 99, sgid 99 ||> setresgid02 1 FAIL : Functionality test for=20 ||setresgid(-1, -1, -1) ||> failed ||>=20 ||> And (if we can trust it) here's what strace says: ||> write(1, "Calling setegid(99)\n", 20) =3D 20 ||> setresgid(rgid 4294967295, egid 99, sgid 4294967295) =3D 0 ||> write(1, "calling setresgid(-1, -1, -1)\n", 30) =3D 30 ||> setresgid(rgid 4294967295, egid 4294967295, sgid 4294967295) =3D 0 ||> getresgid(rgid ..., egid ..., sgid ...) =3D 0 ||> write(1, "getresgid reports rgid 0, egid 9"..., 42) =3D 42 ||> write(1, "Expected rgid 0, egid 99, sgid 9"..., 34) =3D 34 ||> write(1, "setresgid02 1 FAIL : Funct"..., 79) =3D 79 ||>=20 ||> The same thing on x86 outputs: ||>=20 ||> Calling setegid(99) ||> calling setresgid(-1, -1, -1) ||> getresgid reports rgid 0, egid 99, sgid 99 ||> Expected rgid 0, egid 99, sgid 99 ||> setresgid02 1 PASS : Test for setresgid(-1, -1, -1) successful ||>=20 ||> And strace says: ||> write(1, "Calling setegid(99)\n", 20) =3D 20 ||> setregid32(0xffffffff, 0x63) =3D 0 ||> write(1, "calling setresgid(-1, -1, -1)\n", 30) =3D 30 ||> setresgid32(0xffffffff, 0xffffffff, 0xffffffff) =3D 0 ||> getsetgid32(0xbffffa44, 0xbffffa40, 0xbffffa3c) =3D 0 ||> write(1, "getresgid reports rgid 0, egid 9"..., 43) =3D 43 ||> write(1, "Expected rgid 0, egid 99, sgid 9"..., 34) =3D 34 ||> write(1, "setresgid02 1 PASS : Test "..., 69) =3D 69 ||>=20 ||> It looks rather as if glibc has a bug in it in x86, just as ||> Stephen Rothwell asserted. I've written a new LTP testcase ||> for this, and it seems to confirm his theory. ||>=20 ||> This means that the test setresgid02 is broken; it was ||> written as if the behavior on x86 is correct. ||>=20 ||> Or so it seems to me. Anyone see a hole in this? ||> If people agree, I guess I should send a bug report in to glibc. ||>=20 ||> Thanks, ||> Dan ||>=20 ||> -- ||> Dan Kegel ||> http://www.kegel.com ||>=20 |http://counter.li.org/cgi-bin/runscript/display-person.cgi?user=3D78045 ||> --- /dev/null 2002-08-30 16:31:37.000000000 -0700 ||> +++ ltp-full-20030404/testcases/kernel/syscalls/setegid/setegid01.c ||> 2003-04-06 20:28:25.000000000 -0700 ||> @@ -0,0 +1,115 @@ ||> +/* ||> + * Copyright (c) Dan Kegel 2003 ||> + * ||> + * This program is free software; you can redistribute=20 ||it and/or modify ||> + * it under the terms of the GNU General Public License=20 ||as published by ||> + * the Free Software Foundation; either version 2 of the=20 ||License, or ||> + * (at your option) any later version. ||> + * ||> + * This program is distributed in the hope that it will=20 |be useful, ||> + * but WITHOUT ANY WARRANTY; without even the implied=20 |warranty of ||> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See ||> + * the GNU General Public License for more details. ||> + * ||> + * You should have received a copy of the GNU General=20 ||Public License ||> + * along with this program; if not, write to the Free Software ||> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,=20 ||MA 02111-1307 ||> USA ||> + */ ||> + ||> +/* ||> + * Test Name: setegid01 ||> + * ||> + * Test Description: ||> + * Verify that setegid does not modify the saved gid or real gid. ||> + */ ||> +#include <pwd.h> ||> +#include <sys/types.h> ||> +#include <stdio.h> ||> +#include <unistd.h> ||> +#include <errno.h> ||> +#include "test.h" ||> +#include "usctest.h" ||> + ||> +char *TCID =3D "setegid01"; ||> +int TST_TOTAL =3D 1; /* is this number right? */ ||> +int verbose =3D 0; ||> + ||> +option_t options[] =3D { ||> + { "v", &verbose, NULL }, /* No argument */ ||> + { NULL, NULL, NULL } /* NULL required to end array */ ||> +}; ||> + ||> +void help() ||> +{ ||> + printf(" -v verbose\n"); ||> +} ||> + ||> +int main(int argc, char **argv) ||> +{ ||> + struct passwd nobody; ||> + gid_t nobody_gid; ||> + gid_t cur_rgid, cur_egid, cur_sgid; ||> + gid_t orig_rgid, orig_egid, orig_sgid; ||> + char *msg; ||> + ||> + if ((msg =3D parse_opts(argc, argv, options, help)) !=3D=20 ||(char *)NULL) { ||> + tst_brkm(TBROK, NULL, "Option parsing error - %s", msg); ||> + tst_exit(); ||> + } ||> + ||> + if (geteuid() !=3D 0) { ||> + tst_brkm(TBROK, NULL, "Must be super/root for this test!"); ||> + tst_exit(); ||> + } ||> + ||> + nobody =3D *getpwnam("nobody"); ||> + nobody_gid =3D nobody.pw_gid; ||> + ||> + TEST(getresgid(&orig_rgid, &orig_egid, &orig_sgid)); ||> + if (TEST_RETURN =3D=3D -1) { ||> + tst_resm(TBROK, "getresgid() Failed, errno=3D%d :=20 ||%s", TEST_ERRNO, ||> strerror(TEST_ERRNO)); ||> + tst_exit(); ||> + } ||> + if (verbose) { ||> + printf("getresgid reports rgid %d, egid %d, sgid=20 ||%d\n", orig_rgid, ||> + orig_egid, orig_sgid); ||> + printf("calling setegid(nobody_gid %d)\n", nobody_gid); ||> + } ||> + TEST(setegid(nobody_gid)); ||> + if (TEST_RETURN =3D=3D -1) { ||> + tst_resm(TFAIL, "setegid() Failed, errno=3D%d : %s",=20 ||TEST_ERRNO, ||> strerror(TEST_ERRNO)); ||> + tst_exit(); ||> + } ||> + ||> + TEST(getresgid(&cur_rgid, &cur_egid, &cur_sgid)); ||> + if (TEST_RETURN =3D=3D -1) { ||> + tst_resm(TBROK, "setegid() Failed, errno=3D%d : %s",=20 ||TEST_ERRNO, ||> strerror(TEST_ERRNO)); ||> + tst_exit(); ||> + } ||> + if (verbose) { ||> + printf("getresgid reports rgid %d, egid %d, sgid=20 ||%d\n", cur_rgid, ||> + cur_egid, cur_sgid); ||> + } ||> + ||> + /* make sure it at least does what its name says */ ||> + if (nobody_gid !=3D cur_egid) { ||> + tst_resm(TFAIL, "setegid() Failed functional test:=20 ||it failed to ||> change the effective gid"); ||> + tst_exit(); ||> + } ||> + ||> + /* SUSv3 says the real group ID and saved set-gid must ||> + * remain unchanged by setgid. See ||> + * ||> http://www.opengroup.org/onlinepubs/007904975/functions/setegid.html ||> + */ ||> + if (orig_sgid !=3D cur_sgid) { ||> + tst_resm(TFAIL, "setegid() Failed functional test:=20 ||it changed the ||> saved set-gid"); ||> + tst_exit(); ||> + } ||> + if (orig_rgid !=3D cur_rgid) { ||> + tst_resm(TFAIL, "setegid() Failed functional test:=20 ||it changed the ||> real gid"); ||> + tst_exit(); ||> + } ||> + tst_resm(TPASS, "setegid() passed functional test"); ||> + tst_exit(); ||> + return 0; ||> +} ||> --- /dev/null 2002-08-30 16:31:37.000000000 -0700 ||> +++ ltp-full-20030404/testcases/kernel/syscalls/setegid/Makefile ||> 2003-04-06 20:07:12.000000000 -0700 ||> @@ -0,0 +1,36 @@ ||> +# ||> +# Copyright (c) International Business Machines Corp., 2001 ||> +# ||> +# This program is free software; you can redistribute it=20 ||and/or modify ||> +# it under the terms of the GNU General Public License as=20 ||published by ||> +# the Free Software Foundation; either version 2 of the=20 |License, or ||> +# (at your option) any later version. ||> +# ||> +# This program is distributed in the hope that it will be useful, ||> +# but WITHOUT ANY WARRANTY; without even the implied warranty of ||> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See ||> +# the GNU General Public License for more details. ||> +# ||> +# You should have received a copy of the GNU General=20 |Public License ||> +# along with this program; if not, write to the Free Software ||> +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA=20 ||02111-1307 USA ||> +# ||> + ||>=20 ||+############################################################## ||############# ||>=20 ||> +# name of file : Makefile ||> # ||>=20 ||+############################################################## ||############# ||>=20 ||> +CFLAGS+=3D -I../../../../include -Wall -g ||> +LOADLIBES+=3D -L../../../../lib -lltp ||> + ||> +SRCS=3D$(wildcard *.c) ||> +TARGETS=3D$(patsubst %.c,%,$(SRCS)) ||> + ||> +all: $(TARGETS) ||> + ||> +install: ||> + @set -e; for i in $(TARGETS); do ln -f $$i=20 ||../../../bin/$$i ; ||> done ||> + ||> +clean: ||> + rm -f $(TARGETS) ||> + ||> + ||>=20 ||>=20 ||>=20 ||>=20 ||>=20 || || ||--=20 ||Dan Kegel ||http://www.kegel.com ||http://counter.li.org/cgi-bin/runscript/display-person.cgi?user=3D78045= || || || ||------------------------------------------------------- ||This SF.net email is sponsored by: ValueWeb:=20 ||Dedicated Hosting for just $79/mo with 500 GB of bandwidth!=20 ||No other company gives more support or power for your dedicated server ||http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/ ||_______________________________________________ ||Ltp-list mailing list ||Ltp...@li... ||https://lists.sourceforge.net/lists/listinfo/ltp-list || | |