From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52611) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bdLwe-0002qx-Ba for qemu-devel@nongnu.org; Fri, 26 Aug 2016 14:33:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bdLwZ-0002iu-CO for qemu-devel@nongnu.org; Fri, 26 Aug 2016 14:33:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35884) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bdLwZ-0002ip-4b for qemu-devel@nongnu.org; Fri, 26 Aug 2016 14:33:31 -0400 References: <147222401281.18925.1894824578752486297.stgit@bahia.lan> <147222402095.18925.396915168302239352.stgit@bahia.lan> From: Eric Blake Message-ID: <57C08B78.1040409@redhat.com> Date: Fri, 26 Aug 2016 13:33:28 -0500 MIME-Version: 1.0 In-Reply-To: <147222402095.18925.396915168302239352.stgit@bahia.lan> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="kI13w0gBgWtgVOK2BK8xpMqW5DS6l9PN9" Subject: Re: [Qemu-devel] [PATCH v2 1/5] 9p: forbid illegal path names List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Greg Kurz , qemu-devel@nongnu.org Cc: Peter Maydell , Felix Wilhelm , "Michael S. Tsirkin" , P J P , "Aneesh Kumar K.V" This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --kI13w0gBgWtgVOK2BK8xpMqW5DS6l9PN9 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 08/26/2016 10:07 AM, Greg Kurz wrote: > Empty path components don't make sense and may cause undefined behavior= , > depending on the backend. >=20 > Also, the walk request described in the 9P spec [1] clearly shows that > the client is supposed to send individual path components: the official= > linux client never sends portions of path containing the / character fo= r > example. >=20 > Moreover, the 9P spec [2] also states that a system can decide to restr= ict > the set of supported characters used in path components, with an explic= it > mention "to remove slashes from name components". >=20 > This patch introduces a new name_is_illegal() helper that checks the > names sent by the client are not empty and don't contain unwanted chars= =2E > Since 9pfs is only supported on linux hosts, only the / character is > checked at the moment. When support for other hosts (AKA. win32) is add= ed, > other chars may need to be blacklisted as well. >=20 > If a client sends an illegal path component, the request will fail and > EINVAL is returned to the client. >=20 > [1] http://man.cat-v.org/plan_9/5/walk > [2] http://man.cat-v.org/plan_9/5/intro >=20 > Suggested-by: Peter Maydell > Signed-off-by: Greg Kurz > --- > hw/9pfs/9p.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++= ++++++ > 1 file changed, 56 insertions(+) >=20 > diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c > index b6b02b46a9da..dba11773699b 100644 > --- a/hw/9pfs/9p.c > +++ b/hw/9pfs/9p.c > @@ -1256,6 +1256,11 @@ static int v9fs_walk_marshal(V9fsPDU *pdu, uint1= 6_t nwnames, V9fsQID *qids) > return offset; > } > =20 > +static bool name_is_illegal(const char *name) > +{ > + return name =3D=3D NULL || strchr(name, '/') !=3D NULL; Is anyone actually passing NULL? And the commit message says you are blacklisting the empty string "", but that is not what you did here. Depending on whether callers can even pass NULL, you may be able to just s/name =3D=3D NULL/!*name/ --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --kI13w0gBgWtgVOK2BK8xpMqW5DS6l9PN9 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJXwIt4AAoJEKeha0olJ0NqLMcH/A5hiFL3j2/v5Dt+K2vnuT6m pgxrUEkrRJabVEpCIbdN2daSHlOlj3baBJ2M3qS0SJu+5N46TnHfaJqpbtrYGCbK +Vm1ct42f5bvMFBA42YZoYJxwd9oN+B0fE7/OeIUfU0r4ex1tNE/J0a24Lvsrt3T sW9jOSYljMiagis8g2zovY+ucyYvQXLvnYcCS6YgocgJ2Jmtlx7+lKP43u0D6Atp WubZ7Afb2/WJQ8Klqox8mzJ3g4hpdkVxH1sXlAmZe/XRVwTwc+hMdFje7PvzyeSh GTTDUYXnFe1e+IIJ9uUnKopqFWSiW3BmmoXBvGfzdQH25k0dBknxII6HOBYWg/o= =3mHP -----END PGP SIGNATURE----- --kI13w0gBgWtgVOK2BK8xpMqW5DS6l9PN9--