From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:35219) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TM0YN-0007N2-Er for qemu-devel@nongnu.org; Wed, 10 Oct 2012 13:58:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TM0YF-0000Hv-DT for qemu-devel@nongnu.org; Wed, 10 Oct 2012 13:58:43 -0400 Message-ID: <5075B73E.9020506@redhat.com> Date: Wed, 10 Oct 2012 11:58:22 -0600 From: Eric Blake MIME-Version: 1.0 References: <1349868762-10021-1-git-send-email-pbonzini@redhat.com> <50759EEC.8070308@weilnetz.de> <50759F9E.3060800@redhat.com> In-Reply-To: <50759F9E.3060800@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig2E036F849F6642211FD8F566" Subject: Re: [Qemu-devel] [PATCH] virtfs-proxy-helper: check return code of setfsgid/setfsuid List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-trivial@nongnu.org, Stefan Weil , qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig2E036F849F6642211FD8F566 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 10/10/2012 10:17 AM, Paolo Bonzini wrote: > Il 10/10/2012 18:14, Stefan Weil ha scritto: >>> >>> >>> diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.= c >>> index f9a8270..b34a84a 100644 >>> --- a/fsdev/virtfs-proxy-helper.c >>> +++ b/fsdev/virtfs-proxy-helper.c >>> @@ -290,8 +290,12 @@ static int setfsugid(int uid, int gid) >>> CAP_DAC_OVERRIDE, >>> }; >>> - setfsgid(gid); >>> - setfsuid(uid); >>> + if (setfsgid(gid) !=3D 0) { >>> + return -1; >>> + } >> >> Wouldn't setfsgid(gid) =3D=3D gid be also ok? >=20 > Of course, it should be < 0. I have no idea how to test this thing... POSIX states that uid_t and gid_t may be unsigned, so checking for < 0 is not necessarily possible (really, all you can check for is equality with the same value as ((uid_t)-1) when put through integer promotion rules). --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enig2E036F849F6642211FD8F566 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://www.enigmail.net/ iQEcBAEBCAAGBQJQdbc+AAoJEKeha0olJ0NqkbEH/3AaFLRZiJz1SqPWD80U0OES eWSpoYJYxHTMKlZYwxPGPyUeI0qrCAKbEVyjVO36F55T0az5YD8ubV0qGYO1It9O qQhkrbWmpN235jUTX2VW/RahO5cNFS6kvbL+xoGa1LzBftUqFv/1gjknIMRDlU36 6hGczQuhm4N97ycYDRd1uUD3TrBiXIpUFjDRZOVqjnwQda9/Esjc4+mjkAcfS6r2 3rQHUQk2CRqi6RarWyLggORym4ck95rQgnymdNl7gNpllBJ3VboEmE7KfvOiB3UA MvcorI8fOv/4tD52+VIMT0GSZp021TxWADcGdYIw23m8RCfapAB5fXtmvA0cNlo= =pFH2 -----END PGP SIGNATURE----- --------------enig2E036F849F6642211FD8F566--