linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
To: Mike Fleetwood <mike.fleetwood@googlemail.com>
Cc: linux-btrfs <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH 2/4] btrfs-progs: fix segment fault when exec btrfs-debug-tree as non-root
Date: Thu, 20 Feb 2014 17:59:16 +0800	[thread overview]
Message-ID: <1392890356.2929.6.camel@localhost.localdomain> (raw)
In-Reply-To: <CAMU1PDgNnvuw3cjx4-qfi4PxHiyswdSzjZdoDwv+uEJTvx1r4Q@mail.gmail.com>

On Thu, 2014-02-20 at 08:48 +0000, Mike Fleetwood wrote:
> On 20 February 2014 02:49, Gui Hecheng <guihc.fnst@cn.fujitsu.com> wrote:
> > When exec btrfs-debug-tree as non-root user, we get a segment fault.
> > Because the btrfs_scan_block_devices return a success 0 when we fail
> > to open a device. Now we just return the errno if this case happens.
> >
> > Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
> > ---
> >  utils.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/utils.c b/utils.c
> > index 97e23d5..1878abc 100644
> > --- a/utils.c
> > +++ b/utils.c
> > @@ -1517,7 +1517,8 @@ scan_again:
> >                 scans++;
> >                 goto scan_again;
> >         }
> > -       return 0;
> > +
> > +       return errno ? -errno : 0;
> >  }
> >
> >  u64 parse_size(char *s)
> > --
> > 1.8.1.4
> 
> Hi Gui,
> 
> This strikes me as not not right because errno is only documented as
> being set when open() returns -1 on failure.  In the success case
> errno is not set so you can't assume it will be 0.
> 
> I think the following might work:
> 1) Initilase ret = 0 at the start of btrfs_scan_block_devices()
> 2) In the open(fullpath, O_RDONLY) failure case set ret = fd
> 3) return ret
> 
> Thanks,
> Mike
Hi Mike,
Thanks for your comment, I think it is a reasonable way to fix the ret
value problem.
But I am sorry that my patch does not really address the segmentfault
problem.

Please *ignore* this patch...

-Gui
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



  reply	other threads:[~2014-02-20 10:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-20  2:49 [PATCH 1/4] btrfs-progs: judge the return value of check_mounted more accurately Gui Hecheng
2014-02-20  2:49 ` [PATCH 2/4] btrfs-progs: fix segment fault when exec btrfs-debug-tree as non-root Gui Hecheng
2014-02-20  8:48   ` Mike Fleetwood
2014-02-20  9:59     ` Gui Hecheng [this message]
2014-02-20  2:49 ` [PATCH 3/4] btrfs-progs: fix wrong error msg for exec btrfsck " Gui Hecheng
2014-02-20  2:49 ` [PATCH 4/4] btrfs-progs: clean the unnecessary error msg of btrfs-file-show Gui Hecheng

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=1392890356.2929.6.camel@localhost.localdomain \
    --to=guihc.fnst@cn.fujitsu.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=mike.fleetwood@googlemail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).