From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1J0z7w-0002gh-Fc for qemu-devel@nongnu.org; Sat, 08 Dec 2007 07:49:52 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1J0z7v-0002ft-CF for qemu-devel@nongnu.org; Sat, 08 Dec 2007 07:49:51 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1J0z7v-0002fi-2W for qemu-devel@nongnu.org; Sat, 08 Dec 2007 07:49:51 -0500 Received: from partizan.velesys.com ([213.184.230.195]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1J0z7u-0004y9-9R for qemu-devel@nongnu.org; Sat, 08 Dec 2007 07:49:50 -0500 Received: from localhost (partizan [10.0.5.24]) by partizan.velesys.com (paritzan.velesys.com) with ESMTP id CD10F341E2E for ; Sat, 8 Dec 2007 14:49:50 +0200 (EET) Received: from partizan.velesys.com ([10.0.5.24]) by localhost (partizan.velesys.com [10.0.5.24]) (amavisd-new, port 10024) with ESMTP id 7AXPSnzHhOdD for ; Sat, 8 Dec 2007 14:49:45 +0200 (EET) Received: from localhost.localdomain (unknown [86.57.155.32]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by partizan.velesys.com (paritzan.velesys.com) with ESMTP id B0514341E2C for ; Sat, 8 Dec 2007 14:49:44 +0200 (EET) Date: Sat, 8 Dec 2007 14:50:51 +0200 From: "Kirill A. Shutemov" Subject: Re: [Qemu-devel] [patch] fix getgroups and getgroups32 syscalls Message-ID: <20071208125051.GA18930@localhost.localdomain> References: <9c10c9f0712071517k3832dea4te2706e302c085e2f@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="jI8keyz6grp/JLjh" Content-Disposition: inline In-Reply-To: <9c10c9f0712071517k3832dea4te2706e302c085e2f@mail.gmail.com> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org --jI8keyz6grp/JLjh Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On [Fri, 07.12.2007 20:17], Lauro Ramos Venancio wrote: > The attached patch fixes a bug in getgroups and getgroups32 syscalls. > The current implementation returns error when size=3D0. >=20 > According the manual: > " If size is zero, list is not modified, but the total number of > supplementary group IDs for the process is returned." >=20 > -- > Lauro Ramos Venancio > OpenBossa Labs - Instituto Nokia de Tecnologia > Recife - Brazil > Index: qemu-arm-eabi/linux-user/syscall.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- qemu-arm-eabi.orig/linux-user/syscall.c 2007-12-07 19:59:03.000000000= -0300 > +++ qemu-arm-eabi/linux-user/syscall.c 2007-12-07 20:01:47.000000000 -0300 > @@ -5024,12 +5024,13 @@ > { > int gidsetsize =3D arg1; > uint16_t *target_grouplist; > - gid_t *grouplist; > + gid_t *grouplist =3D NULL; > int i; > =20 > - grouplist =3D alloca(gidsetsize * sizeof(gid_t)); > + if (gidsetsize) > + grouplist =3D alloca(gidsetsize * sizeof(gid_t)); > ret =3D get_errno(getgroups(gidsetsize, grouplist)); > - if (!is_error(ret)) { > + if (gidsetsize && !is_error(ret)) { > target_grouplist =3D lock_user(VERIFY_WRITE, arg2, gidse= tsize * 2, 0); > if (!target_grouplist) > goto efault; This patch is too noisy, I think. My patch: diff --git a/linux-user/syscall.c b/linux-user/syscall.c index ad97871..96a11a9 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5029,6 +5029,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long = arg1, =20 grouplist =3D alloca(gidsetsize * sizeof(gid_t)); ret =3D get_errno(getgroups(gidsetsize, grouplist)); + if (gidsetsize =3D=3D 0) + break; if (!is_error(ret)) { target_grouplist =3D lock_user(VERIFY_WRITE, arg2, gidsets= ize * 2, 0); if (!target_grouplist) @@ -5179,6 +5181,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long = arg1, =20 grouplist =3D alloca(gidsetsize * sizeof(gid_t)); ret =3D get_errno(getgroups(gidsetsize, grouplist)); + if (gidsetsize =3D=3D 0) + break; if (!is_error(ret)) { target_grouplist =3D lock_user(VERIFY_WRITE, arg2, gidsets= ize * 4, 0); if (!target_grouplist) { --=20 Regards, Kirill A. Shutemov + Belarus, Minsk + Velesys LLC, http://www.velesys.com/ + ALT Linux Team, http://www.altlinux.com/ --jI8keyz6grp/JLjh Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQFHWpMrbWYnhzC5v6oRAqLDAJ9seLcfjs3j/g1VtJlNvxFjg6alsACcCMN5 /uqq9jdpvhCmJ/0UQO3WjTo= =/Ere -----END PGP SIGNATURE----- --jI8keyz6grp/JLjh--