Received: from eggs.gnu.org ([2001:4830:134:3::10]:33241) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bknRT-0003AZ-Nc for qemu-devel@nongnu.org; Fri, 16 Sep 2016 03:20:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bknRN-0007yh-Le for qemu-devel@nongnu.org; Fri, 16 Sep 2016 03:20:10 -0400 Received: from 4.mo6.mail-out.ovh.net ([87.98.184.159]:53572) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bknRN-0007xv-FR for qemu-devel@nongnu.org; Fri, 16 Sep 2016 03:20:05 -0400 Received: from player776.ha.ovh.net (b7.ovh.net [213.186.33.57]) by mo6.mail-out.ovh.net (Postfix) with ESMTP id 95BDCFFBD70 for ; Fri, 16 Sep 2016 09:20:03 +0200 (CEST) Date: Fri, 16 Sep 2016 09:19:55 +0200 From: Greg Kurz Message-ID: <20160916091955.0706cc6a@bahia> In-Reply-To: <147398054143.25432.18026157491978434193.stgit@bahia> References: <147398054143.25432.18026157491978434193.stgit@bahia> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] 9pfs: fix potential segfault during walk List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: "Aneesh Kumar K.V" , Paolo Bonzini , Michael Roth , qemu-stable@nongnu.org On Fri, 16 Sep 2016 01:05:11 +0200 Greg Kurz wrote: > If the call to fid_to_qid() returns an error, we will call v9fs_path_free() > on uninitialized paths. > I'll add this to the changelog: It is a regression introduced by the following commit: 56f101ecce0e 9pfs: handle walk of ".." in the root directory > Let's fix this by initializing dpath and path before calling fid_to_qid(). > > Signed-off-by: Greg Kurz > --- > > Thanks Paolo (and Coverity) for spotting this. > > Cc'ing stable as this is a regression introduced in 2.7. It is also present > in Michael's stable-2.6-staging branch. > > hw/9pfs/9p.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c > index dfe293d11d1c..91a497079acb 100644 > --- a/hw/9pfs/9p.c > +++ b/hw/9pfs/9p.c > @@ -1320,13 +1320,14 @@ static void v9fs_walk(void *opaque) > goto out_nofid; > } > > + v9fs_path_init(&dpath); > + v9fs_path_init(&path); > + > err = fid_to_qid(pdu, fidp, &qid); > if (err < 0) { > goto out; > } > > - v9fs_path_init(&dpath); > - v9fs_path_init(&path); > /* > * Both dpath and path initially poin to fidp. > * Needed to handle request with nwnames == 0 >