Received: from eggs.gnu.org ([2001:4830:134:3::10]:34158) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZFj4d-00082p-EE for qemu-devel@nongnu.org; Thu, 16 Jul 2015 09:19:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZFj4c-0002Se-Ga for qemu-devel@nongnu.org; Thu, 16 Jul 2015 09:19:39 -0400 Date: Thu, 16 Jul 2015 14:19:28 +0100 From: Stefan Hajnoczi Message-ID: <20150716131928.GB16984@stefanha-thinkpad.redhat.com> References: <20150709105213.GE28530@stefanha-thinkpad.redhat.com> <6FA64178-06AB-4C41-9A90-6FCD8ADF0CE4@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="CdrF4e02JqNVZeln" Content-Disposition: inline In-Reply-To: <6FA64178-06AB-4C41-9A90-6FCD8ADF0CE4@gmail.com> Subject: Re: [Qemu-devel] [Qemu-block] [PATCH] raw-posix.c: Make physical devices usable in QEMU List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Programmingkid Cc: Kevin Wolf , qemu-devel qemu-devel , Qemu-block --CdrF4e02JqNVZeln Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jul 09, 2015 at 10:02:26AM -0400, Programmingkid wrote: >=20 > On Jul 9, 2015, at 6:52 AM, Stefan Hajnoczi wrote: >=20 > > On Tue, Jul 07, 2015 at 01:33:23PM -0400, Programmingkid wrote: > >> Make physical devices like a USB flash drive or a CDROM drive work in = QEMU. With > >> this patch I can use a USB flash drive like a hard drive. Before this = patch,=20 > >> QEMU would just quit with a message like "resource busy". > >=20 > > The commit message and the description are missing "on Mac OS X". It > > should be clear right away that this applies to Mac only. This works > > fine on Linux and probably other host OSes. >=20 > Yeah, that should have been done. Did you see any issues with the code? QEMU shouldn't silently open a different file than the one given by the user. The user should give the exact device file they want. If there is magic behavior it needs to be documented, but I don't see a reason why that's necessary in the case of device files. QEMU shouldn't mount/unmount the CD-ROM. atexit(3) doesn't handle crashes or abort(). Users may be confused to find their CD-ROM unmounted in those cases and would see this as a bug. Instead we should refuse mounted CD-ROMs so the user understands that block-level access requires them to unmount first. The strcpy/sprintf usage in this patch is unsafe and can lead to buffer overflow, for example in the case of generating command-lines. The command-line buffer is only MAXPATHLEN so prepending the command to the filename could exceed the buffer size. There is also a buffer overflow in the array of devices that need to be mounted. What happens if there are more than 7 devices? --CdrF4e02JqNVZeln Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJVp69gAAoJEJykq7OBq3PICiIH/2tfMna3kR/KJrzUjJTUN5XE cq/1qlUkuLSH61nfBi9TbEc/ri0h34bvi1/zURFfRAJN1jaFhOTn8SB8nFmSvvCr 9dlS5yodsln018ed7QRbPevmkaocvl9iIkKFf3o67mcbkO9njV7XzAPT1Czn69RP xK8f8/1Qarjq746fetsKUegXk3tIwAtZUODMlCI3IxPo7mM9jCDedjBZqXHxhqtj Oa+5B/HebfCkz1yA6lxrHqHilyxNYXmGAvIHP8Rvk8YXyIrvS0tTVzzQ8WlMhgdJ Iel23fn4DVxCU+gsd5ZaQvDq6H1jx0BVcWUJeJkQDweJLwqQn2QJcnXymEZFZT4= =zXlY -----END PGP SIGNATURE----- --CdrF4e02JqNVZeln--