From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:51826) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TMn9n-0002wQ-TH for qemu-devel@nongnu.org; Fri, 12 Oct 2012 17:52:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TMn9m-000070-5h for qemu-devel@nongnu.org; Fri, 12 Oct 2012 17:52:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45959) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TMn9l-00006B-TY for qemu-devel@nongnu.org; Fri, 12 Oct 2012 17:52:34 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9CLqXeT020665 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 12 Oct 2012 17:52:33 -0400 Message-ID: <50789120.2020805@redhat.com> Date: Fri, 12 Oct 2012 15:52:32 -0600 From: Eric Blake MIME-Version: 1.0 References: <37ca1a150224c144f9329fc8408f78c388f50a02.1349848348.git.jcody@redhat.com> In-Reply-To: <37ca1a150224c144f9329fc8408f78c388f50a02.1349848348.git.jcody@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig4ADDCB20A71DC2AD4CCCB7C3" Subject: Re: [Qemu-devel] [PATCH 1/2] block: make bdrv_find_backing_image compare canonical filenames List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jeff Cody Cc: kwolf@redhat.com, pbonzini@redhat.com, qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig4ADDCB20A71DC2AD4CCCB7C3 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 10/09/2012 11:56 PM, Jeff Cody wrote: > Currently, bdrv_find_backing_image compares bs->backing_file with > what is passed in as a backing_file name. Mismatches may occur, > however, when bs->backing_file and backing_file are both not > absolute or relative. >=20 > Use path_combine() to make sure any relative backing filenames are > relative to the current image filename being searched, and then use > realpath() to make all comparisons based on absolute filenames. >=20 > This also changes bdrv_find_backing_image to no longer be recursive, > but iterative. >=20 > Signed-off-by: Jeff Cody > --- > block.c | 38 ++++++++++++++++++++++++++++++++------ > 1 file changed, 32 insertions(+), 6 deletions(-) >=20 > + for (curr_bs =3D bs; curr_bs->backing_hd; curr_bs =3D curr_bs->bac= king_hd) { > + /* If not an absolute filename path, make it relative to the c= urrent > + * image's filename path */ > + path_combine(filename_tmp, sizeof(filename_tmp), > + curr_bs->filename, backing_file); I just realized that it is possible to set up a qcow2 file that wraps a network protocol as its backing source, such as 'nbd:...'. In this case, what does path_combine() do to that user string? > + > + /* We are going to compare absolute pathnames */ > + if (!realpath(filename_tmp, filename_full)) { > + continue; > + } and realpath() certainly won't like it (most likely, it won't exist in the file system, but on the off chance that it does, that file is much different than the real protocol that we are using as the backing source)= =2E I'm afraid you may need a followup patch that handles the case of a non-file backing protocol, and insist on an exact match in that case without trying any normalization. --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enig4ADDCB20A71DC2AD4CCCB7C3 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/ iQEcBAEBCAAGBQJQeJEgAAoJEKeha0olJ0Nq+SMIAK5YGXwsldrDfGGuhCrOi7n3 EuPbYq0g51yIbZDQ9reFT+RYVkbDp8nJEdZFYwUb4hNFkfewQA8e2h/Os/L2jsuS vAKBpw3WX6Sq+0glaL33OGPaHLMA22rTEeX00kTa0o+97/1W/z6U5DiPG3EjMNpK HeVRsjiamfxisXRDtw4lbHhw6Ys0UovEQRrr0py+kQStVQzOjbu7IuqyB5Y53SZE aiggsxhU9iUJEJ1YaMjiABN5qZdr2MAaiwaV54G4dYla920Pv3MCPz5aKkCx0yN2 CvhOMFzeJ7A5MJLt+SGUCZpGEh5TchmgdHJPhpb4KR+NweiQpt8vC9GKenW/Wgk= =UIqi -----END PGP SIGNATURE----- --------------enig4ADDCB20A71DC2AD4CCCB7C3--