All of lore.kernel.org
 help / color / mirror / Atom feed
From: Will Deacon <will.deacon@arm.com>
To: "G. Campana" <gcampana+kvm@quarkslab.com>
Cc: kvm@vger.kernel.org, andre.przywara@arm.com
Subject: Re: [PATCH 7/7] kvmtool: 9p: refactor rel_to_abs()
Date: Fri, 18 Nov 2016 15:37:57 +0000	[thread overview]
Message-ID: <20161118153757.GT13470@arm.com> (raw)
In-Reply-To: <890a15c5-9634-7592-288d-a216925d9758@quarkslab.com>

On Fri, Nov 18, 2016 at 04:33:07PM +0100, G. Campana wrote:
> On 11/17/2016 01:20 PM, Will Deacon wrote:
> > On Thu, Nov 10, 2016 at 04:18:54PM +0100, G. Campana wrote:
> >> On 08/11/2016 03:38, Will Deacon wrote:
> >>> On Tue, Oct 18, 2016 at 06:03:05PM +0200, G. Campana wrote:
> >>>> @@ -614,7 +618,6 @@ static void virtio_p9_readdir(struct p9_dev *p9dev,
> >>>>  	struct stat st;
> >>>>  	struct p9_fid *fid;
> >>>>  	struct dirent *dent;
> >>>> -	char full_path[PATH_MAX];
> >>>>  	u64 offset, old_offset;
> >>>>  
> >>>>  	rcount = 0;
> >>>> @@ -645,11 +648,8 @@ static void virtio_p9_readdir(struct p9_dev *p9dev,
> >>>>  			break;
> >>>>  		}
> >>>>  		old_offset = dent->d_off;
> >>>> -		if (rel_to_abs(p9dev, dent->d_name, full_path, sizeof(full_path)) != 0) {
> >>>> -			errno = ENAMETOOLONG;
> >>>> -			goto err_out;
> >>>> -		}
> >>>> -		lstat(full_path, &st);
> >>>> +		if (stat_rel(p9dev, dent->d_name, &st) != 0)
> >>>> +			memset(&st, -1, sizeof(st));
> >>>
> >>> Why the memset, and not goto err_out?
> >>>
> >> Because the user may not be allowed to stat some entries in a directory
> >> and it shouldn't make readdir() fail.
> > 
> > Ok, but is memsetting to -1 really the right thing to do? This gets
> > "converted" into a p9_qid_t, which will then look pretty strange (path
> > and version will be set to 0xff, type will be set to P9_QTDIR).
> > 
> Before this patch, st was either uninitialized or invalid if lstat
> failed, hence the memset call which doesn't break the logic of this
> function. I only tried to fix vulnerabilities in this patch series, and
> I think this issue deserves a separate patch. What do you think?

Well, how about just skipping entries where the stat failed and continuing
around the loop. Does that work?

Will

      reply	other threads:[~2016-11-18 15:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-18 16:03 [PATCH 7/7] kvmtool: 9p: refactor rel_to_abs() G. Campana
2016-11-08  2:38 ` Will Deacon
2016-11-10 15:18   ` G. Campana
2016-11-17 12:20     ` Will Deacon
2016-11-18 15:33       ` G. Campana
2016-11-18 15:37         ` Will Deacon [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161118153757.GT13470@arm.com \
    --to=will.deacon@arm.com \
    --cc=andre.przywara@arm.com \
    --cc=gcampana+kvm@quarkslab.com \
    --cc=kvm@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.